Docs and examples updated

This commit is contained in:
killer069
2021-09-21 13:00:38 +05:30
parent c68a57aaf4
commit 3528f89607
14 changed files with 436 additions and 192 deletions

View File

@@ -49,7 +49,7 @@ export class SoundCloudTrack {
contains_music: boolean;
writer_composer: string;
} | null;
thumbanil: string;
thumbnail: string;
user: SoundCloudUser;
constructor(data: any) {
this.name = data.title;
@@ -81,7 +81,23 @@ export class SoundCloudTrack {
last_name: data.user.last_name,
thumbnail: data.user.avatar_url
};
this.thumbanil = data.artwork_url;
this.thumbnail = data.artwork_url;
}
toJSON() {
return {
name: this.name,
id: this.id,
type: this.type,
url: this.url,
fetched : this.fetched,
durationInMs: this.durationInMs,
durationInSec: this.durationInSec,
publisher: this.publisher,
formats: this.formats,
thumbnail: this.thumbnail,
user : this.user
};
}
}
@@ -152,6 +168,30 @@ export class SoundCloudPlaylist {
}
await Promise.allSettled(work);
}
get total_tracks(){
let count = 0
this.tracks.forEach((track) => {
if(track instanceof SoundCloudTrack) count++
else return
})
return count
}
toJSON() {
return {
name: this.name,
id: this.id,
type: this.type,
sub_type : this.sub_type,
url: this.url,
durationInMs: this.durationInMs,
durationInSec: this.durationInSec,
tracksCount : this.tracksCount,
user : this.user,
tracks : this.tracks
};
}
}
export class Stream extends PassThrough {

View File

@@ -9,9 +9,9 @@ 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 { SoundCloudTrack, Stream as SoStream } from './SoundCloud/classes';
import { LiveStreaming, Stream } from './YouTube/classes/LiveStream';
import { LiveStreaming, Stream as YTStream } from './YouTube/classes/LiveStream';
export async function stream(url: string, cookie?: string): Promise<Stream | LiveStreaming | SoStream> {
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);
}
@@ -19,7 +19,7 @@ export async function stream(url: string, cookie?: string): Promise<Stream | Liv
export async function stream_from_info(
info: InfoData | SoundCloudTrack,
cookie?: string
): Promise<Stream | LiveStreaming | SoStream> {
): Promise<YTStream | LiveStreaming | SoStream> {
if (info instanceof SoundCloudTrack) return await so_stream_info(info);
else return await yt_stream_info(info, cookie);
}