Created
December 28, 2023 07:55
-
-
Save S-U-P-E-R-I-O-R/6cda2771da8d033f3b6396aa7379ff34 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 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