|
const axios = require("axios"); |
|
const { cmd } = require("../command"); |
|
|
|
cmd({ |
|
pattern: "tiktok", |
|
alias: ["ttdl", "tiktokdl","tt"], |
|
react: 'β°', |
|
desc: "Download TikTok videos.", |
|
category: "download", |
|
use: ".tiktok <TikTok video URL>", |
|
filename: __filename |
|
}, async (conn, mek, m, { from, reply, args }) => { |
|
try { |
|
|
|
const tiktokUrl = args[0]; |
|
if (!tiktokUrl || !tiktokUrl.includes("tiktok.com")) { |
|
return reply('Please provide a valid TikTok video URL. Example: `.tiktok https://tiktok.com/...`'); |
|
} |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'β³', key: m.key } }); |
|
|
|
|
|
const apiUrl = `https://api.nexoracle.com/downloader/tiktok-nowm?apikey=free_key@maher_apis&url=${encodeURIComponent(tiktokUrl)}`; |
|
|
|
|
|
const response = await axios.get(apiUrl); |
|
|
|
|
|
if (!response.data || response.data.status !== 200 || !response.data.result) { |
|
return reply('β Unable to fetch the video. Please check the URL and try again.'); |
|
} |
|
|
|
|
|
const { title, thumbnail, author, metrics, url } = response.data.result; |
|
|
|
|
|
|
|
|
|
|
|
const videoResponse = await axios.get(url, { responseType: 'arraybuffer' }); |
|
if (!videoResponse.data) { |
|
return reply('β Failed to download the video. Please try again later.'); |
|
} |
|
|
|
|
|
const videoBuffer = Buffer.from(videoResponse.data, 'binary'); |
|
|
|
|
|
await conn.sendMessage(from, { |
|
video: videoBuffer, |
|
caption: `*π«πΙΔ«Δ« πΖ ππππππππππ*\n\n` + |
|
`π *α΄Ιͺα΄Κα΄*: ${title || "No title"}\n` + |
|
`π€ *α΄α΄α΄Κα΄Κ*: ${author.nickname}\n` + |
|
`β₯οΈ *ΚΙͺα΄α΄s*: ${metrics.digg_count}\n` + |
|
`π¬ *α΄α΄α΄α΄α΄Ι΄α΄s*: ${metrics.comment_count}\n` + |
|
`β»οΈ *sΚα΄Κα΄s*: ${metrics.share_count}\n` + |
|
`π₯ *α΄
α΄α΄‘Ι΄Κα΄α΄α΄
s*: ${metrics.download_count}\n\n` + |
|
`> *Β© α΄α΄α΄‘α΄Κα΄α΄
ΚΚ α΄ΚΙͺ*`, |
|
contextInfo: { |
|
mentionedJid: [m.sender], |
|
forwardingScore: 999, |
|
isForwarded: true, |
|
forwardedNewsletterMessageInfo: { |
|
newsletterJid: '120363318387454868@newsletter', |
|
newsletterName: 'γ πΙΔ«Δ« πΖ πΚΜππΰΉαΦΙΌΚ γ', |
|
serverMessageId: 143 |
|
} |
|
} |
|
}, { quoted: mek }); |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'β
', key: m.key } }); |
|
} catch (error) { |
|
console.error('Error downloading TikTok video:', error); |
|
reply('β Unable to download the video. Please try again later.'); |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'β', key: m.key } }); |
|
} |
|
}); |
|
|