Skip to content

Commit ab6674d

Browse files
> V3
1 parent d5e0207 commit ab6674d

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

plugins/dl-tiktok.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
1-
import { tiktokdl } from '@bochilteam/scraper'
2-
import fg from 'api-dylux'
1+
import { tiktokdl } from '@bochilteam/scraper';
2+
import fg from 'api-dylux';
33

44
let handler = async (m, { conn, text, args, usedPrefix, command }) => {
55
if (!args[0] && m.quoted && m.quoted.text) {
6-
args[0] = m.quoted.text
6+
args[0] = m.quoted.text;
77
}
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`;
1010

11-
let txt = 'Here your Requested video'
11+
let txt = 'Here your requested video';
1212

1313
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;
2417

25-
if (!url) throw global.error
18+
if (!url) throw global.error;
2619

27-
conn.sendFile(m.chat, url, 'tiktok.mp4', '', m)
20+
conn.sendFile(m.chat, url, 'tiktok.mp4', '', m);
2821
} catch (err) {
22+
console.error('Primary download failed:', err); // Debugging log
2923
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*');
3430
}
3531
}
3632
}
3733

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;
4137

42-
export default handler
38+
export default handler;

0 commit comments

Comments
 (0)