bifm/extractors/rekonise.js
2022-06-26 23:12:27 -04:00

43 lines
1.2 KiB
JavaScript

const axios = require("axios");
const lib = require("../lib");
module.exports = {
hostnames: ["rekonise.com"],
requiresCaptcha: false,
get: async function(url, opt) {
try {
let id = new URL(url).pathname;
if (lib.config().debug == true) console.log("[rekonise] Requesting API...");
let h = lib.config().defaults?.axios.headers;
if (opt.referer) {
h.Referer = opt.referer;
}
let proxy;
if (lib.config().defaults?.axios.proxy) {
if (lib.config().defaults?.axios.proxy?.type == "socks5") {
const agent = require("socks-proxy-agent");
let prox = `socks5://${lib.config().defaults?.axios.proxy?.host}:${lib.config().defaults?.axios.proxy?.port}`;
proxy = {httpsAgent: (new agent.SocksProxyAgent(prox))};
} else {
proxy = {};
}
}
let resp = await axios({
method: "GET",
url: `https://api.rekonise.com/unlocks${id}`,
headers: h,
...proxy
});
if (lib.config().debug == true) console.log("[rekonise] Got API content.");
return resp?.data?.url;
} catch(err) {
throw err;
}
}
}