Quality added

This commit is contained in:
killer069
2021-09-24 12:49:39 +05:30
parent be840ce18b
commit f304d6bcbd
8 changed files with 92 additions and 88 deletions

View File

@@ -7,21 +7,22 @@ import fs from 'fs';
import { sp_validate, yt_validate, so_validate } from '.';
import { SpotifyAuthorize } from './Spotify';
import { check_id, stream as so_stream, stream_from_info as so_stream_info } from './SoundCloud';
import { InfoData, stream as yt_stream, stream_from_info as yt_stream_info } from './YouTube/stream';
import { InfoData, stream as yt_stream, StreamOptions, stream_from_info as yt_stream_info } from './YouTube/stream';
import { SoundCloudTrack, Stream as SoStream } from './SoundCloud/classes';
import { LiveStreaming, Stream as YTStream } from './YouTube/classes/LiveStream';
export async function stream(url: string, cookie?: string): Promise<YTStream | LiveStreaming | SoStream> {
if (url.indexOf('soundcloud') !== -1) return await so_stream(url);
else return await yt_stream(url, cookie);
export async function stream(url: string, options: StreamOptions = {}): Promise<YTStream | LiveStreaming | SoStream> {
if(url.length === 0) throw new Error('Stream URL has a length of 0. Check your url again.')
if (url.indexOf('soundcloud') !== -1) return await so_stream(url, options.quality);
else return await yt_stream(url, { cookie : options.cookie });
}
export async function stream_from_info(
info: InfoData | SoundCloudTrack,
cookie?: string
options: StreamOptions = {}
): Promise<YTStream | LiveStreaming | SoStream> {
if (info instanceof SoundCloudTrack) return await so_stream_info(info);
else return await yt_stream_info(info, cookie);
else return await yt_stream_info(info, { cookie : options.cookie });
}
export async function validate(url: string): Promise<string | boolean> {