UNPKG

@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.

31 lines (30 loc) 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetCostumAjaxURL = GetCostumAjaxURL; exports.default = GetAjaxURL; const default_1 = __importDefault(require("../default")); const defaultPathRegister = { download: "/api/progress", info: "/api/download" }; function GetCostumAjaxURL(costumPath = defaultPathRegister) { const costumRegister = { download: costumPath.download, info: costumPath.info }; return (reqType, hosting) => { const parsedHostUrl = new URL(String(hosting || default_1.default.hosting || "")); const origin = `${parsedHostUrl.protocol || "https:"}//${parsedHostUrl.host}`; const getType = costumRegister[reqType] || ""; return String(new URL(getType, origin).href); }; } function GetAjaxURL(reqType, hosting) { const parsedHostUrl = new URL(String(hosting || default_1.default.hosting || "")); const origin = `${parsedHostUrl.protocol || "https:"}//${parsedHostUrl.host}`; const getType = defaultPathRegister[reqType] || ""; return String(new URL(getType, origin).href); }