Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nasrullahmalik authored Feb 16, 2024
1 parent fe875fd commit 40430c3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions plugins/dl-instagram.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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;

0 comments on commit 40430c3

Please sign in to comment.