import got from "got"; import loc from "../../localization/manager.js"; import { genericUserAgent } from "../config.js"; import { unicodeDecode } from "../sub/utils.js"; let userAgent = genericUserAgent.split(' Chrome/1')[0] let config = { tiktok: { short: "https://vt.tiktok.com/", api: "https://api2.musical.ly/aweme/v1/feed/?aweme_id={postId}&version_code=262&app_name=musical_ly&channel=App&device_id=null&os_version=14.4.2&device_platform=iphone&device_type=iPhone9", // ill always find more endpoints lmfao }, douyin: { short: "https://v.douyin.com/", api: "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={postId}", } } function selector(j, h, id) { let t; switch (h) { case "tiktok": t = j["aweme_list"].filter((v) => { if (v["aweme_id"] == id) return true }) break; case "douyin": t = j['item_list'].filter((v) => { if (v["aweme_id"] == id) return true }) break; } if (t.length > 0) { return t[0] } else return false } export default async function(obj) { try { if (!obj.postId) { let html = await got.get(`${config[obj.host]["short"]}${obj.id}`, { followRedirect: false, headers: { "user-agent": userAgent } }); html = html.body; if (html.slice(0, 17) === ' { if (i.includes(".jpeg?")) return true; }) imageLinks.push({url: selector[0]}) } return { picker: imageLinks, urls: audio, audioFilename: audioFilename, isAudioOnly: true, isMp3: isMp3, } } if (audio) return { urls: audio, audioFilename: audioFilename, isAudioOnly: true, isMp3: isMp3, } } catch (e) { return { error: loc(obj.lang, 'ErrorBadFetch') }; } }