tiktok is back!
- added support for tiktok (images won't work, they're only accessible through the app) - hopefully main input bar is now not rounded on ios, i fucking hate apple - if service is not supported, a correlating error will appear, not generic one - removed duplicates from config that are present in package json already - tiny bit of clean up
This commit is contained in:
30
src/modules/services/tiktok.js
Normal file
30
src/modules/services/tiktok.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import got from "got";
|
||||
import loc from "../../localization/manager.js";
|
||||
import { genericUserAgent} 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 } });
|
||||
html.on('error', (err) => {
|
||||
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
|
||||
});
|
||||
html = html.body
|
||||
obj.postId = html.split('video/')[1].split('?')[0]
|
||||
}
|
||||
let url = `https://tiktok.com/@video/video/${obj.postId}`
|
||||
let html = await got.get(url, { headers: { "user-agent": genericUserAgent } });
|
||||
html.on('error', (err) => {
|
||||
return { error: loc(obj.lang, 'ErrorCantConnectToServiceAPI', 'tiktok') };
|
||||
});
|
||||
html = html.body;
|
||||
if (html.includes(',"preloadList":[{"url":"')) {
|
||||
return { urls: unicodeDecode(html.split(',"preloadList":[{"url":"')[1].split('","id":"')[0].trim()), filename: `tiktok_${obj.postId}.mp4` };
|
||||
} else {
|
||||
return { error: loc(obj.lang, 'ErrorEmptyDownload') };
|
||||
}
|
||||
} catch (e) {
|
||||
return { error: loc(obj.lang, 'ErrorBadFetch') };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user