Some huge changes

This commit is contained in:
killer069
2021-11-18 15:38:25 +05:30
parent e53e892606
commit 81e6bc0092
58 changed files with 648 additions and 181 deletions

View File

@@ -0,0 +1,39 @@
import { YouTubeVideo } from "../classes/Video";
export interface LiveStreamData {
isLive: boolean;
dashManifestUrl: string | null
hlsManifestUrl: string | null
}
export interface formatData {
itag: number;
mimeType: string
bitrate: number
width: number
height: number
lastModified: string
contentLength: string
quality: string
fps: number
qualityLabel: string
projectionType: string
averageBitrate: number
audioQuality: string
approxDurationMs: string
audioSampleRate: string
audioChannels: number
url : string
signatureCipher : string;
cipher : string;
loudnessDb : number;
targetDurationSec : number;
}
export interface InfoData{
LiveStreamData : LiveStreamData
html5player : string
format : Partial<formatData>[]
video_details : YouTubeVideo
related_videos: string[]
}

View File

@@ -2,7 +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';
import { InfoData } from './constants';
interface InfoOptions {
proxy?: Proxy[];
@@ -79,7 +79,7 @@ export function extractID(url: string): string {
* @param options cookie and proxy parameters to add
* @returns Data containing video_details, LiveStreamData and formats of video url.
*/
export async function video_basic_info(url: string, options: InfoOptions = {}) {
export async function video_basic_info(url: string, options: InfoOptions = {}) : Promise<InfoData> {
let body: string;
if (options.htmldata) {
body = url;
@@ -187,7 +187,7 @@ function parseSeconds(seconds: number): string {
* @param options cookie and proxy parameters to add
* @returns Data containing video_details, LiveStreamData and formats of video url.
*/
export async function video_info(url: string, options: InfoOptions = {}) {
export async function video_info(url: string, options: InfoOptions = {}): Promise<InfoData> {
const data = await video_basic_info(url, options);
if (data.LiveStreamData.isLive === true && data.LiveStreamData.hlsManifestUrl !== null) {
return data;