28 lines
661 B
JavaScript
28 lines
661 B
JavaScript
const lib = require("./lib");
|
|
const fs = require("fs/promises");
|
|
|
|
module.exports = {
|
|
fetch: fetch,
|
|
getAllExtractors: getAllExtractors
|
|
};
|
|
|
|
async function fetch(url, options) {
|
|
if (!url) throw new Error("URL parameter is required.");
|
|
if (!options) options = {allowForceLogs: false};
|
|
else if (!options?.forceNoLogs) options.allowForceLogs = false;
|
|
|
|
let extractor = await lib.getExtractor(url);
|
|
let result = await extractor.get(url, options);
|
|
|
|
return result;
|
|
}
|
|
|
|
async function getAllExtractors() {
|
|
let dir = await fs.readdir(`${__dirname}/extractors`);
|
|
|
|
for (let i in dir) {
|
|
dir[i] = `${__dirname}/extractors/${dir[i]}`;
|
|
}
|
|
|
|
return dir;
|
|
} |