Add video_info_from_basic_info function

This commit is contained in:
absidue
2021-10-16 16:32:49 +02:00
parent 7640267046
commit f1be72088f
5 changed files with 45 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import { ProxyOptions as Proxy, request } from './../../Request/index';
import { format_decipher } from './cipher';
import { YouTubeVideo } from '../classes/Video';
import { YouTubePlayList } from '../classes/Playlist';
import { InfoData } from '../stream';
interface InfoOptions {
proxy?: Proxy[];
@@ -176,6 +177,21 @@ export async function video_info(url: string, options: InfoOptions = {}) {
return data;
}
}
/**
* Function uses data from video_basic_info and deciphers it if it contains signatures.
* @param data basic_video_info data
* @returns Data containing video_details, LiveStreamData and formats of video url.
*/
export async function video_info_from_basic_info(data: InfoData) {
if (data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null) {
return data;
} else if (data.format[0].signatureCipher || data.format[0].cipher) {
data.format = await format_decipher(data.format, data.html5player);
return data;
} else {
return data;
}
}
/**
* Function to get YouTube playlist info from a playlist url.
* @param url Playlist URL