commit
68bc6173e2
@ -63,7 +63,7 @@ export async function stream_from_info(
|
|||||||
info: InfoData | StreamInfoData,
|
info: InfoData | StreamInfoData,
|
||||||
options: StreamOptions = {}
|
options: StreamOptions = {}
|
||||||
): Promise<YouTubeStream> {
|
): Promise<YouTubeStream> {
|
||||||
if (!info.format || info.format.length === 0)
|
if (info.format.length === 0)
|
||||||
throw new Error('Upcoming and premiere videos that are not currently live cannot be streamed.');
|
throw new Error('Upcoming and premiere videos that are not currently live cannot be streamed.');
|
||||||
|
|
||||||
const final: any[] = [];
|
const final: any[] = [];
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { YouTubeVideo } from '../classes/Video';
|
|||||||
import { YouTubePlayList } from '../classes/Playlist';
|
import { YouTubePlayList } from '../classes/Playlist';
|
||||||
import { InfoData, StreamInfoData } from './constants';
|
import { InfoData, StreamInfoData } from './constants';
|
||||||
import { URL, URLSearchParams } from 'node:url';
|
import { URL, URLSearchParams } from 'node:url';
|
||||||
|
import { parseAudioFormats } from '../stream';
|
||||||
|
|
||||||
interface InfoOptions {
|
interface InfoOptions {
|
||||||
htmldata?: boolean;
|
htmldata?: boolean;
|
||||||
@ -378,12 +379,15 @@ export async function video_stream_info(url: string, options: InfoOptions = {}):
|
|||||||
dashManifestUrl: player_response.streamingData?.dashManifestUrl ?? null,
|
dashManifestUrl: player_response.streamingData?.dashManifestUrl ?? null,
|
||||||
hlsManifestUrl: player_response.streamingData?.hlsManifestUrl ?? null
|
hlsManifestUrl: player_response.streamingData?.hlsManifestUrl ?? null
|
||||||
};
|
};
|
||||||
return await decipher_info({
|
return await decipher_info(
|
||||||
|
{
|
||||||
LiveStreamData,
|
LiveStreamData,
|
||||||
html5player,
|
html5player,
|
||||||
format,
|
format,
|
||||||
video_details
|
video_details
|
||||||
});
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Function to convert seconds to [hour : minutes : seconds] format
|
* Function to convert seconds to [hour : minutes : seconds] format
|
||||||
@ -427,9 +431,13 @@ export async function video_info(url: string, options: InfoOptions = {}): Promis
|
|||||||
/**
|
/**
|
||||||
* Function uses data from video_basic_info and deciphers it if it contains signatures.
|
* Function uses data from video_basic_info and deciphers it if it contains signatures.
|
||||||
* @param data Data - {@link InfoData}
|
* @param data Data - {@link InfoData}
|
||||||
|
* @param audio_only `boolean` - To decipher only audio formats only.
|
||||||
* @returns Deciphered Video Info {@link InfoData}
|
* @returns Deciphered Video Info {@link InfoData}
|
||||||
*/
|
*/
|
||||||
export async function decipher_info<T extends InfoData | StreamInfoData>(data: T): Promise<T> {
|
export async function decipher_info<T extends InfoData | StreamInfoData>(
|
||||||
|
data: T,
|
||||||
|
audio_only: boolean = false
|
||||||
|
): Promise<T> {
|
||||||
if (
|
if (
|
||||||
data.LiveStreamData.isLive === true &&
|
data.LiveStreamData.isLive === true &&
|
||||||
data.LiveStreamData.dashManifestUrl !== null &&
|
data.LiveStreamData.dashManifestUrl !== null &&
|
||||||
@ -437,11 +445,10 @@ export async function decipher_info<T extends InfoData | StreamInfoData>(data: T
|
|||||||
) {
|
) {
|
||||||
return data;
|
return data;
|
||||||
} else if (data.format.length > 0 && (data.format[0].signatureCipher || data.format[0].cipher)) {
|
} else if (data.format.length > 0 && (data.format[0].signatureCipher || data.format[0].cipher)) {
|
||||||
|
if (audio_only) data.format = parseAudioFormats(data.format);
|
||||||
data.format = await format_decipher(data.format, data.html5player);
|
data.format = await format_decipher(data.format, data.html5player);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else return data;
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets YouTube playlist info from a playlist url.
|
* Gets YouTube playlist info from a playlist url.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user