Socket
Socket
Sign inDemoInstall

youtube-ext

Package Overview
Dependencies
1
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.20 to 1.1.21

2

dist/channelInfo.d.ts

@@ -1,2 +0,2 @@

import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export interface ChannelInfoOptions {

@@ -3,0 +3,0 @@ requestOptions?: UndiciRequestOptions;

@@ -14,6 +14,4 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const cookies_1 = require("./cookies");
const utils_1 = require("./utils");
const cookies_1 = require("./cookies");
/**

@@ -25,11 +23,11 @@ * Get full information about a YouTube channel.

if (typeof url !== "string") {
throw new Error(constants_1.constants.errors.type("url", "string", typeof url));
throw new Error(utils_1.constants.errors.type("url", "string", typeof url));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -41,3 +39,3 @@ },

if (!url.startsWith("http")) {
url = constants_1.constants.urls.channel.base(url);
url = utils_1.constants.urls.channel.base(url);
}

@@ -47,2 +45,3 @@ let data;

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
data = yield resp.body.text();

@@ -56,3 +55,3 @@ cookies_1.cookieJar.utilizeResponseHeaders(resp.headers);

try {
const raw = (0, common_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
const raw = (0, utils_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
initialData = JSON.parse(raw);

@@ -93,3 +92,3 @@ }

id: x === null || x === void 0 ? void 0 : x.videoId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_d = (_c = (_b = x === null || x === void 0 ? void 0 : x.navigationEndpoint) === null || _b === void 0 ? void 0 : _b.commandMetadata) === null || _c === void 0 ? void 0 : _c.webCommandMetadata) === null || _d === void 0 ? void 0 : _d.url),

@@ -96,0 +95,0 @@ channel: {

import { VideoStream } from "./videoInfo";
import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export interface ExtractStreamInfoOptions {

@@ -4,0 +4,0 @@ requestOptions?: UndiciRequestOptions;

@@ -14,5 +14,4 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const cookies_1 = require("./cookies");
const utils_1 = require("./utils");
/**

@@ -25,11 +24,11 @@ * Get only stream information about a YouTube video.

if (typeof url !== "string") {
throw new Error(constants_1.constants.errors.type("url", "string", typeof url));
throw new Error(utils_1.constants.errors.type("url", "string", typeof url));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -40,3 +39,3 @@ },

if (!url.startsWith("http")) {
url = constants_1.constants.urls.video.base(url);
url = utils_1.constants.urls.video.base(url);
}

@@ -46,2 +45,3 @@ let data;

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
data = yield resp.body.text();

@@ -55,3 +55,3 @@ cookies_1.cookieJar.utilizeResponseHeaders(resp.headers);

try {
const streamingDataRaw = (0, common_1.contentBetweenEnds)(data, '"streamingData":', [
const streamingDataRaw = (0, utils_1.contentBetweenEnds)(data, '"streamingData":', [
['},"playbackTracking":{', "}"],

@@ -72,5 +72,5 @@ ['}]},"', "}]}"],

try {
const playerJsURL = (0, common_1.contentBetween)(data, '"PLAYER_JS_URL":"', '"');
const playerJsURL = (0, utils_1.contentBetween)(data, '"PLAYER_JS_URL":"', '"');
stream.player = {
url: constants_1.constants.urls.base + playerJsURL,
url: utils_1.constants.urls.base + playerJsURL,
};

@@ -77,0 +77,0 @@ }

import { VideoStream, VideoFormat } from "./videoInfo";
import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export type GetFormatsEvaluator = "auto" | "eval" | "vm" | "isolated-vm" | GetFormatsCustomEvaluator;

@@ -4,0 +4,0 @@ export type GetFormatsCustomEvaluator = (code: string) => Promise<GetFormatsEvaluatorResult>;

@@ -14,5 +14,4 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const cookies_1 = require("./cookies");
const utils_1 = require("./utils");
/**

@@ -26,11 +25,11 @@ * Generates Stream URL(s).

if (typeof stream !== "object") {
throw new Error(constants_1.constants.errors.type("formats", "object", typeof stream));
throw new Error(utils_1.constants.errors.type("formats", "object", typeof stream));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -61,3 +60,3 @@ },

}));
const cipherData = (0, common_1.parseQueryString)(x.signatureCipher);
const cipherData = (0, utils_1.parseQueryString)(x.signatureCipher);
x.url = `${cipherData.url}&${cipherData.sp}=${decipher.decoder(cipherData.s)}`;

@@ -82,2 +81,3 @@ x.__decoded = true;

const hlsResp = yield (0, undici_1.request)(stream.hlsManifestUrl, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(hlsResp);
const hlsData = yield hlsResp.body.text();

@@ -102,9 +102,9 @@ cookies_1.cookieJar.utilizeResponseHeaders(hlsResp.headers);

resolved.push({
itag: (0, common_1.parseNumberOr)((_g = url.match(/itag\/(\d+)\//)) === null || _g === void 0 ? void 0 : _g[1], 0),
itag: (0, utils_1.parseNumberOr)((_g = url.match(/itag\/(\d+)\//)) === null || _g === void 0 ? void 0 : _g[1], 0),
url,
mimeType: codecs ? `codes=${codecs[1]}` : "",
contentLength: (_h = tags["BANDWIDTH"]) !== null && _h !== void 0 ? _h : "0",
fps: (0, common_1.parseNumberOr)(tags["RATE"], 0),
height: (0, common_1.parseNumberOr)(resolution[1], 0),
width: (0, common_1.parseNumberOr)(resolution[0], 0),
fps: (0, utils_1.parseNumberOr)(tags["RATE"], 0),
height: (0, utils_1.parseNumberOr)(resolution[1], 0),
width: (0, utils_1.parseNumberOr)(resolution[0], 0),
__decoded: true,

@@ -119,11 +119,12 @@ });

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
const data = yield resp.body.text();
const aFuncStart = 'a=a.split("")';
const aFuncEnd = "};";
const aFuncBody = (0, common_1.contentBetween)(data, aFuncStart, aFuncEnd);
const aFuncBody = (0, utils_1.contentBetween)(data, aFuncStart, aFuncEnd);
const aFunc = "(a) => {" + aFuncStart + aFuncBody + aFuncEnd;
const bVar = (0, common_1.contentBetween)(aFuncBody, ";", ".");
const bVar = (0, utils_1.contentBetween)(aFuncBody, ";", ".");
const bVarStart = `var ${bVar}=`;
const bVarEnd = "}};";
const bFuncBody = (0, common_1.contentBetween)(data, bVarStart, bVarEnd);
const bFuncBody = (0, utils_1.contentBetween)(data, bVarStart, bVarEnd);
const bFunc = bVarStart + bFuncBody + bVarEnd;

@@ -150,6 +151,6 @@ const decoderCode = aFunc + "\n" + bFunc;

else {
if ((0, common_1.isModuleInstalled)("isolated-vm")) {
if ((0, utils_1.isModuleInstalled)("isolated-vm")) {
evaluator = evalInIsolatedVM;
}
else if ((0, common_1.isModuleInstalled)("vm")) {
else if ((0, utils_1.isModuleInstalled)("vm")) {
evaluator = evalInNodeVM;

@@ -172,3 +173,3 @@ }

const evalInNodeVM = (code) => __awaiter(void 0, void 0, void 0, function* () {
const vm = (0, common_1.requireOrThrow)("vm");
const vm = (0, utils_1.requireOrThrow)("vm");
return {

@@ -182,3 +183,3 @@ decoder: vm.runInNewContext(code),

var _j;
const ivm = (0, common_1.requireOrThrow)("isolated-vm");
const ivm = (0, utils_1.requireOrThrow)("isolated-vm");
const isolate = new ivm.Isolate({ memoryLimit: (_j = options === null || options === void 0 ? void 0 : options.memoryLimit) !== null && _j !== void 0 ? _j : 8 });

@@ -185,0 +186,0 @@ const context = isolate.createContextSync();

@@ -5,3 +5,3 @@ /// <reference types="node" />

import type Miniget from "miniget";
import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export interface GetReadableStreamOptions {

@@ -8,0 +8,0 @@ begin?: number;

@@ -14,5 +14,3 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const youtube_1 = require("./utils/youtube");
const utils_1 = require("./utils");
/**

@@ -26,13 +24,13 @@ * Returns a YouTube stream.

if (typeof stream !== "object") {
throw new Error(constants_1.constants.errors.type("streams", "object", typeof stream));
throw new Error(utils_1.constants.errors.type("streams", "object", typeof stream));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
const commonRequestOptions = {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
},
};
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: commonRequestOptions,

@@ -42,6 +40,6 @@ m3u8streamRequestOptions: commonRequestOptions,

}, options);
if ((0, youtube_1.isDashContentURL)(stream.url) || (0, youtube_1.isHlsContentURL)(stream.url)) {
const m3u8stream = (0, common_1.requireOrThrow)("m3u8stream");
if ((0, utils_1.isDashContentURL)(stream.url) || (0, utils_1.isHlsContentURL)(stream.url)) {
const m3u8stream = (0, utils_1.requireOrThrow)("m3u8stream");
let begin = options.begin;
if (typeof begin === "undefined" && (0, youtube_1.isLiveContentURL)(stream.url)) {
if (typeof begin === "undefined" && (0, utils_1.isLiveContentURL)(stream.url)) {
begin = Date.now();

@@ -58,4 +56,4 @@ }

}
if (!options.ignoreMiniget && (0, common_1.isModuleInstalled)("miniget")) {
const miniget = (0, common_1.requireOrThrow)("miniget");
if (!options.ignoreMiniget && (0, utils_1.isModuleInstalled)("miniget")) {
const miniget = (0, utils_1.requireOrThrow)("miniget");
return miniget(streamURL, options.minigetRequestOptions);

@@ -62,0 +60,0 @@ }

@@ -1,2 +0,2 @@

import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export interface PlaylistInfoOptions {

@@ -3,0 +3,0 @@ requestOptions?: UndiciRequestOptions;

@@ -14,5 +14,4 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const cookies_1 = require("./cookies");
const utils_1 = require("./utils");
/**

@@ -24,11 +23,11 @@ * Get full information about a YouTube playlist.

if (typeof url !== "string") {
throw new Error(constants_1.constants.errors.type("url", "string", typeof url));
throw new Error(utils_1.constants.errors.type("url", "string", typeof url));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -38,5 +37,5 @@ },

}, options);
const id = (_b = (_a = url.match(constants_1.constants.urls.playlist.getIdRegex)) === null || _a === void 0 ? void 0 : _a[2]) !== null && _b !== void 0 ? _b : url;
const id = (_b = (_a = url.match(utils_1.constants.urls.playlist.getIdRegex)) === null || _a === void 0 ? void 0 : _a[2]) !== null && _b !== void 0 ? _b : url;
if (!url.startsWith("http")) {
url = constants_1.constants.urls.playlist.base(id);
url = utils_1.constants.urls.playlist.base(id);
}

@@ -46,2 +45,3 @@ let data;

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
data = yield resp.body.text();

@@ -55,3 +55,3 @@ cookies_1.cookieJar.utilizeResponseHeaders(resp.headers);

try {
initialDataRaw = (0, common_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
initialDataRaw = (0, utils_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
}

@@ -92,8 +92,8 @@ catch (err) {

try {
const initialContinuationToken = (0, common_1.contentBetween)(data, '"continuationCommand":{"token":"', '","');
const innerTubeRaw = (0, common_1.contentBetween)(data, '"INNERTUBE_API_KEY":', ',"INNERTUBE_CONTEXT":');
const initialContinuationToken = (0, utils_1.contentBetween)(data, '"continuationCommand":{"token":"', '","');
const innerTubeRaw = (0, utils_1.contentBetween)(data, '"INNERTUBE_API_KEY":', ',"INNERTUBE_CONTEXT":');
const { INNERTUBE_API_KEY, INNERTUBE_CLIENT_VERSION } = JSON.parse('{"INNERTUBE_API_KEY":' + innerTubeRaw + "}");
let continuationToken = initialContinuationToken;
while (continuationToken) {
const resp = yield (0, undici_1.request)(constants_1.constants.urls.playlist.continuation(INNERTUBE_API_KEY), Object.assign(Object.assign({}, options.requestOptions), { method: "POST", body: JSON.stringify({
const resp = yield (0, undici_1.request)(utils_1.constants.urls.playlist.continuation(INNERTUBE_API_KEY), Object.assign(Object.assign({}, options.requestOptions), { method: "POST", body: JSON.stringify({
continuation: continuationToken,

@@ -112,2 +112,3 @@ context: {

}) }));
(0, utils_1.assertUndiciOkResponse)(resp);
const data = (yield resp.body.json());

@@ -139,3 +140,3 @@ continuationToken = undefined;

id: x === null || x === void 0 ? void 0 : x.videoId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_e = (_d = (_c = x === null || x === void 0 ? void 0 : x.navigationEndpoint) === null || _c === void 0 ? void 0 : _c.commandMetadata) === null || _d === void 0 ? void 0 : _d.webCommandMetadata) === null || _e === void 0 ? void 0 : _e.url),

@@ -145,3 +146,3 @@ channel: {

id: (_m = (_l = (_k = (_j = (_h = x === null || x === void 0 ? void 0 : x.shortBylineText) === null || _h === void 0 ? void 0 : _h.runs[0]) === null || _j === void 0 ? void 0 : _j.navigationEndpoint) === null || _k === void 0 ? void 0 : _k.commandMetadata) === null || _l === void 0 ? void 0 : _l.webCommandMetadata) === null || _m === void 0 ? void 0 : _m.url,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_r = (_q = (_p = (_o = x === null || x === void 0 ? void 0 : x.shortBylineText) === null || _o === void 0 ? void 0 : _o.runs[0]) === null || _p === void 0 ? void 0 : _p.navigationEndpoint) === null || _q === void 0 ? void 0 : _q.browseEndpoint) === null || _r === void 0 ? void 0 : _r.browseId),

@@ -148,0 +149,0 @@ },

@@ -1,3 +0,2 @@

import { constants } from "./utils/constants";
import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions, constants } from "./utils";
export interface SearchOptions {

@@ -4,0 +3,0 @@ requestOptions?: UndiciRequestOptions;

@@ -14,5 +14,4 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const cookies_1 = require("./cookies");
const utils_1 = require("./utils");
/**

@@ -24,11 +23,11 @@ * Search for videos, channels, playlists, etc...

if (typeof terms !== "string") {
throw new Error(constants_1.constants.errors.type("terms", "string", typeof terms));
throw new Error(utils_1.constants.errors.type("terms", "string", typeof terms));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -38,6 +37,6 @@ },

}, options);
let url = constants_1.constants.urls.search.base(terms);
let url = utils_1.constants.urls.search.base(terms);
if (options.filterType &&
constants_1.constants.urls.search.filters[options.filterType]) {
url += constants_1.constants.urls.search.filters[options.filterType];
utils_1.constants.urls.search.filters[options.filterType]) {
url += utils_1.constants.urls.search.filters[options.filterType];
}

@@ -47,2 +46,3 @@ let data;

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
data = yield resp.body.text();

@@ -73,3 +73,3 @@ cookies_1.cookieJar.utilizeResponseHeaders(resp.headers);

id: x === null || x === void 0 ? void 0 : x.videoId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_f = (_e = (_d = x === null || x === void 0 ? void 0 : x.navigationEndpoint) === null || _d === void 0 ? void 0 : _d.commandMetadata) === null || _e === void 0 ? void 0 : _e.webCommandMetadata) === null || _f === void 0 ? void 0 : _f.url),

@@ -79,3 +79,3 @@ channel: {

id: (_m = (_l = (_k = (_j = x === null || x === void 0 ? void 0 : x.ownerText) === null || _j === void 0 ? void 0 : _j.runs[0]) === null || _k === void 0 ? void 0 : _k.navigationEndpoint) === null || _l === void 0 ? void 0 : _l.browseEndpoint) === null || _m === void 0 ? void 0 : _m.browseId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_s = (_r = (_q = (_p = (_o = x === null || x === void 0 ? void 0 : x.ownerText) === null || _o === void 0 ? void 0 : _o.runs[0]) === null || _p === void 0 ? void 0 : _p.navigationEndpoint) === null || _q === void 0 ? void 0 : _q.commandMetadata) === null || _r === void 0 ? void 0 : _r.webCommandMetadata) === null || _s === void 0 ? void 0 : _s.url),

@@ -104,3 +104,3 @@ },

id: x === null || x === void 0 ? void 0 : x.channelId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_6 = (_5 = x === null || x === void 0 ? void 0 : x.navigationEndpoint) === null || _5 === void 0 ? void 0 : _5.browseEndpoint) === null || _6 === void 0 ? void 0 : _6.canonicalBaseUrl),

@@ -128,3 +128,3 @@ // TODO: ensure if its `videoCountText` or `subscriberCountText`

id: x === null || x === void 0 ? void 0 : x.playlistId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_17 = (_16 = (_15 = x === null || x === void 0 ? void 0 : x.navigationEndpoint) === null || _15 === void 0 ? void 0 : _15.commandMetadata) === null || _16 === void 0 ? void 0 : _16.webCommandMetadata) === null || _17 === void 0 ? void 0 : _17.url),

@@ -131,0 +131,0 @@ thumbnails: (_20 = (_19 = (_18 = x === null || x === void 0 ? void 0 : x.thumbnailRenderer) === null || _18 === void 0 ? void 0 : _18.playlistVideoThumbnailRenderer) === null || _19 === void 0 ? void 0 : _19.thumbnail) === null || _20 === void 0 ? void 0 : _20.thumbnails,

@@ -18,3 +18,11 @@ "use strict";

const contentBetween = (data, start, end) => {
return data.split(start, 2)[1].split(end, 1)[0];
const first = data.split(start, 2)[1];
if (typeof first !== "string") {
throw new Error(`Unable to match prefix (${first})`);
}
const second = first.split(end, 1)[0];
if (typeof second !== "string") {
throw new Error(`Unable to match suffix (${second})`);
}
return second;
};

@@ -30,4 +38,3 @@ exports.contentBetween = contentBetween;

}
// should i return first?
return first;
throw new Error(`Unable to match any of the suffixes (${JSON.stringify(ends)})`);
};

@@ -34,0 +41,0 @@ exports.contentBetweenEnds = contentBetweenEnds;

export * from "./common";
export * from "./constants";
export * from "./undici";
export * from "./youtube";

@@ -19,2 +19,3 @@ "use strict";

__exportStar(require("./constants"), exports);
__exportStar(require("./undici"), exports);
__exportStar(require("./youtube"), exports);

@@ -1,2 +0,3 @@

import { request } from "undici";
import { Dispatcher, request } from "undici";
export type UndiciRequestOptions = NonNullable<Parameters<typeof request>[1]>;
export declare const assertUndiciOkResponse: (response: Dispatcher.ResponseData) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertUndiciOkResponse = void 0;
const assertUndiciOkResponse = (response) => {
if (response.statusCode !== 200) {
throw new Error(`Unexpected status code ${response.statusCode}`);
}
};
exports.assertUndiciOkResponse = assertUndiciOkResponse;

@@ -1,2 +0,2 @@

import { UndiciRequestOptions } from "./utils/undici";
import { UndiciRequestOptions } from "./utils";
export interface VideoInfoOptions {

@@ -3,0 +3,0 @@ requestOptions?: UndiciRequestOptions;

@@ -14,6 +14,5 @@ "use strict";

const undici_1 = require("undici");
const constants_1 = require("./utils/constants");
const common_1 = require("./utils/common");
const utils_1 = require("./utils");
const cookies_1 = require("./cookies");
const extractStreamInfo_1 = require("./extractStreamInfo");
const cookies_1 = require("./cookies");
/**

@@ -25,11 +24,11 @@ * Get full information about a YouTube video.

if (typeof url !== "string") {
throw new Error(constants_1.constants.errors.type("url", "string", typeof url));
throw new Error(utils_1.constants.errors.type("url", "string", typeof url));
}
if (typeof options !== "object") {
throw new Error(constants_1.constants.errors.type("options", "object", typeof options));
throw new Error(utils_1.constants.errors.type("options", "object", typeof options));
}
options = (0, common_1.mergeObj)({
options = (0, utils_1.mergeObj)({
requestOptions: {
headers: {
"User-Agent": constants_1.constants.headers.userAgent,
"User-Agent": utils_1.constants.headers.userAgent,
Cookie: cookies_1.cookieJar.cookieHeaderValue(),

@@ -40,3 +39,3 @@ },

if (!url.startsWith("http")) {
url = constants_1.constants.urls.video.base(url);
url = utils_1.constants.urls.video.base(url);
}

@@ -46,2 +45,3 @@ let data;

const resp = yield (0, undici_1.request)(url, options.requestOptions);
(0, utils_1.assertUndiciOkResponse)(resp);
data = yield resp.body.text();

@@ -55,3 +55,3 @@ cookies_1.cookieJar.utilizeResponseHeaders(resp.headers);

try {
const initialDataRaw = (0, common_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
const initialDataRaw = (0, utils_1.contentBetween)(data, "var ytInitialData = ", ";</script>");
initialData = JSON.parse(initialDataRaw);

@@ -64,3 +64,3 @@ }

try {
const initialPlayerRaw = (0, common_1.contentBetween)(data, "var ytInitialPlayerResponse = ", ";var meta = ");
const initialPlayerRaw = (0, utils_1.contentBetween)(data, "var ytInitialPlayerResponse = ", ";var meta = ");
initialPlayer = JSON.parse(initialPlayerRaw);

@@ -92,3 +92,3 @@ }

id: (_k = (_j = initialData === null || initialData === void 0 ? void 0 : initialData.currentVideoEndpoint) === null || _j === void 0 ? void 0 : _j.watchEndpoint) === null || _k === void 0 ? void 0 : _k.videoId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_o = (_m = (_l = initialData === null || initialData === void 0 ? void 0 : initialData.currentVideoEndpoint) === null || _l === void 0 ? void 0 : _l.commandMetadata) === null || _m === void 0 ? void 0 : _m.webCommandMetadata) === null || _o === void 0 ? void 0 : _o.url),

@@ -100,3 +100,3 @@ shortDescription: (_p = initialPlayer === null || initialPlayer === void 0 ? void 0 : initialPlayer.videoDetails) === null || _p === void 0 ? void 0 : _p.shortDescription,

id: (_2 = (_1 = (_0 = (_z = (_y = (_x = secondary === null || secondary === void 0 ? void 0 : secondary.owner) === null || _x === void 0 ? void 0 : _x.videoOwnerRenderer) === null || _y === void 0 ? void 0 : _y.title) === null || _z === void 0 ? void 0 : _z.runs[0]) === null || _0 === void 0 ? void 0 : _0.navigationEndpoint) === null || _1 === void 0 ? void 0 : _1.browseEndpoint) === null || _2 === void 0 ? void 0 : _2.browseId,
url: constants_1.constants.urls.base +
url: utils_1.constants.urls.base +
((_8 = (_7 = (_6 = (_5 = (_4 = (_3 = secondary === null || secondary === void 0 ? void 0 : secondary.owner) === null || _3 === void 0 ? void 0 : _3.videoOwnerRenderer) === null || _4 === void 0 ? void 0 : _4.title) === null || _5 === void 0 ? void 0 : _5.runs[0]) === null || _6 === void 0 ? void 0 : _6.navigationEndpoint) === null || _7 === void 0 ? void 0 : _7.browseEndpoint) === null || _8 === void 0 ? void 0 : _8.canonicalBaseUrl),

@@ -103,0 +103,0 @@ subscribers: {

{
"name": "youtube-ext",
"version": "1.1.20",
"version": "1.1.21",
"description": "A simple YouTube scraper and downloader.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc