Fix TikTok download issue

This commit is contained in:
minzique 2022-08-29 15:02:19 +05:30
parent 083e61e111
commit e80d2ec01e
3 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,7 @@
"maxVideoDuration": 1920000, "maxVideoDuration": 1920000,
"maxAudioDuration": 4200000, "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", "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": { "authorInfo": {
"name": "wukko", "name": "wukko",
"link": "https://wukko.me/", "link": "https://wukko.me/",

View File

@ -12,6 +12,7 @@ export const
maxVideoDuration = config.maxVideoDuration, maxVideoDuration = config.maxVideoDuration,
maxAudioDuration = config.maxAudioDuration, maxAudioDuration = config.maxAudioDuration,
genericUserAgent = config.genericUserAgent, genericUserAgent = config.genericUserAgent,
genericUserAgentTikTok = config.genericUserAgentTikTok,
repo = packageJson["bugs"]["url"].replace('/issues', ''), repo = packageJson["bugs"]["url"].replace('/issues', ''),
authorInfo = config.authorInfo, authorInfo = config.authorInfo,
supportedLanguages = config.supportedLanguages, supportedLanguages = config.supportedLanguages,
@ -19,4 +20,4 @@ export const
internetExplorerRedirect = config.internetExplorerRedirect, internetExplorerRedirect = config.internetExplorerRedirect,
donations = config.donations, donations = config.donations,
ffmpegArgs = config.ffmpegArgs, ffmpegArgs = config.ffmpegArgs,
supportedAudio = config.supportedAudio supportedAudio = config.supportedAudio;

View File

@ -1,12 +1,12 @@
import got from "got"; import got from "got";
import loc from "../../localization/manager.js"; import loc from "../../localization/manager.js";
import { genericUserAgent } from "../config.js"; import { genericUserAgentTikTok } from "../config.js";
import { unicodeDecode } from "../sub/utils.js"; import { unicodeDecode } from "../sub/utils.js";
export default async function(obj) { export default async function(obj) {
try { try {
if (!obj.postId) { 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) => { html.on('error', (err) => {
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') }; return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
}); });
@ -18,7 +18,7 @@ export default async function(obj) {
} }
} }
if (!obj.noWatermark && !obj.isAudioOnly) { 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) => { html.on('error', (err) => {
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') }; return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
}); });