/***
@ Base: https://igram.world/
@ Author: Shannz
@ Note: Instagram reels and image slide downloader
***/
import axios from 'axios';
import crypto from 'crypto';
import qs from 'qs';
const CONFIG = {
API_URL: 'https://api-wh.igram.world/api/convert',
SECRETS: {
SALT: '241c28282e4ce419ce73ca61555a5a0c7faf887c5ccf9305c55484f701ba883a',
_TS_FIXED: 1766415734394,
},
HEADERS: {
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36',
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
'Origin': 'https://igram.world',
'Referer': 'https://igram.world/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site'
}
};
const utils = {
generateSignature: (url, ts) => {
const signatureBase = `${url}${ts}${CONFIG.SECRETS.SALT}`;
return crypto.createHash('sha256').update(signatureBase).digest('hex');
}
};
export const igram = {
download: async (url) => {
try {
const ts = Date.now();
const _s = utils.generateSignature(url, ts);
const payload = {
'sf_url': url,
'ts': ts,
'_ts': CONFIG.SECRETS._TS_FIXED,
'_tsc': 0,
'_s': _s
};
const response = await axios.post(CONFIG.API_URL, qs.stringify(payload), {
headers: CONFIG.HEADERS
});
if (!response.data) return null;
return response.data;
} catch (error) {
console.error(`error download: ${error.message}`);
return null;
}
}
};