mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update tiktok/tiktok.js
This commit is contained in:
parent
d221886faa
commit
8352cf096f
1 changed files with 21 additions and 7 deletions
|
|
@ -4,14 +4,29 @@ async function searchResults(keyword) {
|
|||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
};
|
||||
const body = JSON.stringify({
|
||||
keywords: keyword,
|
||||
count: 20,
|
||||
cursor: 0
|
||||
});
|
||||
|
||||
try {
|
||||
if (keyword.includes('tiktok.com')) {
|
||||
const detailResponse = await fetchv2(`https://tikwm.com/api/?url=${encodeURIComponent(keyword)}`);
|
||||
const detailData = await detailResponse.json();
|
||||
|
||||
if (detailData.code === 0) {
|
||||
results.push({
|
||||
title: detailData.data.title.trim(),
|
||||
image: detailData.data.cover.trim(),
|
||||
href: detailData.data.play.trim()
|
||||
});
|
||||
}
|
||||
return JSON.stringify(results);
|
||||
}
|
||||
|
||||
const body = JSON.stringify({
|
||||
keywords: keyword,
|
||||
count: 20,
|
||||
cursor: 0
|
||||
});
|
||||
|
||||
const response = await fetchv2('https://tikwm.com/api/feed/search', headers, "POST", body);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
for (const video of data.data.videos) {
|
||||
|
|
@ -28,7 +43,6 @@ async function searchResults(keyword) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return JSON.stringify(results);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue