|
1 | | -import { tiktokdl } from '@bochilteam/scraper' |
2 | | -import fg from 'api-dylux' |
| 1 | +import { tiktokdl } from '@bochilteam/scraper'; |
| 2 | +import fg from 'api-dylux'; |
3 | 3 |
|
4 | 4 | let handler = async (m, { conn, text, args, usedPrefix, command }) => { |
5 | 5 | if (!args[0] && m.quoted && m.quoted.text) { |
6 | | - args[0] = m.quoted.text |
| 6 | + args[0] = m.quoted.text; |
7 | 7 | } |
8 | | - if (!args[0] && !m.quoted) throw `Give the link of the video Tiktok or quote a tiktok link` |
9 | | - if (!args[0].match(/tiktok/gi)) throw `Verify that the link is from TikTok` |
| 8 | + if (!args[0] && !m.quoted) throw `Give the link of the video Tiktok or quote a TikTok link`; |
| 9 | + if (!args[0].match(/tiktok/gi)) throw `Verify that the link is from TikTok`; |
10 | 10 |
|
11 | | - let txt = 'Here your Requested video' |
| 11 | + let txt = 'Here your requested video'; |
12 | 12 |
|
13 | 13 | try { |
14 | | - const { |
15 | | - author: { nickname }, |
16 | | - video, |
17 | | - description, |
18 | | - } = await tiktokdl(args[0]) |
19 | | - const url = |
20 | | - video.no_watermark2 || |
21 | | - video.no_watermark || |
22 | | - 'https://tikcdn.net' + video.no_watermark_raw || |
23 | | - video.no_watermark_hd |
| 14 | + console.log('Fetching TikTok video...'); // Debugging log |
| 15 | + const { author: { nickname }, video, description } = await tiktokdl(args[0]); |
| 16 | + const url = video.no_watermark2 || video.no_watermark || 'https://tikcdn.net' + video.no_watermark_raw || video.no_watermark_hd; |
24 | 17 |
|
25 | | - if (!url) throw global.error |
| 18 | + if (!url) throw global.error; |
26 | 19 |
|
27 | | - conn.sendFile(m.chat, url, 'tiktok.mp4', '', m) |
| 20 | + conn.sendFile(m.chat, url, 'tiktok.mp4', '', m); |
28 | 21 | } catch (err) { |
| 22 | + console.error('Primary download failed:', err); // Debugging log |
29 | 23 | try { |
30 | | - let p = await fg.tiktok(args[0]) |
31 | | - conn.sendFile(m.chat, p.play, 'tiktok.mp4', txt, m) |
32 | | - } catch { |
33 | | - m.reply('*An unexpected error occurred*') |
| 24 | + console.log('Attempting fallback download...'); // Debugging log |
| 25 | + let p = await fg.tiktok(args[0]); |
| 26 | + conn.sendFile(m.chat, p.play, 'tiktok.mp4', txt, m); |
| 27 | + } catch (err) { |
| 28 | + console.error('Fallback download failed:', err); // Debugging log |
| 29 | + m.reply('*An unexpected error occurred*'); |
34 | 30 | } |
35 | 31 | } |
36 | 32 | } |
37 | 33 |
|
38 | | -handler.help = ['tiktok'].map(v => v + ' <url>') |
39 | | -handler.tags = ['downloader'] |
40 | | -handler.command = /^t(t|iktok(d(own(load(er)?)?|l))?|td(own(load(er)?)?|l))$/i |
| 34 | +handler.help = ['tiktok'].map(v => v + ' <url>'); |
| 35 | +handler.tags = ['downloader']; |
| 36 | +handler.command = /^t(t|iktok(d(own(load(er)?)?|l))?|td(own(load(er)?)?|l))$/i; |
41 | 37 |
|
42 | | -export default handler |
| 38 | +export default handler; |
0 commit comments