notmebotz-tools
Version:
Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT
61 lines (55 loc) • 1.93 kB
JavaScript
const axios = require('axios');
async function tiktokStalk(username) {
try {
const profileResponse = await axios.post('https://tokviewer.net/api/check-profile', {
username
}, {
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36',
'Referer': 'https://tokviewer.net/'
}
});
const videoResponse = await axios.post('https://tokviewer.net/api/video', {
username,
offset: Date.now(),
limit: 10
}, {
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
}
});
if (profileResponse.data.status !== 200 || videoResponse.data.status !== 200) {
throw new Error('Failed to fetch TikTok data');
}
const processedVideos = videoResponse.data.data.map(video => {
return {
id: video.id || video.aweme_id,
desc: video.desc || '',
createTime: video.create_time,
url: `https://www.tiktok.com/@${username}/video/${video.id || video.aweme_id}`,
cover: video.cover?.url_list?.[0] || video.video?.cover?.url_list?.[0] || '',
duration: video.video?.duration || video.duration || 0,
stats: {
playCount: video.statistics?.play_count || 0,
diggCount: video.statistics?.digg_count || 0,
commentCount: video.statistics?.comment_count || 0,
shareCount: video.statistics?.share_count || 0
}
};
});
return {
author: "Herzs",
status: 200,
data: {
profile: profileResponse.data.data,
videos: processedVideos
}
};
} catch (error) {
throw new Error(`TikTok stalk failed: ${error.message}, report to owner`);
}
}
module.exports = { tiktokStalk}