ShahriarAbidbd/SmartifyXBotPublic · Bot Template
Do Tasks Smartly with SmartifyX 😎
Utilitydownloaderyoutubeinstagramfacebookspoilercontent-protection
25 commands2 envUpdated 1d agoCreated Jul 28, 2026
commands/Downloader/_ytt.js
javascript · 127 lines
1/**#command2name: /ytt3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12function cleanYTTitle(rawTitle) {13 if (!rawTitle) return {};14 15 let parts = rawTitle.split("|").map(p => p.trim());16 let title = parts[1] || rawTitle;17 18 return { title };19}20 21async function getYTVideo(link) {22 23 let a = await Bot.sendMessage("⏳ Downloading")24 let mid = a.result.message_id25 26 await Api.editMessageText({27 chat_id: chat.id,28 message_id: mid,29 text: "⏳ Downloading."30 })31 32 // validate YT link33 if (34 link.indexOf("youtube.com") === -1 &&35 link.indexOf("yt.watch") === -1 &&36 link.indexOf("youtu.be") === -137 ) {38 Api.editMessageText({39 chat_id: chat.id,40 message_id: mid,41 text: "❗ Only Youtube URLs are supported."42 })43 return44 }45 46 let headers = {47 "Accept": "application/json",48 "Content-Type": "application/json",49 "Origin": "https://ytdownload.in",50 "Referer": "https://ytdownload.in/",51 "User-Agent": "Mozilla/5.0 (Android)"52 }53 54 // warmup55 await HTTP.get({56 url: "https://ytdownload.in",57 headers: headers58 })59 60 let res = await HTTP.post({61 url: Bot.get("downloader_api"),62 headers: headers,63 body: { url: link, format: "mp4", quality: "1080p" }64 })65 66 await Api.editMessageText({67 chat_id: chat.id,68 message_id: mid,69 text: "⏳ Downloading.."70 })71 72 if (!res.ok || !res.data?.responseFinal) {73 Api.editMessageText({74 chat_id: chat.id,75 message_id: mid,76 text: "❌ Thumbnail not found."77 })78 return79 }80 81 await Api.editMessageText({82 chat_id: chat.id,83 message_id: mid,84 text: "⏳ Downloading..."85 })86 87 let r = res.data.responseFinal88 let thumb = r.thumbnails89 90 if (!thumb) {91 Api.editMessageText({92 chat_id: chat.id,93 message_id: mid,94 text: "❌ Thumbnail not available."95 })96 return97 }98 99 let info = cleanYTTitle(r.title)100 101 let caption =102 "<b>" + (info.title || "Youtube Video") + "</b>"103 104 let name = user.first_name + (user.last_name ? " " + user.last_name : "")105 106 await Api.editMessageMedia({107 chat_id: chat.id,108 message_id: mid,109 media: {110 type: "photo",111 media: thumb,112 caption:113 caption +114 `\n\n<blockquote><b>Downloaded by:</b> <a href="tg://user?id=${user.id}">${name}</a></blockquote>`,115 parse_mode: "HTML"116 }117 })118}119 120/* command handler */121if (request.reply_to_message && request.reply_to_message.text) {122 getYTVideo(request.reply_to_message.text)123} else if (params) {124 getYTVideo(params)125} else {126 msg.reply("❗ Please provide a Youtube video link.")127}