ShahriarAbidbd/SmartifyXBotPublic · Bot Template
Do Tasks Smartly with SmartifyX 😎
Utilitydownloaderyoutubeinstagramfacebookspoilercontent-protection
25 commands2 envUpdated 1d agoCreated Jul 28, 2026
commands/Downloader/_ig.js
javascript · 138 lines
1/**#command2name: /ig3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12function cleanIGTitle(rawTitle) {13 if (!rawTitle) return {};14 15 let parts = rawTitle.split("|").map(p => p.trim());16 let stats = parts[0] || "";17 let title = parts[1] || rawTitle;18 19 return {20 title21 };22}23 24async function getIGVideo(link) {25 26 let a = await Bot.sendMessage("⏳ Downloading")27 let mid = a.result.message_id28 29 await Api.editMessageText({30 chat_id: chat.id,31 message_id: mid,32 text: "⏳ Downloading."33 })34 35 // validate IG link36 if (37 link.indexOf("instagram.com") === -1 &&38 link.indexOf("ig.watch") === -1 &&39 link.indexOf("ig.com") === -140 ) {41 Api.editMessageText({42 chat_id: chat.id,43 message_id: mid,44 text: "❗ Only Instagram URLs are supported."45 })46 return47 }48 49 let headers = {50 "Accept": "application/json",51 "Content-Type": "application/json",52 "Origin": "https://ytdownload.in",53 "Referer": "https://ytdownload.in/",54 "User-Agent": "Mozilla/5.0 (Android)"55 }56 57 // warmup58 await HTTP.get({59 url: "https://ytdownload.in",60 headers: headers61 })62 63 let res = await HTTP.post({64 url: Bot.get("downloader_api"),65 headers: headers,66 body: {67 url: link,68 format: "mp4",69 quality: "1080p"70 }71 })72 73 await Api.editMessageText({74 chat_id: chat.id,75 message_id: mid,76 text: "⏳ Downloading.."77 })78 79 if (!res.ok || !res.data?.responseFinal) {80 Api.editMessageText({81 chat_id: chat.id,82 message_id: mid,83 text: "❌ Video not found or private."84 })85 return86 }87 88 await Api.editMessageText({89 chat_id: chat.id,90 message_id: mid,91 text: "⏳ Downloading..."92 })93 94 let r = res.data.responseFinal95 96 // HD video priority97 let video =98 r.videoUrl ||99 r.formats?.find(v => v.qualityLabel?.includes("HD"))?.url ||100 r.formats?.[0]?.url101 102 if (!video) {103 Api.editMessageText({104 chat_id: chat.id,105 message_id: mid,106 text: "❌ HD video not available."107 })108 return109 }110 111 let info = cleanIGTitle(r.title)112 113 let caption =114 "<b>" + (info.title || "Instagram Video") + "</b>"115 116 let name = user.first_name + (user.last_name ? " " + user.last_name : "")117 118 await Api.editMessageMedia({119 chat_id: chat.id,120 message_id: mid,121 media: {122 type: "video",123 media: video,124 caption: caption +125 `\n\n<blockquote><b>Downloaded by:</b> <a href="tg://user?id=${user.id}">${name}</a></blockquote>`,126 parse_mode: "HTML"127 }128 })129}130 131/* command handler */132if (request.reply_to_message && request.reply_to_message.text) {133 getIGVideo(request.reply_to_message.text)134} else if (params) {135 getIGVideo(params)136} else {137 msg.reply("❗ Please provide a Instagram video link.")138}