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