fixed tiktok support and updated ytdl-core version

This commit is contained in:
wukko 2022-08-30 14:05:39 +06:00
parent 083e61e111
commit 1acfb14d2c
2 changed files with 6 additions and 4 deletions

View file

@ -1,7 +1,7 @@
{
"name": "cobalt",
"description": "save what you love",
"version": "3.3.5",
"version": "3.3.6",
"author": "wukko",
"exports": "./src/cobalt.js",
"type": "module",
@ -32,6 +32,6 @@
"node-cache": "^5.1.2",
"url-pattern": "1.0.3",
"xml-js": "^1.6.11",
"ytdl-core": "4.11.0"
"ytdl-core": "4.11.1"
}
}

View file

@ -3,10 +3,12 @@ import loc from "../../localization/manager.js";
import { genericUserAgent } from "../config.js";
import { unicodeDecode } from "../sub/utils.js";
let userAgent = genericUserAgent.split(' Chrome/1')[0]
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": userAgent } });
html.on('error', (err) => {
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
});
@ -18,7 +20,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": userAgent } });
html.on('error', (err) => {
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
});