From 1acfb14d2c1c553b27054c20e2a959afa0327530 Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 30 Aug 2022 14:05:39 +0600 Subject: [PATCH] fixed tiktok support and updated ytdl-core version --- package.json | 4 ++-- src/modules/services/tiktok.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2c61d5b..55067f9 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/modules/services/tiktok.js b/src/modules/services/tiktok.js index b7e8bbc..ef63455 100644 --- a/src/modules/services/tiktok.js +++ b/src/modules/services/tiktok.js @@ -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') }; });