-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bb7a1f
commit 696330c
Showing
1 changed file
with
32 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,32 @@ | ||
import { TiktokDL } form '@tobyg74/tiktok-api-dl' | ||
|
||
async function downloadTikTokVideo(url) { | ||
try { | ||
const result = await TiktokDL(url, { | ||
version: "v1" // version: "v1" | "v2" | "v3" | ||
}); | ||
|
||
console.log(result); | ||
return result; | ||
} catch (error) { | ||
console.error("Error:", error.message); | ||
|
||
throw error; | ||
} | ||
} | ||
|
||
async function handler.command(command, message) { | ||
const args = message.body.split(' '); | ||
|
||
if (args.length !== 2 || args[0] !== '.tiktok') { | ||
console.log('Format perintah tidak valid'); | ||
return; | ||
} | ||
|
||
const tiktok_url = args[1]; | ||
|
||
try { | ||
const result = await downloadTikTokVideo(tiktok_url); | ||
|
||
const replyMessage = `Video TikTok berhasil diunduh! Hasil: ${result}`; | ||
|
||
console.log(replyMessage); | ||
} catch (error) { | ||
|
||
const errorMessage = `Terjadi kesalahan saat mengunduh video TikTok: ${error.message}`; | ||
|
||
console.error(errorMessage); | ||
} | ||
} | ||
|
||
// Contoh penggunaan handler command | ||
const command = '.tiktok https://vt.tiktok.com/ZS84BnrU9'; | ||
const message = { body: command }; | ||
|
||
handler.help = ['tiktok <url>','tiktokdl <url>', 'tiktokslide <url>'] | ||
handler.tags = ['download'] | ||
handler.command = /^(tiktok(dl)?(slide|image)?)$/i | ||
|
||
|
||
handler.premium = false | ||
handler.limit = true | ||
|
||
export default handler | ||
import { niceBytes } from '../../lib/func.js'; | ||
|
||
let handler = async (m, { conn, text, usedPrefix, command }) => { | ||
if (!text) throw `Usage : *${usedPrefix + command} <url>'`; | ||
|
||
try { | ||
let anu = await (await fetch(`https://oni-chan.my.id/api/download/tiktok?url=${text}`)).json(); | ||
if (!anu.status) throw Error(); | ||
caption = anu.caption; | ||
anu = anu.server1; | ||
let data = anu.url; | ||
let url = data; | ||
if (data.fileSize > 400000) return m.reply(`Filesize: ${data.fileSizeH}\nTidak dapat mengirim, maksimal file 400 MB`); | ||
|
||
let txt = `*${caption}*\n\n` + | ||
`⭔ Resolution : ${anu.quality}\n` + | ||
`⭔ Size : ${data.fileSizeH}`; | ||
|
||
await conn.sendFile(m.chat, url, `${anu.caption}.mp4`, txt); | ||
} catch (e) { | ||
console.log(e); | ||
throw 'invalid url / server down.'; | ||
} | ||
}; | ||
|
||
handler.help = ['tiktok <url>', 'tiktokdl <url>', 'tiktokslide <url>']; | ||
handler.tags = ['download']; | ||
handler.command = /^(tiktok(dl)?(slide|image)?)$/i; | ||
handler.premium = false; | ||
handler.limit = true; | ||
|
||
export default handler; |