Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/others/mediafire.js
1126 views
1
import got from 'got';
2
import cheerio from 'cheerio';
3
export async function mediafiredl(url) {
4
var _a, _b;
5
if (!/https?:\/\/(www\.)?mediafire\.com/.test(url))
6
throw new Error('Invalid URL: ' + url);
7
const data = await got(url).text();
8
const $ = cheerio.load(data);
9
const Url = ($('#downloadButton').attr('href') || '').trim();
10
const url2 = ($('#download_link > a.retry').attr('href') || '').trim();
11
const $intro = $('div.dl-info > div.intro');
12
const filename = $intro.find('div.filename').text().trim();
13
const filetype = $intro.find('div.filetype > span').eq(0).text().trim();
14
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';
15
const $li = $('div.dl-info > ul.details > li');
16
const aploud = $li.eq(1).find('span').text().trim();
17
const filesizeH = $li.eq(0).find('span').text().trim();
18
const filesize = parseFloat(filesizeH) * (/GB/i.test(filesizeH)
19
? 1000000
20
: /MB/i.test(filesizeH)
21
? 1000
22
: /KB/i.test(filesizeH)
23
? 1
24
: /B/i.test(filesizeH)
25
? 0.1
26
: 0);
27
return {
28
url: Url,
29
url2,
30
filename,
31
filetype,
32
ext,
33
aploud,
34
filesizeH,
35
filesize
36
};
37
}
38
//# sourceMappingURL=mediafire.js.map
39