selfdebrid/extractors/dbree.js

45 lines
1.3 KiB
JavaScript

const axios = require("axios");
const ddgb = require("@cantfindkernel/ddos-guard-bypass");
const scp = require("set-cookie-parser");
const cheerio = require("cheerio");
const lib = require("../lib");
module.exports = {
get: get,
hostnames: ["dbree.org"],
tests: []
};
async function get(url, options) {
lib.log(`dbree`, `Bypassing DDOS Guard's protection (this will take a moment)...`, [], true, options);
let bypass = await ddgb.bypass(url);
lib.log(`dbree`, `Fetching page...`, [], true, options);
let resp = await axios({
headers: bypass.headers,
url: url
});
lib.log(`dbree`, `Parsing page...`);
let $ = cheerio.load(resp.data);
let dlLink = $("h2 > a.btn.center-block")?.[0]?.attribs?.href;
let dlName = $("ul:not(.navbar-nav):not(.dropdown-menu) > li")?.[0]?.children?.[0]?.data?.split(`Name: `).slice(1).join(`Name: `);
if (dlLink && dlName) {
let headers = bypass.headers;
let moreCookies = scp.parse(resp.headers["set-cookie"]);
moreCookies = lib.cookieToString(moreCookies);
headers["cookie"] = `${headers["cookie"]}; ${moreCookies}`;
headers["referer"] = url;
return {
axiosData: {
headers: headers,
url: `https:${dlLink}`
},
metadata: {
fileName: dlName
}
};
} else throw new Error("Download button not found.");
}