tiktok: update domain & force device info
This commit is contained in:
parent
8e1606f50c
commit
a1c5a4da72
1 changed files with 12 additions and 7 deletions
|
@ -4,8 +4,8 @@ const userAgent = genericUserAgent.split(' Chrome/1')[0],
|
||||||
config = {
|
config = {
|
||||||
tiktok: {
|
tiktok: {
|
||||||
short: "https://vt.tiktok.com/",
|
short: "https://vt.tiktok.com/",
|
||||||
api: "https://api22-normal-c-useast2a.tiktokv.com/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®ion=US&carrier_region=US",
|
api: "https://api22-normal-c-alisg.tiktokv.com/aweme/v1/feed/?aweme_id={postId}®ion=US&carrier_region=US",
|
||||||
userAgent: "TikTok 26.2.0 rv:262018 (iPhone; iOS 14.4.2; en_US) Cronet"
|
userAgent: "TikTok/338014 CFNetwork/1410.1 Darwin/22.6.0"
|
||||||
},
|
},
|
||||||
douyin: {
|
douyin: {
|
||||||
short: "https://v.douyin.com/",
|
short: "https://v.douyin.com/",
|
||||||
|
@ -32,6 +32,8 @@ function selector(j, h, id) {
|
||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let postId = obj.postId ? obj.postId : false;
|
let postId = obj.postId ? obj.postId : false;
|
||||||
|
|
||||||
|
if (!process.env.TIKTOK_DEVICE_INFO) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
if (!postId) {
|
if (!postId) {
|
||||||
let html = await fetch(`${config[obj.host].short}${obj.id}`, {
|
let html = await fetch(`${config[obj.host].short}${obj.id}`, {
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
|
@ -48,12 +50,15 @@ export default async function(obj) {
|
||||||
}
|
}
|
||||||
if (!postId) return { error: 'ErrorCantGetID' };
|
if (!postId) return { error: 'ErrorCantGetID' };
|
||||||
|
|
||||||
|
let deviceInfo = JSON.parse(process.env.TIKTOK_DEVICE_INFO);
|
||||||
|
deviceInfo = new URLSearchParams(deviceInfo).toString();
|
||||||
|
|
||||||
let detail;
|
let detail;
|
||||||
detail = await fetch(config[obj.host].api.replace("{postId}", postId), {
|
detail = await fetch(`${config[obj.host].api.replace("{postId}", postId)}&${deviceInfo}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent": config[obj.host].userAgent
|
"user-agent": config[obj.host].userAgent
|
||||||
}
|
}
|
||||||
}).then((r) => { return r.json() }).catch(() => { return false });
|
}).then((r) => { return r.json() }).catch(() => { return false });
|
||||||
|
|
||||||
detail = selector(detail, obj.host, postId);
|
detail = selector(detail, obj.host, postId);
|
||||||
if (!detail) return { error: 'ErrorCouldntFetch' };
|
if (!detail) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
Loading…
Reference in a new issue