mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
pretty code
This commit is contained in:
@@ -182,7 +182,7 @@ export class SoundCloudTrack {
|
||||
* Converts class to JSON
|
||||
* @returns JSON parsed Data
|
||||
*/
|
||||
toJSON() : SoundTrackJSON {
|
||||
toJSON(): SoundTrackJSON {
|
||||
return {
|
||||
name: this.name,
|
||||
id: this.id,
|
||||
@@ -288,7 +288,7 @@ export class SoundCloudPlaylist {
|
||||
}
|
||||
/**
|
||||
* Fetches all unfetched songs in a playlist.
|
||||
*
|
||||
*
|
||||
* For fetching songs and getting all songs, see `fetched_tracks` property.
|
||||
* @returns playlist class
|
||||
*/
|
||||
@@ -325,14 +325,14 @@ export class SoundCloudPlaylist {
|
||||
}
|
||||
/**
|
||||
* Get all fetched tracks as a array.
|
||||
*
|
||||
*
|
||||
* For getting all feetched tracks
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* const playlist = await play.soundcloud("playlist url")
|
||||
*
|
||||
*
|
||||
* await playlist.fetch()
|
||||
*
|
||||
*
|
||||
* const result = playlist.fetched_tracks
|
||||
* ```
|
||||
*/
|
||||
@@ -370,9 +370,9 @@ export class SoundCloudStream {
|
||||
* Readable Stream through which data passes
|
||||
*/
|
||||
stream: Readable;
|
||||
/**
|
||||
* Type of audio data that we recieved from normal youtube url.
|
||||
*/
|
||||
/**
|
||||
* Type of audio data that we recieved from normal youtube url.
|
||||
*/
|
||||
type: StreamType;
|
||||
/**
|
||||
* Dash Url containing segment urls.
|
||||
@@ -396,7 +396,7 @@ export class SoundCloudStream {
|
||||
private downloaded_segments: number;
|
||||
/**
|
||||
* Incoming message that we recieve.
|
||||
*
|
||||
*
|
||||
* Storing this is essential.
|
||||
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
||||
* @private
|
||||
@@ -503,7 +503,7 @@ export class SoundCloudStream {
|
||||
}
|
||||
/**
|
||||
* This cleans every used variable in class.
|
||||
*
|
||||
*
|
||||
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
||||
*/
|
||||
private cleanup() {
|
||||
@@ -519,7 +519,7 @@ export class SoundCloudStream {
|
||||
/**
|
||||
* Pauses timer.
|
||||
* Stops running of loop.
|
||||
*
|
||||
*
|
||||
* Useful if you don't want to get excess data to be stored in stream.
|
||||
*/
|
||||
pause() {
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
import { SoundCloudTrack, SoundCloudTrackDeprecated, SoundCloudTrackFormat, SoundCloudUser } from "./classes";
|
||||
import { SoundCloudTrack, SoundCloudTrackDeprecated, SoundCloudTrackFormat, SoundCloudUser } from './classes';
|
||||
|
||||
export interface SoundTrackJSON{
|
||||
export interface SoundTrackJSON {
|
||||
/**
|
||||
* SoundCloud Track Name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* SoundCloud Track ID
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* SoundCloud Track url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* SoundCloud Track fetched status
|
||||
*/
|
||||
fetched: boolean;
|
||||
/**
|
||||
* SoundCloud Track Duration in seconds
|
||||
*/
|
||||
durationInSec: number;
|
||||
/**
|
||||
* SoundCloud Track Duration in miili seconds
|
||||
*/
|
||||
durationInMs: number;
|
||||
/**
|
||||
* SoundCloud Track formats data
|
||||
*/
|
||||
formats: SoundCloudTrackFormat[];
|
||||
/**
|
||||
* SoundCloud Track Publisher Data
|
||||
*/
|
||||
publisher: {
|
||||
name: string;
|
||||
id: number;
|
||||
artist: string;
|
||||
contains_music: boolean;
|
||||
writer_composer: string;
|
||||
} | null;
|
||||
/**
|
||||
* SoundCloud Track thumbnail
|
||||
*/
|
||||
thumbnail: string;
|
||||
/**
|
||||
* SoundCloud Track user data
|
||||
*/
|
||||
user: SoundCloudUser;
|
||||
name: string;
|
||||
/**
|
||||
* SoundCloud Track ID
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* SoundCloud Track url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* SoundCloud Track fetched status
|
||||
*/
|
||||
fetched: boolean;
|
||||
/**
|
||||
* SoundCloud Track Duration in seconds
|
||||
*/
|
||||
durationInSec: number;
|
||||
/**
|
||||
* SoundCloud Track Duration in miili seconds
|
||||
*/
|
||||
durationInMs: number;
|
||||
/**
|
||||
* SoundCloud Track formats data
|
||||
*/
|
||||
formats: SoundCloudTrackFormat[];
|
||||
/**
|
||||
* SoundCloud Track Publisher Data
|
||||
*/
|
||||
publisher: {
|
||||
name: string;
|
||||
id: number;
|
||||
artist: string;
|
||||
contains_music: boolean;
|
||||
writer_composer: string;
|
||||
} | null;
|
||||
/**
|
||||
* SoundCloud Track thumbnail
|
||||
*/
|
||||
thumbnail: string;
|
||||
/**
|
||||
* SoundCloud Track user data
|
||||
*/
|
||||
user: SoundCloudUser;
|
||||
}
|
||||
|
||||
export interface PlaylistJSON{
|
||||
export interface PlaylistJSON {
|
||||
/**
|
||||
* SoundCloud Playlist Name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* SoundCloud Playlist ID
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* SoundCloud Playlist URL
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* SoundCloud Playlist Sub type. == "album" for soundcloud albums
|
||||
*/
|
||||
sub_type: string;
|
||||
/**
|
||||
* SoundCloud Playlist Total Duration in seconds
|
||||
*/
|
||||
durationInSec: number;
|
||||
/**
|
||||
* SoundCloud Playlist Total Duration in milli seconds
|
||||
*/
|
||||
durationInMs: number;
|
||||
/**
|
||||
* SoundCloud Playlist user data
|
||||
*/
|
||||
user: SoundCloudUser;
|
||||
/**
|
||||
* SoundCloud Playlist tracks [ It can be fetched or not fetched ]
|
||||
*/
|
||||
tracks: SoundCloudTrack[] | SoundCloudTrackDeprecated[];
|
||||
/**
|
||||
* SoundCloud Playlist tracks number
|
||||
*/
|
||||
tracksCount: number;
|
||||
/**
|
||||
* SoundCloud Client ID provided by user
|
||||
* @private
|
||||
*/
|
||||
}
|
||||
name: string;
|
||||
/**
|
||||
* SoundCloud Playlist ID
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* SoundCloud Playlist URL
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* SoundCloud Playlist Sub type. == "album" for soundcloud albums
|
||||
*/
|
||||
sub_type: string;
|
||||
/**
|
||||
* SoundCloud Playlist Total Duration in seconds
|
||||
*/
|
||||
durationInSec: number;
|
||||
/**
|
||||
* SoundCloud Playlist Total Duration in milli seconds
|
||||
*/
|
||||
durationInMs: number;
|
||||
/**
|
||||
* SoundCloud Playlist user data
|
||||
*/
|
||||
user: SoundCloudUser;
|
||||
/**
|
||||
* SoundCloud Playlist tracks [ It can be fetched or not fetched ]
|
||||
*/
|
||||
tracks: SoundCloudTrack[] | SoundCloudTrackDeprecated[];
|
||||
/**
|
||||
* SoundCloud Playlist tracks number
|
||||
*/
|
||||
tracksCount: number;
|
||||
/**
|
||||
* SoundCloud Client ID provided by user
|
||||
* @private
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ interface SoundDataOptions {
|
||||
const pattern = /^(?:(https?):\/\/)?(?:(?:www|m)\.)?(api\.soundcloud\.com|soundcloud\.com|snd\.sc)\/(.*)$/;
|
||||
/**
|
||||
* Gets info from a soundcloud url.
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* let sound = await play.soundcloud('soundcloud url')
|
||||
*
|
||||
*
|
||||
* // sound.type === "track" | "playlist" | "user"
|
||||
*
|
||||
*
|
||||
* if (sound.type === "track") {
|
||||
* spot = spot as play.SoundCloudTrack
|
||||
* // Code with SoundCloud track class.
|
||||
@@ -97,9 +97,9 @@ export async function stream(url: string, quality?: number): Promise<SoundCloudS
|
||||
}
|
||||
/**
|
||||
* Gets Free SoundCloud Client ID.
|
||||
*
|
||||
*
|
||||
* Use this in beginning of your code to add SoundCloud support.
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* play.getFreeClientID().then((clientID) => play.setToken({
|
||||
* soundcloud : {
|
||||
@@ -156,7 +156,7 @@ export async function check_id(id: string): Promise<boolean> {
|
||||
/**
|
||||
* Validates a soundcloud url
|
||||
* @param url soundcloud url
|
||||
* @returns
|
||||
* @returns
|
||||
* ```ts
|
||||
* false | 'track' | 'playlist'
|
||||
* ```
|
||||
@@ -192,4 +192,4 @@ export function setSoundCloudToken(options: SoundDataOptions) {
|
||||
soundData = options;
|
||||
}
|
||||
|
||||
export { SoundCloudTrack, SoundCloudPlaylist, SoundCloudStream }
|
||||
export { SoundCloudTrack, SoundCloudPlaylist, SoundCloudStream };
|
||||
|
||||
Reference in New Issue
Block a user