mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
pretty codes and LiveStream issues fixed 100%
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { video_info } from '.';
|
||||
import { LiveStreaming, Stream } from './classes/LiveStream';
|
||||
import { Proxy } from './utils/request';
|
||||
|
||||
export enum StreamType {
|
||||
Arbitrary = 'arbitrary',
|
||||
@@ -12,6 +13,7 @@ export enum StreamType {
|
||||
export interface StreamOptions {
|
||||
quality?: number;
|
||||
cookie?: string;
|
||||
proxy?: Proxy[];
|
||||
}
|
||||
|
||||
export interface InfoData {
|
||||
@@ -25,7 +27,7 @@ export interface InfoData {
|
||||
video_details: any;
|
||||
}
|
||||
|
||||
function parseAudioFormats(formats: any[]) {
|
||||
export function parseAudioFormats(formats: any[]) {
|
||||
const result: any[] = [];
|
||||
formats.forEach((format) => {
|
||||
const type = format.mimeType as string;
|
||||
@@ -41,7 +43,7 @@ function parseAudioFormats(formats: any[]) {
|
||||
export type YouTubeStream = Stream | LiveStreaming;
|
||||
|
||||
export async function stream(url: string, options: StreamOptions = {}): Promise<YouTubeStream> {
|
||||
const info = await video_info(url, { cookie : options.cookie });
|
||||
const info = await video_info(url, { cookie: options.cookie, proxy: options.proxy });
|
||||
const final: any[] = [];
|
||||
if (
|
||||
info.LiveStreamData.isLive === true &&
|
||||
@@ -70,7 +72,8 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
|
||||
info.video_details.durationInSec,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options.cookie as string
|
||||
options.cookie as string,
|
||||
options.quality
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,6 +106,7 @@ export async function stream_from_info(info: InfoData, options: StreamOptions =
|
||||
info.video_details.durationInSec,
|
||||
Number(final[0].contentLength),
|
||||
info.video_details.url,
|
||||
options.cookie as string
|
||||
options.cookie as string,
|
||||
options.quality
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user