mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
Codes made pretty
This commit is contained in:
@@ -38,7 +38,7 @@ export async function stream(url: string, quality? : number): Promise<Stream> {
|
||||
|
||||
if (data instanceof SoundCloudPlaylist) throw new Error("Streams can't be created from Playlist url");
|
||||
|
||||
const HLSformats = parseHlsFormats(data.formats)
|
||||
const HLSformats = parseHlsFormats(data.formats);
|
||||
if (!quality) quality = HLSformats.length - 1;
|
||||
else if (quality <= 0) quality = 0;
|
||||
else if (quality > HLSformats.length) quality = HLSformats.length - 1;
|
||||
@@ -51,7 +51,7 @@ export async function stream(url: string, quality? : number): Promise<Stream> {
|
||||
}
|
||||
|
||||
export async function stream_from_info(data: SoundCloudTrack, quality?: number): Promise<Stream> {
|
||||
const HLSformats = parseHlsFormats(data.formats)
|
||||
const HLSformats = parseHlsFormats(data.formats);
|
||||
if (!quality) quality = HLSformats.length - 1;
|
||||
else if (quality <= 0) quality = 0;
|
||||
else if (quality > HLSformats.length) quality = HLSformats.length - 1;
|
||||
@@ -89,7 +89,7 @@ export async function so_validate(url: string): Promise<false | 'track' | 'playl
|
||||
function parseHlsFormats(data: SoundCloudTrackFormat[]) {
|
||||
const result: SoundCloudTrackFormat[] = [];
|
||||
data.forEach((format) => {
|
||||
if(format.format.protocol === 'hls') result.push(format)
|
||||
if (format.format.protocol === 'hls') result.push(format);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { SoundCloudTrack, Stream as SoStream } from './SoundCloud/classes';
|
||||
import { LiveStreaming, Stream as YTStream } from './YouTube/classes/LiveStream';
|
||||
|
||||
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.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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user