49 lines
1 KiB
JavaScript
49 lines
1 KiB
JavaScript
const axios = require("axios");
|
|
const cheerio = require("cheerio");
|
|
const lib = require("../lib");
|
|
|
|
module.exports = {
|
|
get: get,
|
|
hostnames: ["bunkr.is", "bunkr.ru"],
|
|
tests: []
|
|
}
|
|
|
|
async function get(url, options) {
|
|
let parsed = new URL(url);
|
|
let host = parsed.hostname;
|
|
|
|
if (host == "stream.bunkr.is" || host == "stream.bunkr.ru") {
|
|
lib.log(`bunkr`, `Fetching stream page...`, [], true, options);
|
|
|
|
let resp = await axios({
|
|
url: url,
|
|
headers: lib.defaultHeaders
|
|
});
|
|
|
|
lib.log(`bunkr`, `Parsing page...`);
|
|
let $ = cheerio.load(resp.data);
|
|
|
|
let next = $("#__NEXT_DATA__").text();
|
|
next = JSON.parse(next).props.pageProps.file;
|
|
|
|
return {
|
|
axiosData: {
|
|
url: `${next.mediafiles}/${next.name}`
|
|
},
|
|
metadata: {
|
|
fileName: next.name,
|
|
size: parseInt(next.size)
|
|
}
|
|
}
|
|
} else {
|
|
return {
|
|
axiosData: {
|
|
url: url,
|
|
headers: lib.defaultHeaders
|
|
},
|
|
metadata: {
|
|
fileName: parsed.pathname.substring(1)
|
|
}
|
|
};
|
|
}
|
|
} |