Update index.js
Browse files
index.js
CHANGED
|
@@ -27,7 +27,44 @@ const post = async (url, form, headers = {}) => {
|
|
| 27 |
return response;
|
| 28 |
};
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
async function igdl(query) {
|
| 32 |
url_dl = [];
|
| 33 |
let headers = {
|
|
@@ -317,6 +354,11 @@ const app = express()
|
|
| 317 |
"title": "Pinterest Downloader",
|
| 318 |
"method": "GET",
|
| 319 |
"example": `${host}/pindl?url=`,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
}
|
| 321 |
]
|
| 322 |
})})
|
|
@@ -415,6 +457,21 @@ const app = express()
|
|
| 415 |
return res.json({ message: e.message });
|
| 416 |
}
|
| 417 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
.get('/ytdl', async (req, res) => {
|
| 419 |
try {
|
| 420 |
let { url } = req.query
|
|
|
|
| 27 |
return response;
|
| 28 |
};
|
| 29 |
|
| 30 |
+
|
| 31 |
+
// MEDIAFIRE DL
|
| 32 |
+
async function mediafire(url) {
|
| 33 |
+
return new Promise(async(resolve, reject) => {
|
| 34 |
+
var a, b;
|
| 35 |
+
if (!/https?:\/\/(www\.)?mediafire\.com/.test(url)) return resolve()
|
| 36 |
+
const data = await axios.get(url, {headers:headers}).catch(function (error) {})
|
| 37 |
+
if (!data) {
|
| 38 |
+
resolve()
|
| 39 |
+
} else {
|
| 40 |
+
const $ = cheerio.load(data.data);
|
| 41 |
+
const Url = ($('#downloadButton').attr('href') || '').trim();
|
| 42 |
+
const url2 = ($('#download_link > a.retry').attr('href') || '').trim();
|
| 43 |
+
const $intro = $('div.dl-info > div.intro');
|
| 44 |
+
const filename = $intro.find('div.filename').text().trim();
|
| 45 |
+
const filetype = $intro.find('div.filetype > span').eq(0).text().trim();
|
| 46 |
+
const ext = ((b = (a = /\(\.(.*?)\)/.exec($intro.find('div.filetype > span').eq(1).text())) === null || a === void 0 ? void 0 : a[1]) === null || b === void 0 ? void 0 : b.trim()) || 'bin';
|
| 47 |
+
const $li = $('div.dl-info > ul.details > li');
|
| 48 |
+
const aploud = $li.eq(1).find('span').text().trim();
|
| 49 |
+
const filesize = $li.eq(0).find('span').text().trim();
|
| 50 |
+
const filesizeB = (0, formatSize)(filesize);
|
| 51 |
+
const result = {
|
| 52 |
+
url: Url || url2,
|
| 53 |
+
url2,
|
| 54 |
+
filename,
|
| 55 |
+
filetype,
|
| 56 |
+
ext,
|
| 57 |
+
upload_date: aploud,
|
| 58 |
+
filesize,
|
| 59 |
+
filesizeB
|
| 60 |
+
};
|
| 61 |
+
resolve(result)
|
| 62 |
+
}
|
| 63 |
+
})
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
//SAVEIG
|
| 68 |
async function igdl(query) {
|
| 69 |
url_dl = [];
|
| 70 |
let headers = {
|
|
|
|
| 354 |
"title": "Pinterest Downloader",
|
| 355 |
"method": "GET",
|
| 356 |
"example": `${host}/pindl?url=`,
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"title": "Mediafire Downloader",
|
| 360 |
+
"method": "GET",
|
| 361 |
+
"example": `${host}/mediafire?url=`,
|
| 362 |
}
|
| 363 |
]
|
| 364 |
})})
|
|
|
|
| 457 |
return res.json({ message: e.message });
|
| 458 |
}
|
| 459 |
})
|
| 460 |
+
.get('/mediafire', async (req, res) => {
|
| 461 |
+
try {
|
| 462 |
+
let { url } = req.query
|
| 463 |
+
if (!/https?:\/\/(www\.)?mediafire\.com\/(file|download)/i.test(url)) {
|
| 464 |
+
return res.json({ message: 'Invalid URL' });
|
| 465 |
+
} else if (/https?:\/\/(www\.)?mediafire\.com\/file\/[^\/]+\/[^\/]+$/i.test(url)) {
|
| 466 |
+
return res.json({ message: 'Invalid URL' });
|
| 467 |
+
}
|
| 468 |
+
let data = await mediafire(url)
|
| 469 |
+
return res.json(data)
|
| 470 |
+
} catch (e) {
|
| 471 |
+
console.log(e);
|
| 472 |
+
return res.json({ message: e.message });
|
| 473 |
+
}
|
| 474 |
+
})
|
| 475 |
.get('/ytdl', async (req, res) => {
|
| 476 |
try {
|
| 477 |
let { url } = req.query
|