Skip to content

Instantly share code, notes, and snippets.

@S-U-P-E-R-I-O-R
Created December 28, 2023 07:55
Show Gist options
  • Select an option

  • Save S-U-P-E-R-I-O-R/6cda2771da8d033f3b6396aa7379ff34 to your computer and use it in GitHub Desktop.

Select an option

Save S-U-P-E-R-I-O-R/6cda2771da8d033f3b6396aa7379ff34 to your computer and use it in GitHub Desktop.
import fetch from 'node-fetch';
let handler = async (m, { conn, usedPrefix, args, command, text }) => {
if (!text) throw `You need to give the URL of Any Instagram video, post, reel, image`;
m.reply(wait);
let res;
try {
res = await fetch(`${gurubot}/igdlv1?url=${text}`);
} catch (error) {
throw `An error occurred: ${error.message}`;
}
let api_response = await res.json();
if (!api_response || !api_response.data) {
throw `No video or image found or Invalid response from API.`;
}
const mediaArray = api_response.data;
for (const mediaData of mediaArray) {
const mediaType = mediaData.type;
const mediaURL = mediaData.url_download;
let cap = `HERE IS THE ${mediaType.toUpperCase()} >,<`;
if (mediaType === 'video') {
conn.sendFile(m.chat, mediaURL, 'instagram.mp4', cap, m);
} else if (mediaType === 'image') {
conn.sendFile(m.chat, mediaURL, 'instagram.jpg', cap, m);
}
}
};
handler.help = ['instagram'];
handler.tags = ['downloader'];
handler.command = /^(instagram|igdl|ig|insta)$/i;
export default handler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment