Created
January 27, 2026 12:45
-
-
Save ayashiiiyo/da4460251b080afa31d3deeaa33a2d76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import * as cheerio from "cheerio" | |
| let handler = async (m, { conn, args, command }) => { | |
| try { | |
| if (!args[0]) return m.reply(`*Example:* .${command} https://vt.tiktok.com/ZS5G3wv8h/`) | |
| m.reply("Wait") | |
| const body = new URLSearchParams({ | |
| q: args[0], | |
| cursor: "0", | |
| page: "0", | |
| lang: "id" | |
| }).toString() | |
| const res = await fetch("https://savetik.io/api/ajaxSearch", { | |
| method: "POST", | |
| headers: { | |
| "content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
| "x-requested-with": "XMLHttpRequest", | |
| "user-agent": "Mozilla/5.0", | |
| "origin": "https://savetik.io", | |
| "referer": "https://savetik.io/id/download-tiktok-photos", | |
| "accept": "*/*" | |
| }, | |
| body | |
| }) | |
| const json = await res.json() | |
| const html = typeof json.data === "string" ? json.data : "" | |
| if (!html) return m.reply("Gagal mengambil data") | |
| const $ = cheerio.load(html) | |
| const mp4 = | |
| $('a:contains("Unduh MP4 [1]")').attr("href") || | |
| $('a:contains("Unduh MP4 [2]")').attr("href") || | |
| $('a:contains("Unduh MP4 HD")').attr("href") || | |
| null | |
| const mp3 = $('a:contains("Unduh MP3")').attr("href") || null | |
| const images = [] | |
| $(".photo-list ul.download-box li").each((_, el) => { | |
| const img = $(el).find("a[title='Unduh Gambar']").attr("href") | |
| if (img) images.push(img) | |
| }) | |
| if (!mp4 && images.length > 0) { | |
| for (let img of images) { | |
| await conn.sendMessage(m.chat, { image: { url: img } }, { quoted: m }) | |
| } | |
| if (mp3) await conn.sendMessage(m.chat, { audio: { url: mp3 }, mimetype: "audio/mpeg" }, { quoted: m }) | |
| } else if (mp4) { | |
| await conn.sendMessage(m.chat, { video: { url: mp4 } }, { quoted: m }) | |
| if (mp3) await conn.sendMessage(m.chat, { audio: { url: mp3 }, mimetype: "audio/mpeg" }, { quoted: m }) | |
| } | |
| } catch (e) { | |
| m.reply(String(e.message)) | |
| } | |
| } | |
| handler.help = ["tt", "tiktok", "ttdl", "tiktokdl"] | |
| handler.tags = ["downloader"] | |
| handler.command = ["tt", "tiktok", "ttdl", "tiktokdl"] | |
| export default handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment