From e80d2ec01ef80b6dd88559576823f06dc3d7f087 Mon Sep 17 00:00:00 2001 From: minzique Date: Mon, 29 Aug 2022 15:02:19 +0530 Subject: [PATCH] Fix TikTok download issue --- src/config.json | 1 + src/modules/config.js | 3 ++- src/modules/services/tiktok.js | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config.json b/src/config.json index 8434c240..75d587ca 100644 --- a/src/config.json +++ b/src/config.json @@ -3,6 +3,7 @@ "maxVideoDuration": 1920000, "maxAudioDuration": 4200000, "genericUserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "genericUserAgentTikTok": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)", "authorInfo": { "name": "wukko", "link": "https://wukko.me/", diff --git a/src/modules/config.js b/src/modules/config.js index bd093946..e5d54387 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -12,6 +12,7 @@ export const maxVideoDuration = config.maxVideoDuration, maxAudioDuration = config.maxAudioDuration, genericUserAgent = config.genericUserAgent, + genericUserAgentTikTok = config.genericUserAgentTikTok, repo = packageJson["bugs"]["url"].replace('/issues', ''), authorInfo = config.authorInfo, supportedLanguages = config.supportedLanguages, @@ -19,4 +20,4 @@ export const internetExplorerRedirect = config.internetExplorerRedirect, donations = config.donations, ffmpegArgs = config.ffmpegArgs, - supportedAudio = config.supportedAudio + supportedAudio = config.supportedAudio; diff --git a/src/modules/services/tiktok.js b/src/modules/services/tiktok.js index b7e8bbc9..2ec69c07 100644 --- a/src/modules/services/tiktok.js +++ b/src/modules/services/tiktok.js @@ -1,12 +1,12 @@ import got from "got"; import loc from "../../localization/manager.js"; -import { genericUserAgent } from "../config.js"; +import { genericUserAgentTikTok } from "../config.js"; import { unicodeDecode } from "../sub/utils.js"; export default async function(obj) { try { if (!obj.postId) { - let html = await got.get(`https://vt.tiktok.com/${obj.id}`, { headers: { "user-agent": genericUserAgent } }); + let html = await got.get(`https://vt.tiktok.com/${obj.id}`, { headers: { "user-agent": genericUserAgentTikTok } }); html.on('error', (err) => { return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') }; }); @@ -18,7 +18,7 @@ export default async function(obj) { } } if (!obj.noWatermark && !obj.isAudioOnly) { - let html = await got.get(`https://tiktok.com/@video/video/${obj.postId}`, { headers: { "user-agent": genericUserAgent } }); + let html = await got.get(`https://tiktok.com/@video/video/${obj.postId}`, { headers: { "user-agent": genericUserAgentTikTok } }); html.on('error', (err) => { return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') }; });