66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
const axios = require("axios");
|
|
const cheerio = require("cheerio");
|
|
const scp = require("set-cookie-parser");
|
|
const lib = require("../lib");
|
|
|
|
module.exports = {
|
|
get: get,
|
|
hostnames: [
|
|
"anonfiles.com",
|
|
"filechan.org",
|
|
"letsupload.cc",
|
|
"share-online.is",
|
|
"megaupload.is",
|
|
"myfile.is",
|
|
"bayfiles.com",
|
|
"openload.cc",
|
|
"lolabits.se",
|
|
"vshare.is",
|
|
"hotfile.io",
|
|
"rapidshare.nu",
|
|
"upvid.cc"
|
|
],
|
|
tests: []
|
|
}
|
|
|
|
async function get(url, options) {
|
|
let path = new URL(url).pathname;
|
|
let id = path.split(`/`).slice(1)[0];
|
|
if (id?.length !== 10) throw new Error("Invalid Anonfiles link.");
|
|
|
|
lib.log(`anonfiles`, `Fetching page...`, [], true, options);
|
|
|
|
let resp = await axios({
|
|
url: url,
|
|
headers: lib.defaultHeaders
|
|
});
|
|
|
|
lib.log(`anonfiles`, `Parsing page...`);
|
|
let $ = cheerio.load(resp.data);
|
|
let dlLink = $("#download-url")?.[0]?.attribs?.href;
|
|
|
|
if (!dlLink) throw new Error("Invalid URL, could not find download link.");
|
|
|
|
let dlName = dlLink.split(`/`)[dlLink.split(`/`).length - 1];
|
|
|
|
let cookies = scp.parse(resp.headers["set-cookie"]);
|
|
let headers = lib.defaultHeaders;
|
|
headers["Cookies"] = lib.cookieToString(cookies);
|
|
if (headers["Cookies"] == "") delete headers["Cookies"];
|
|
headers["Referer"] = url;
|
|
|
|
headers = JSON.parse(JSON.stringify(headers));
|
|
|
|
lib.log(`anonfiles`, `Extractor succeeded, downloading...`, [], true, options);
|
|
|
|
return {
|
|
axiosData: {
|
|
headers: headers,
|
|
url: dlLink
|
|
},
|
|
metadata: {
|
|
fileName: dlName
|
|
},
|
|
type: "file"
|
|
};
|
|
} |