remove(core#ttsaveProvider): removed ttsaveProvider. Why? We cannot use this service anymore, as we cannot obtain cookies from the site to manipulate the sessions. See https://github.com/hansputera/tiktok-dl/pull/9#issue-1084370105

Signed-off-by: hansputera <hanifdwyputrasembiring@gmail.com>
This commit is contained in:
hansputera
2022-03-11 19:13:51 +07:00
parent 6179ec632a
commit ad31281cff
2 changed files with 0 additions and 87 deletions

View File

@@ -1,76 +0,0 @@
import {getFetch} from '../fetch';
import {BaseProvider, ExtractedInfo} from './base';
import {keyGeneratorTTSave, matchLink} from './utils';
/**
* @class TTSave
*/
export class TTSave extends BaseProvider {
/**
* @return {string}
*/
public resourceName(): string {
return 'ttsave';
}
public client = getFetch('https://ttsave.app');
public maintenance = {
reason: "TTSave doesn't returned cookie to manipulate the session",
};
/**
*
* @param {string} url - TikTok Video URL
* @return {Promise<ExtractedInfo>}
*/
public async fetch(url: string): Promise<ExtractedInfo> {
// getting token
const response = await this.client('./');
const token = (
response.body.match(/(m|doDownload)?\(e,"(.*)"\)}/) as string[]
)
.filter((x) => x.length)
.pop() as string;
const key = await keyGeneratorTTSave(token);
const dlResponse = await this.client.post('./download.php', {
json: {
id: url,
token: token,
key: key,
},
headers: {
Origin: this.client.defaults.options.prefixUrl,
Referer: this.client.defaults.options.prefixUrl,
Cookie: response.headers['set-cookie']?.toString(), // no cookies :(
...response.headers,
},
});
return this.extract(dlResponse.body);
}
/**
*
* @param {string} html - HTML Raw
* @return {ExtractedInfo}
*/
extract(html: string): ExtractedInfo {
const tiktokCDNs = (matchLink(html) as string[]).filter((x) =>
/http(s)?:\/\/(.*)?.tiktokcdn.com/gi.test(x),
);
const videoCDNs = tiktokCDNs.filter((x) => !/jpeg/gi.test(x));
return {
video: {
thumb: tiktokCDNs.find((x) => /jpeg/gi.test(x)),
urls: videoCDNs.filter((x) => !/music/gi.test(x)),
},
music: {
url: videoCDNs.find((x) => /music/gi.test(x)) as string,
},
};
}
}

View File

@@ -1,11 +0,0 @@
/**
* Generate key for ttsave.app
*
* @param {string} token - Generated token by TTSave
* @return {string | undefined}
*/
export const keyGeneratorTTSave = async (token: string): Promise<string> => {
const expectedLen = token.length / 3;
return token.split('').reverse().join('').slice(-expectedLen);
};