descargas-tiktok.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import axios from 'axios';
  2. const handler = async (m, { conn, text, args, usedPrefix, command }) => {
  3. if (!text) throw `⚠️ *¿Qué TikTok buscar? 🤔*\n\n⚡ *Ingrese un enlace de TikTok para descargar el video*\n*Ej:* ${usedPrefix + command} https://vm.tiktok.com/xxxx`;
  4. if (!/(?:https:?\/{2})?(?:w{3}|vm|vt|t)?\.?tiktok.com\/([^\s&]+)/gi.test(text)) throw `❌ Error`;
  5. const { key } = await conn.sendMessage(m.chat, { text: `*🐣 Tranquilo*\n▰▰▰▱▱▱▱▱▱\n𝙔𝙖 𝙚𝙨𝙩𝙤𝙮 𝙙𝙚𝙨𝙘𝙖𝙧𝙜𝙖𝙙𝙤...` }, { quoted: m });
  6. await delay(1000);
  7. const apiUrl = `https://api.siputzx.my.id/api/tiktok?url=${encodeURIComponent(text)}`;
  8. try {
  9. const response = await axios.get(apiUrl);
  10. if (response.data.status && response.data.data.success) {
  11. const videoUrls = response.data.data.urls;
  12. if (videoUrls.length > 0) {
  13. const videoUrl = videoUrls[0]; // Tomar el primer enlace
  14. await conn.sendMessage(m.chat, { video: { url: videoUrl }, caption: `*🔰 Aquí está tu video de TikTok*` }, { quoted: m });
  15. await conn.sendMessage(m.chat, { text: `✅ 𝘾𝙤𝙢𝙥𝙡𝙚𝙩𝙖𝙙𝙤\n▰▰▰▰▰▰▰▰▰\n𝘼𝙦𝙪𝙞 𝙚𝙨𝙩𝙖 𝙩𝙪 𝙫𝙞𝙙𝙚𝙤 💫`, edit: key });
  16. } else {
  17. throw new Error("No se encontraron enlaces de video.");
  18. }
  19. } else {
  20. throw new Error("Error al obtener el video de TikTok.");
  21. }
  22. } catch (error) {
  23. console.error(error);
  24. await conn.sendMessage(m.chat, { text: `⚠️ Ocurrió un error al intentar descargar el video. Intenta nuevamente.` }, { quoted: m });
  25. m.react(`❌`);
  26. }
  27. };
  28. const delay = time => new Promise(res => setTimeout(res, time));
  29. handler.help = ['tiktok'];
  30. handler.tags = ['downloader'];
  31. handler.command = /^(tt|tiktok)(dl|nowm)?$/i;
  32. handler.limit = 1;
  33. export default handler;