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.

29 lines (28 loc) 1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getDownloadFormat; const default_1 = __importDefault(require("../default")); function getDownloadFormat(inputformat) { const stringifiedFormat = String(inputformat || ""); const audioFormatIndex = default_1.default.format.audio.indexOf(stringifiedFormat); const videoFormatIndex = default_1.default.format.video.indexOf(stringifiedFormat); if (audioFormatIndex !== -1) { return { format: default_1.default.format.audio[audioFormatIndex], mediaType: "audio" }; } if (videoFormatIndex !== -1) { return { format: default_1.default.format.video[videoFormatIndex], mediaType: "video" }; } return { format: undefined, mediaType: undefined }; }