downloader-ttmp3
#hba5wu5javascript · 43 baris · 17 dilihat
import axios from 'axios'
let handler = async(m, { conn, text, usedPrefix, command }) => {
const makeUI = (t, c) => `✨ *${t}*\n\n` + c.split('\n').map(v => `🌸 ${v}`).join('\n') + `\n\n> © LI-SHIYA MD`
if(!text) return m.reply(makeUI('INFO', `Masukkan link TikTok!\nContoh: *${usedPrefix + command} https://vt.tiktok.com/ZS4y5vc3F/*`))
let urlMatch = text.match(/https?:\/\/(?:www\.|vt\.|vm\.)?tiktok\.com\/[^\s]+/i)
if(!urlMatch) return m.reply(makeUI('INFO', `Link TikTok tidak valid.`))
await m.react('⏳')
try {
let { data } = await axios.get(`https://lynxapis.my.id/api/downloader/tiktok-v4?url=${encodeURIComponent(urlMatch[0])}`, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
}, timeout: 60000
})
if(!data || !data.status || !data.data || !data.data.audio_url) throw 'Gagal dapetin audio dari link ini'
let res = data.data
await conn.sendMessage(m.chat, {
audio: { url: res.audio_url },
mimetype: 'audio/mpeg',
fileName: `tiktok_audio.mp3`
}, { quoted: m })
await m.react('✅')
}catch(e) {
console.log(e)
await m.react('❌')
let err = e.response?.data?.message || e.message || e
m.reply(makeUI('ERROR', `Gagal mengunduh audio TikTok.\n💬 *Detail:* ${err}`))
}
}
handler.help = ['ttmp3 <link>']
handler.tags = ['downloader']
handler.command = /^(ttmp3)$/i
handler.limit = true
export default handler