projek3 / plugins /tiktok.js
devstok's picture
Upload folder using huggingface_hub
47ab1ce verified
let axios = require('axios');
let handler = async (m, { conn, text, usedPrefix, command }) => {
if (!text) throw `Masukan URL!\n\ncontoh:\n${usedPrefix + command} https://vm.tiktok.com/ZGJAmhSrp/`;
try {
if (!text.match(/tiktok/gi) && !text.match(/douyin/gi)) {
throw `URL Tidak Ditemukan!`;
}
m.reply(wait);
try {
const response = await axios.get(`https://btch.us.kg/download/v2/ttdl?url=${text}`);
const res = response.data;
if (!res.status) {
throw `Gagal mendapatkan data!`;
}
const result = res.result;
var { video, title, title_audio, audio, thumbnail } = result;
if (!video || video.length === 0) {
throw `Video tidak ditemukan!`;
}
let capt = `乂 *T I K T O K*\n\n`;
capt += `◦ *Title* : ${title}\n`;
capt += `◦ *Audio* : ${title_audio}\n`;
capt += `◦ *Thumbnail* : ${thumbnail}\n`;
capt += `\n`;
if (video.length > 1) {
for (let v of video) {
await conn.sendFile(m.chat, v, null, capt, m);
}
} else {
await conn.sendFile(m.chat, video[0], null, capt, m);
}
if (!audio || audio.length === 0) {
await conn.reply(m.chat, "_Audio tidak tersedia!_", m);
} else {
conn.sendMessage(m.chat, { audio: { url: audio[0] }, mimetype: 'audio/mpeg' }, { quoted: m });
}
return;
} catch (e) {
throw `Terjadi kesalahan saat mengambil data!`;
}
} catch (e) {
throw `Terjadi kesalahan: ${e.message}`;
}
};
handler.help = ['tiktok'];
handler.command = /^(tiktok|tt|tiktokdl|tiktoknowm)$/i;
handler.tags = ['downloader'];
handler.limit = true;
handler.group = false;
handler.premium = false;
handler.owner = false;
handler.admin = false;
handler.botAdmin = false;
handler.fail = null;
handler.private = false;
module.exports = handler;