@ernestoyoofi/yt.loader-to
Version:
An unofficial, promise-based API wrapper for `loader.to` to fetch YouTube video information and generate download links. Written in TypeScript, it's fully typed and easy to use in any Node.js project.
49 lines (48 loc) • 2.38 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const default_1 = __importDefault(require("./default"));
const download_media_1 = __importDefault(require("./request/download-media"));
const get_info_1 = __importDefault(require("./request/get-info"));
const get_ajax_url_1 = require("./yt/get-ajax-url");
class API_YoutubeDownloader {
constructor({ hosting = "", axios_config = {}, costum_ajax, debugging }) {
this.__axios_config = axios_config;
this.__hosting = hosting || default_1.default.hosting;
this.__getajax = costum_ajax ? (0, get_ajax_url_1.GetCostumAjaxURL)(costum_ajax) : undefined;
this.__debugging = debugging;
}
GetInfoYt(url) {
return __awaiter(this, void 0, void 0, function* () {
const urlStr = String(url || "");
return yield (0, get_info_1.default)(urlStr, this.__axios_config);
});
}
DownloadMedia(link, format) {
return __awaiter(this, void 0, void 0, function* () {
return yield (0, download_media_1.default)({
debugging: this.__debugging,
link: String(link || ""),
format: (format || "720"),
options: {
ajax: this.__getajax,
hosting: this.__hosting
}
});
});
}
}
exports.default = Object.assign(Object.assign({}, default_1.default), { API_YoutubeDownloader,
DownloadMedia: download_media_1.default,
GetInfoYoutubeContent: get_info_1.default });