Mendownload Media Instagram
/**
* Judul : Instagram Downloader
* Base URL : https://savefromins.com
* Author : Cx99 - t.me/exploit99
* Deskripsi : Mendownload media Instagram Support (Story/Video/Photo Carouse)
* Channel : https://whatsapp.com/channel/0029VbCSF8sA89MopCVOYW06
*/
'use strict'
const axios = require('axios')
const SITE = 'https://savefromins.com'
const API = 'https://api.savefromins.com/api/contentsite_api/media/parse'
const UA = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36'
const get = url => axios.get(url, {
headers: {
accept: '*/*',
'user-agent': UA
},
timeout: 30000
})
const extractScripts = html => {
const scripts = new Set()
const regex = /(?:src=["'])(https?:\/\/[^"']+\.js[^"']*)/gi
let match
while ((match = regex.exec(html))) scripts.add(match[1])
return [...scripts]
}
const extractAuth = text => {
const patterns = [
/["']auth["']\s*[:=]\s*["']([^"']{8,})["']/gi,
/\bauth\s*[:=]\s*["']([^"']{8,})["']/gi,
/["']auth["']\s*,\s*["']([^"']{8,})["']/gi
]
for (const regex of patterns) {
let match
while ((match = regex.exec(text))) {
const value = match[1]
if (value && !value.includes('${') && !value.includes('auth') && value.length >= 8) {
return value
}
}
}
return null
}
const findDomain = text => {
const match = text.match(/(?:https?:\/\/)?(api-ak\.savefromins\.com)/i)
return match ? match[1] : 'api-ak.savefromins.com'
}
async function getConfig() {
const home = await get(`${SITE}/`)
const scripts = extractScripts(home.data)
let auth = extractAuth(home.data)
let domain = findDomain(home.data)
for (const script of scripts) {
if (auth) break
try {
const res = await get(script)
const found = extractAuth(res.data)
if (found) {
auth = found
domain = findDomain(res.data)
}
} catch {}
}
if (!auth) throw new Error('Auth tidak ditemukan dari frontend SaveFromIns')
return { auth, domain }
}
async function igdl(link) {
if (!link) {
return {
status: false,
message: 'URL Instagram tidak boleh kosong!'
}
}
if (!/^https?:\/\/(www\.)?instagram\.com\//i.test(link.trim())) {
return {
status: false,
message: 'URL Instagram tidak valid!'
}
}
try {
const { auth, domain } = await getConfig()
const res = await axios.post(
API,
new URLSearchParams({
auth,
domain,
origin: 'source',
link: link.trim()
}).toString(),
{
headers: {
accept: '*/*',
'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
'content-type': 'application/x-www-form-urlencoded',
origin: SITE,
referer: `${SITE}/`,
'user-agent': UA
},
timeout: 30000
}
)
return res.data
} catch (e) {
return e.response?.data ?? {
status: false,
message: e.message
}
}
}
module.exports = { igdl }
(async () => {
const { igdl } = require('./igdl')
const result = await igdl('https://www.instagram.com/reel/xxxxxxxx/')
console.log(JSON.stringify(result, null, 2))
})()