mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-12 13:17:45 +02:00
changed the way watermarked tiktok videos are downloaded
This commit is contained in:
@ -41,16 +41,20 @@ export default async function(obj) {
|
||||
detail = selector(JSON.parse(detail.body), obj.host, obj.postId);
|
||||
if (!detail) throw new Error()
|
||||
} catch (e) {
|
||||
if (obj.host === "tiktok") {
|
||||
let html = await got.get(`https://tiktok.com/@video/video/${obj.postId}`, { headers: { "user-agent": userAgent } });
|
||||
html = html.body;
|
||||
if (html.includes(',"preloadList":[{"url":"')) {
|
||||
try {
|
||||
if (obj.host === "tiktok") {
|
||||
let webAppDetail = await got.get(`https://m.tiktok.com/api/item/detail/?itemId=${obj.postId}`, { headers: { "user-agent": userAgent } });
|
||||
webAppDetail = JSON.parse(webAppDetail.body);
|
||||
return {
|
||||
urls: unicodeDecode(html.split(',"preloadList":[{"url":"')[1].split('","id":"')[0].trim()),
|
||||
urls: webAppDetail.itemInfo.itemStruct.video.downloadAddr,
|
||||
filename: `${obj.host}_${obj.postId}_video.mp4`
|
||||
}
|
||||
} else throw new Error()
|
||||
} else throw new Error()
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'ErrorCouldntFetch') }
|
||||
}
|
||||
} catch (e) {
|
||||
return { error: loc(obj.lang, 'ErrorCouldntFetch') }
|
||||
}
|
||||
}
|
||||
let video, videoFilename, audioFilename, isMp3, audio, images,
|
||||
filenameBase = `${obj.host}_${obj.postId}`;
|
||||
@ -64,10 +68,12 @@ export default async function(obj) {
|
||||
videoFilename = `${filenameBase}_video_nw.mp4` // nw - no watermark
|
||||
if (!obj.noWatermark) {
|
||||
if (obj.host === "tiktok") {
|
||||
let html = await got.get(`https://tiktok.com/@video/video/${obj.postId}`, { headers: { "user-agent": userAgent } });
|
||||
html = html.body;
|
||||
if (html.includes(',"preloadList":[{"url":"')) {
|
||||
video = unicodeDecode(html.split(',"preloadList":[{"url":"')[1].split('","id":"')[0].trim())
|
||||
try {
|
||||
let webAppDetail = await got.get(`https://m.tiktok.com/api/item/detail/?itemId=${obj.postId}`, { headers: { "user-agent": userAgent } });
|
||||
webAppDetail = JSON.parse(webAppDetail.body);
|
||||
video = webAppDetail.itemInfo.itemStruct.video.downloadAddr;
|
||||
} catch (e) {
|
||||
video = detail["video"]["download_addr"]["url_list"][0]
|
||||
}
|
||||
} else {
|
||||
video = detail['video']['play_addr']['url_list'][0]
|
||||
|
Reference in New Issue
Block a user