pretty code
This commit is contained in:
parent
6fe9372989
commit
32b9fdbf65
@ -256,4 +256,4 @@ export async function dz_advanced_track_search(options: DeezerAdvancedSearchOpti
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { DeezerTrack, DeezerAlbum, DeezerPlaylist }
|
export { DeezerTrack, DeezerAlbum, DeezerPlaylist };
|
||||||
|
|||||||
@ -182,7 +182,7 @@ export class SoundCloudTrack {
|
|||||||
* Converts class to JSON
|
* Converts class to JSON
|
||||||
* @returns JSON parsed Data
|
* @returns JSON parsed Data
|
||||||
*/
|
*/
|
||||||
toJSON() : SoundTrackJSON {
|
toJSON(): SoundTrackJSON {
|
||||||
return {
|
return {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
@ -288,7 +288,7 @@ export class SoundCloudPlaylist {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches all unfetched songs in a playlist.
|
* Fetches all unfetched songs in a playlist.
|
||||||
*
|
*
|
||||||
* For fetching songs and getting all songs, see `fetched_tracks` property.
|
* For fetching songs and getting all songs, see `fetched_tracks` property.
|
||||||
* @returns playlist class
|
* @returns playlist class
|
||||||
*/
|
*/
|
||||||
@ -325,14 +325,14 @@ export class SoundCloudPlaylist {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get all fetched tracks as a array.
|
* Get all fetched tracks as a array.
|
||||||
*
|
*
|
||||||
* For getting all feetched tracks
|
* For getting all feetched tracks
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const playlist = await play.soundcloud("playlist url")
|
* const playlist = await play.soundcloud("playlist url")
|
||||||
*
|
*
|
||||||
* await playlist.fetch()
|
* await playlist.fetch()
|
||||||
*
|
*
|
||||||
* const result = playlist.fetched_tracks
|
* const result = playlist.fetched_tracks
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@ -370,9 +370,9 @@ export class SoundCloudStream {
|
|||||||
* Readable Stream through which data passes
|
* Readable Stream through which data passes
|
||||||
*/
|
*/
|
||||||
stream: Readable;
|
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;
|
type: StreamType;
|
||||||
/**
|
/**
|
||||||
* Dash Url containing segment urls.
|
* Dash Url containing segment urls.
|
||||||
@ -396,7 +396,7 @@ export class SoundCloudStream {
|
|||||||
private downloaded_segments: number;
|
private downloaded_segments: number;
|
||||||
/**
|
/**
|
||||||
* Incoming message that we recieve.
|
* Incoming message that we recieve.
|
||||||
*
|
*
|
||||||
* Storing this is essential.
|
* Storing this is essential.
|
||||||
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
||||||
* @private
|
* @private
|
||||||
@ -503,7 +503,7 @@ export class SoundCloudStream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This cleans every used variable in class.
|
* This cleans every used variable in class.
|
||||||
*
|
*
|
||||||
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
||||||
*/
|
*/
|
||||||
private cleanup() {
|
private cleanup() {
|
||||||
@ -519,7 +519,7 @@ export class SoundCloudStream {
|
|||||||
/**
|
/**
|
||||||
* Pauses timer.
|
* Pauses timer.
|
||||||
* Stops running of loop.
|
* Stops running of loop.
|
||||||
*
|
*
|
||||||
* Useful if you don't want to get excess data to be stored in stream.
|
* Useful if you don't want to get excess data to be stored in stream.
|
||||||
*/
|
*/
|
||||||
pause() {
|
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
|
* SoundCloud Track Name
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track ID
|
* SoundCloud Track ID
|
||||||
*/
|
*/
|
||||||
id: number;
|
id: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track url
|
* SoundCloud Track url
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track fetched status
|
* SoundCloud Track fetched status
|
||||||
*/
|
*/
|
||||||
fetched: boolean;
|
fetched: boolean;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track Duration in seconds
|
* SoundCloud Track Duration in seconds
|
||||||
*/
|
*/
|
||||||
durationInSec: number;
|
durationInSec: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track Duration in miili seconds
|
* SoundCloud Track Duration in miili seconds
|
||||||
*/
|
*/
|
||||||
durationInMs: number;
|
durationInMs: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track formats data
|
* SoundCloud Track formats data
|
||||||
*/
|
*/
|
||||||
formats: SoundCloudTrackFormat[];
|
formats: SoundCloudTrackFormat[];
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track Publisher Data
|
* SoundCloud Track Publisher Data
|
||||||
*/
|
*/
|
||||||
publisher: {
|
publisher: {
|
||||||
name: string;
|
name: string;
|
||||||
id: number;
|
id: number;
|
||||||
artist: string;
|
artist: string;
|
||||||
contains_music: boolean;
|
contains_music: boolean;
|
||||||
writer_composer: string;
|
writer_composer: string;
|
||||||
} | null;
|
} | null;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track thumbnail
|
* SoundCloud Track thumbnail
|
||||||
*/
|
*/
|
||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Track user data
|
* SoundCloud Track user data
|
||||||
*/
|
*/
|
||||||
user: SoundCloudUser;
|
user: SoundCloudUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaylistJSON{
|
export interface PlaylistJSON {
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist Name
|
* SoundCloud Playlist Name
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist ID
|
* SoundCloud Playlist ID
|
||||||
*/
|
*/
|
||||||
id: number;
|
id: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist URL
|
* SoundCloud Playlist URL
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist Sub type. == "album" for soundcloud albums
|
* SoundCloud Playlist Sub type. == "album" for soundcloud albums
|
||||||
*/
|
*/
|
||||||
sub_type: string;
|
sub_type: string;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist Total Duration in seconds
|
* SoundCloud Playlist Total Duration in seconds
|
||||||
*/
|
*/
|
||||||
durationInSec: number;
|
durationInSec: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist Total Duration in milli seconds
|
* SoundCloud Playlist Total Duration in milli seconds
|
||||||
*/
|
*/
|
||||||
durationInMs: number;
|
durationInMs: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist user data
|
* SoundCloud Playlist user data
|
||||||
*/
|
*/
|
||||||
user: SoundCloudUser;
|
user: SoundCloudUser;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist tracks [ It can be fetched or not fetched ]
|
* SoundCloud Playlist tracks [ It can be fetched or not fetched ]
|
||||||
*/
|
*/
|
||||||
tracks: SoundCloudTrack[] | SoundCloudTrackDeprecated[];
|
tracks: SoundCloudTrack[] | SoundCloudTrackDeprecated[];
|
||||||
/**
|
/**
|
||||||
* SoundCloud Playlist tracks number
|
* SoundCloud Playlist tracks number
|
||||||
*/
|
*/
|
||||||
tracksCount: number;
|
tracksCount: number;
|
||||||
/**
|
/**
|
||||||
* SoundCloud Client ID provided by user
|
* SoundCloud Client ID provided by user
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,12 +14,12 @@ interface SoundDataOptions {
|
|||||||
const pattern = /^(?:(https?):\/\/)?(?:(?:www|m)\.)?(api\.soundcloud\.com|soundcloud\.com|snd\.sc)\/(.*)$/;
|
const pattern = /^(?:(https?):\/\/)?(?:(?:www|m)\.)?(api\.soundcloud\.com|soundcloud\.com|snd\.sc)\/(.*)$/;
|
||||||
/**
|
/**
|
||||||
* Gets info from a soundcloud url.
|
* Gets info from a soundcloud url.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* let sound = await play.soundcloud('soundcloud url')
|
* let sound = await play.soundcloud('soundcloud url')
|
||||||
*
|
*
|
||||||
* // sound.type === "track" | "playlist" | "user"
|
* // sound.type === "track" | "playlist" | "user"
|
||||||
*
|
*
|
||||||
* if (sound.type === "track") {
|
* if (sound.type === "track") {
|
||||||
* spot = spot as play.SoundCloudTrack
|
* spot = spot as play.SoundCloudTrack
|
||||||
* // Code with SoundCloud track class.
|
* // Code with SoundCloud track class.
|
||||||
@ -97,9 +97,9 @@ export async function stream(url: string, quality?: number): Promise<SoundCloudS
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets Free SoundCloud Client ID.
|
* Gets Free SoundCloud Client ID.
|
||||||
*
|
*
|
||||||
* Use this in beginning of your code to add SoundCloud support.
|
* Use this in beginning of your code to add SoundCloud support.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* play.getFreeClientID().then((clientID) => play.setToken({
|
* play.getFreeClientID().then((clientID) => play.setToken({
|
||||||
* soundcloud : {
|
* soundcloud : {
|
||||||
@ -156,7 +156,7 @@ export async function check_id(id: string): Promise<boolean> {
|
|||||||
/**
|
/**
|
||||||
* Validates a soundcloud url
|
* Validates a soundcloud url
|
||||||
* @param url soundcloud url
|
* @param url soundcloud url
|
||||||
* @returns
|
* @returns
|
||||||
* ```ts
|
* ```ts
|
||||||
* false | 'track' | 'playlist'
|
* false | 'track' | 'playlist'
|
||||||
* ```
|
* ```
|
||||||
@ -192,4 +192,4 @@ export function setSoundCloudToken(options: SoundDataOptions) {
|
|||||||
soundData = options;
|
soundData = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SoundCloudTrack, SoundCloudPlaylist, SoundCloudStream }
|
export { SoundCloudTrack, SoundCloudPlaylist, SoundCloudStream };
|
||||||
|
|||||||
@ -115,7 +115,7 @@ export class SpotifyTrack {
|
|||||||
thumbnail: SpotifyThumbnail | undefined;
|
thumbnail: SpotifyThumbnail | undefined;
|
||||||
/**
|
/**
|
||||||
* Constructor for Spotify Track
|
* Constructor for Spotify Track
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
@ -149,7 +149,7 @@ export class SpotifyTrack {
|
|||||||
else this.thumbnail = data.album.images[0];
|
else this.thumbnail = data.album.images[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() : TrackJSON {
|
toJSON(): TrackJSON {
|
||||||
return {
|
return {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
@ -205,13 +205,13 @@ export class SpotifyPlaylist {
|
|||||||
tracksCount: number;
|
tracksCount: number;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist Spotify data
|
* Spotify Playlist Spotify data
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private spotifyData: SpotifyDataOptions;
|
private spotifyData: SpotifyDataOptions;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist fetched tracks Map
|
* Spotify Playlist fetched tracks Map
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
||||||
@ -244,7 +244,7 @@ export class SpotifyPlaylist {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches Spotify Playlist tracks more than 100 tracks.
|
* Fetches Spotify Playlist tracks more than 100 tracks.
|
||||||
*
|
*
|
||||||
* For getting all tracks in playlist, see `total_pages` property.
|
* For getting all tracks in playlist, see `total_pages` property.
|
||||||
* @returns Playlist Class.
|
* @returns Playlist Class.
|
||||||
*/
|
*/
|
||||||
@ -283,18 +283,18 @@ export class SpotifyPlaylist {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist tracks are divided in pages.
|
* Spotify Playlist tracks are divided in pages.
|
||||||
*
|
*
|
||||||
* For example getting data of 101 - 200 videos in a playlist,
|
* For example getting data of 101 - 200 videos in a playlist,
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const playlist = await play.spotify('playlist url')
|
* const playlist = await play.spotify('playlist url')
|
||||||
*
|
*
|
||||||
* await playlist.fetch()
|
* await playlist.fetch()
|
||||||
*
|
*
|
||||||
* const result = playlist.page(2)
|
* const result = playlist.page(2)
|
||||||
* ```
|
* ```
|
||||||
* @param num Page Number
|
* @param num Page Number
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
page(num: number) {
|
page(num: number) {
|
||||||
if (!num) throw new Error('Page number is not provided');
|
if (!num) throw new Error('Page number is not provided');
|
||||||
@ -303,16 +303,16 @@ export class SpotifyPlaylist {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist total no of pages in a playlist
|
* Spotify Playlist total no of pages in a playlist
|
||||||
*
|
*
|
||||||
* For getting all songs in a playlist,
|
* For getting all songs in a playlist,
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const playlist = await play.spotify('playlist url')
|
* const playlist = await play.spotify('playlist url')
|
||||||
*
|
*
|
||||||
* await playlist.fetch()
|
* await playlist.fetch()
|
||||||
*
|
*
|
||||||
* const result = []
|
* const result = []
|
||||||
*
|
*
|
||||||
* for (let i = 0; i <= playlist.tota_pages; i++) {
|
* for (let i = 0; i <= playlist.tota_pages; i++) {
|
||||||
* result.push(playlist.page(i))
|
* result.push(playlist.page(i))
|
||||||
* }
|
* }
|
||||||
@ -332,7 +332,7 @@ export class SpotifyPlaylist {
|
|||||||
* Converts Class to JSON
|
* Converts Class to JSON
|
||||||
* @returns JSON data
|
* @returns JSON data
|
||||||
*/
|
*/
|
||||||
toJSON() : PlaylistJSON{
|
toJSON(): PlaylistJSON {
|
||||||
return {
|
return {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
collaborative: this.collaborative,
|
collaborative: this.collaborative,
|
||||||
@ -341,7 +341,7 @@ export class SpotifyPlaylist {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
thumbnail: this.thumbnail,
|
thumbnail: this.thumbnail,
|
||||||
owner: this.owner,
|
owner: this.owner,
|
||||||
tracksCount : this.tracksCount
|
tracksCount: this.tracksCount
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,21 +391,21 @@ export class SpotifyAlbum {
|
|||||||
tracksCount: number;
|
tracksCount: number;
|
||||||
/**
|
/**
|
||||||
* Spotify Album Spotify data
|
* Spotify Album Spotify data
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private spotifyData: SpotifyDataOptions;
|
private spotifyData: SpotifyDataOptions;
|
||||||
/**
|
/**
|
||||||
* Spotify Album fetched tracks Map
|
* Spotify Album fetched tracks Map
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
private fetched_tracks: Map<string, SpotifyTrack[]>;
|
||||||
/**
|
/**
|
||||||
* Constructor for Spotify Album Class
|
* Constructor for Spotify Album Class
|
||||||
* @param data Json parsed album data
|
* @param data Json parsed album data
|
||||||
* @param spotifyData Spotify credentials
|
* @param spotifyData Spotify credentials
|
||||||
*/
|
*/
|
||||||
constructor(data: any, spotifyData: SpotifyDataOptions) {
|
constructor(data: any, spotifyData: SpotifyDataOptions) {
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.type = 'album';
|
this.type = 'album';
|
||||||
@ -435,7 +435,7 @@ export class SpotifyAlbum {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches Spotify Album tracks more than 50 tracks.
|
* Fetches Spotify Album tracks more than 50 tracks.
|
||||||
*
|
*
|
||||||
* For getting all tracks in album, see `total_pages` property.
|
* For getting all tracks in album, see `total_pages` property.
|
||||||
* @returns Album Class.
|
* @returns Album Class.
|
||||||
*/
|
*/
|
||||||
@ -474,18 +474,18 @@ export class SpotifyAlbum {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Spotify Album tracks are divided in pages.
|
* Spotify Album tracks are divided in pages.
|
||||||
*
|
*
|
||||||
* For example getting data of 51 - 100 videos in a album,
|
* For example getting data of 51 - 100 videos in a album,
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const album = await play.spotify('album url')
|
* const album = await play.spotify('album url')
|
||||||
*
|
*
|
||||||
* await album.fetch()
|
* await album.fetch()
|
||||||
*
|
*
|
||||||
* const result = album.page(2)
|
* const result = album.page(2)
|
||||||
* ```
|
* ```
|
||||||
* @param num Page Number
|
* @param num Page Number
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
page(num: number) {
|
page(num: number) {
|
||||||
if (!num) throw new Error('Page number is not provided');
|
if (!num) throw new Error('Page number is not provided');
|
||||||
@ -494,16 +494,16 @@ export class SpotifyAlbum {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Spotify Album total no of pages in a album
|
* Spotify Album total no of pages in a album
|
||||||
*
|
*
|
||||||
* For getting all songs in a album,
|
* For getting all songs in a album,
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const album = await play.spotify('album url')
|
* const album = await play.spotify('album url')
|
||||||
*
|
*
|
||||||
* await album.fetch()
|
* await album.fetch()
|
||||||
*
|
*
|
||||||
* const result = []
|
* const result = []
|
||||||
*
|
*
|
||||||
* for (let i = 0; i <= album.tota_pages; i++) {
|
* for (let i = 0; i <= album.tota_pages; i++) {
|
||||||
* result.push(album.page(i))
|
* result.push(album.page(i))
|
||||||
* }
|
* }
|
||||||
@ -520,10 +520,10 @@ export class SpotifyAlbum {
|
|||||||
return (page_number - 1) * 100 + (this.fetched_tracks.get(`${page_number}`) as SpotifyTrack[]).length;
|
return (page_number - 1) * 100 + (this.fetched_tracks.get(`${page_number}`) as SpotifyTrack[]).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() : AlbumJSON {
|
toJSON(): AlbumJSON {
|
||||||
return {
|
return {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
id : this.id,
|
id: this.id,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
thumbnail: this.thumbnail,
|
thumbnail: this.thumbnail,
|
||||||
@ -531,7 +531,7 @@ export class SpotifyAlbum {
|
|||||||
copyrights: this.copyrights,
|
copyrights: this.copyrights,
|
||||||
release_date: this.release_date,
|
release_date: this.release_date,
|
||||||
release_date_precision: this.release_date_precision,
|
release_date_precision: this.release_date_precision,
|
||||||
tracksCount : this.tracksCount
|
tracksCount: this.tracksCount
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,118 +1,118 @@
|
|||||||
import { SpotifyArtists, SpotifyCopyright, SpotifyThumbnail, SpotifyTrackAlbum } from './classes'
|
import { SpotifyArtists, SpotifyCopyright, SpotifyThumbnail, SpotifyTrackAlbum } from './classes';
|
||||||
|
|
||||||
export interface TrackJSON{
|
export interface TrackJSON {
|
||||||
/**
|
/**
|
||||||
* Spotify Track Name
|
* Spotify Track Name
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Track ID
|
* Spotify Track ID
|
||||||
*/
|
*/
|
||||||
id: string;
|
id: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Track url
|
* Spotify Track url
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Track explicit info.
|
* Spotify Track explicit info.
|
||||||
*/
|
*/
|
||||||
explicit: boolean;
|
explicit: boolean;
|
||||||
/**
|
/**
|
||||||
* Spotify Track Duration in seconds
|
* Spotify Track Duration in seconds
|
||||||
*/
|
*/
|
||||||
durationInSec: number;
|
durationInSec: number;
|
||||||
/**
|
/**
|
||||||
* Spotify Track Duration in milli seconds
|
* Spotify Track Duration in milli seconds
|
||||||
*/
|
*/
|
||||||
durationInMs: number;
|
durationInMs: number;
|
||||||
/**
|
/**
|
||||||
* Spotify Track Artists data [ array ]
|
* Spotify Track Artists data [ array ]
|
||||||
*/
|
*/
|
||||||
artists: SpotifyArtists[];
|
artists: SpotifyArtists[];
|
||||||
/**
|
/**
|
||||||
* Spotify Track Album data
|
* Spotify Track Album data
|
||||||
*/
|
*/
|
||||||
album: SpotifyTrackAlbum | undefined;
|
album: SpotifyTrackAlbum | undefined;
|
||||||
/**
|
/**
|
||||||
* Spotify Track Thumbnail Data
|
* Spotify Track Thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail: SpotifyThumbnail | undefined;
|
thumbnail: SpotifyThumbnail | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlaylistJSON {
|
export interface PlaylistJSON {
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist Name
|
* Spotify Playlist Name
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist collaborative boolean.
|
* Spotify Playlist collaborative boolean.
|
||||||
*/
|
*/
|
||||||
collaborative: boolean;
|
collaborative: boolean;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist Description
|
* Spotify Playlist Description
|
||||||
*/
|
*/
|
||||||
description: string;
|
description: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist URL
|
* Spotify Playlist URL
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist ID
|
* Spotify Playlist ID
|
||||||
*/
|
*/
|
||||||
id: string;
|
id: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist Thumbnail Data
|
* Spotify Playlist Thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail: SpotifyThumbnail;
|
thumbnail: SpotifyThumbnail;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist Owner Artist data
|
* Spotify Playlist Owner Artist data
|
||||||
*/
|
*/
|
||||||
owner: SpotifyArtists;
|
owner: SpotifyArtists;
|
||||||
/**
|
/**
|
||||||
* Spotify Playlist total tracks Count
|
* Spotify Playlist total tracks Count
|
||||||
*/
|
*/
|
||||||
tracksCount: number;
|
tracksCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AlbumJSON{
|
export interface AlbumJSON {
|
||||||
/**
|
/**
|
||||||
* Spotify Album Name
|
* Spotify Album Name
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Class type. == "album"
|
* Spotify Class type. == "album"
|
||||||
*/
|
*/
|
||||||
type: 'track' | 'playlist' | 'album';
|
type: 'track' | 'playlist' | 'album';
|
||||||
/**
|
/**
|
||||||
* Spotify Album url
|
* Spotify Album url
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Album id
|
* Spotify Album id
|
||||||
*/
|
*/
|
||||||
id: string;
|
id: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Album Thumbnail data
|
* Spotify Album Thumbnail data
|
||||||
*/
|
*/
|
||||||
thumbnail: SpotifyThumbnail;
|
thumbnail: SpotifyThumbnail;
|
||||||
/**
|
/**
|
||||||
* Spotify Album artists [ array ]
|
* Spotify Album artists [ array ]
|
||||||
*/
|
*/
|
||||||
artists: SpotifyArtists[];
|
artists: SpotifyArtists[];
|
||||||
/**
|
/**
|
||||||
* Spotify Album copyright data [ array ]
|
* Spotify Album copyright data [ array ]
|
||||||
*/
|
*/
|
||||||
copyrights: SpotifyCopyright[];
|
copyrights: SpotifyCopyright[];
|
||||||
/**
|
/**
|
||||||
* Spotify Album Release date
|
* Spotify Album Release date
|
||||||
*/
|
*/
|
||||||
release_date: string;
|
release_date: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Album Release Date **precise**
|
* Spotify Album Release Date **precise**
|
||||||
*/
|
*/
|
||||||
release_date_precision: string;
|
release_date_precision: string;
|
||||||
/**
|
/**
|
||||||
* Spotify Album total no of tracks
|
* Spotify Album total no of tracks
|
||||||
*/
|
*/
|
||||||
tracksCount: number;
|
tracksCount: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,12 +27,12 @@ export interface SpotifyDataOptions {
|
|||||||
const pattern = /^((https:)?\/\/)?open.spotify.com\/(track|album|playlist)\//;
|
const pattern = /^((https:)?\/\/)?open.spotify.com\/(track|album|playlist)\//;
|
||||||
/**
|
/**
|
||||||
* Gets Spotify url details.
|
* Gets Spotify url details.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* let spot = await play.spotify('spotify url')
|
* let spot = await play.spotify('spotify url')
|
||||||
*
|
*
|
||||||
* // spot.type === "track" | "playlist" | "album"
|
* // spot.type === "track" | "playlist" | "album"
|
||||||
*
|
*
|
||||||
* if (spot.type === "track") {
|
* if (spot.type === "track") {
|
||||||
* spot = spot as play.SpotifyTrack
|
* spot = spot as play.SpotifyTrack
|
||||||
* // Code with spotify track class.
|
* // Code with spotify track class.
|
||||||
@ -85,7 +85,7 @@ export async function spotify(url: string): Promise<Spotify> {
|
|||||||
/**
|
/**
|
||||||
* Validate Spotify url
|
* Validate Spotify url
|
||||||
* @param url Spotify URL
|
* @param url Spotify URL
|
||||||
* @returns
|
* @returns
|
||||||
* ```ts
|
* ```ts
|
||||||
* 'track' | 'playlist' | 'album' | 'search' | false
|
* 'track' | 'playlist' | 'album' | 'search' | false
|
||||||
* ```
|
* ```
|
||||||
@ -144,7 +144,7 @@ export async function SpotifyAuthorize(data: SpotifyDataOptions, file: boolean):
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Checks if spotify token is expired or not.
|
* Checks if spotify token is expired or not.
|
||||||
*
|
*
|
||||||
* Update token if returned false.
|
* Update token if returned false.
|
||||||
* ```ts
|
* ```ts
|
||||||
* if (!play.is_expired()) {
|
* if (!play.is_expired()) {
|
||||||
@ -206,7 +206,7 @@ export async function sp_search(
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Refreshes Token
|
* Refreshes Token
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* if (!play.is_expired()) {
|
* if (!play.is_expired()) {
|
||||||
* await play.refreshToken()
|
* await play.refreshToken()
|
||||||
@ -243,4 +243,4 @@ export function setSpotifyToken(options: SpotifyDataOptions) {
|
|||||||
refreshToken();
|
refreshToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SpotifyTrack, SpotifyAlbum, SpotifyPlaylist }
|
export { SpotifyTrack, SpotifyAlbum, SpotifyPlaylist };
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export class YouTubeChannel {
|
|||||||
* Converts Channel Class to JSON format
|
* Converts Channel Class to JSON format
|
||||||
* @returns json data of the channel
|
* @returns json data of the channel
|
||||||
*/
|
*/
|
||||||
toJSON() : ChannelJSON {
|
toJSON(): ChannelJSON {
|
||||||
return {
|
return {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
verified: this.verified,
|
verified: this.verified,
|
||||||
@ -100,37 +100,37 @@ export class YouTubeChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChannelJSON{
|
interface ChannelJSON {
|
||||||
/**
|
/**
|
||||||
* YouTube Channel Title
|
* YouTube Channel Title
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Channel Verified status.
|
* YouTube Channel Verified status.
|
||||||
*/
|
*/
|
||||||
verified?: boolean;
|
verified?: boolean;
|
||||||
/**
|
/**
|
||||||
* YouTube Channel artist if any.
|
* YouTube Channel artist if any.
|
||||||
*/
|
*/
|
||||||
artist?: boolean;
|
artist?: boolean;
|
||||||
/**
|
/**
|
||||||
* YouTube Channel ID.
|
* YouTube Channel ID.
|
||||||
*/
|
*/
|
||||||
id?: string;
|
id?: string;
|
||||||
/**
|
/**
|
||||||
* Type of Class [ Channel ]
|
* Type of Class [ Channel ]
|
||||||
*/
|
*/
|
||||||
type: 'video' | 'playlist' | 'channel';
|
type: 'video' | 'playlist' | 'channel';
|
||||||
/**
|
/**
|
||||||
* YouTube Channel Url
|
* YouTube Channel Url
|
||||||
*/
|
*/
|
||||||
url?: string;
|
url?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Channel Icon data.
|
* YouTube Channel Icon data.
|
||||||
*/
|
*/
|
||||||
icons?: ChannelIconInterface[];
|
icons?: ChannelIconInterface[];
|
||||||
/**
|
/**
|
||||||
* YouTube Channel subscribers count.
|
* YouTube Channel subscribers count.
|
||||||
*/
|
*/
|
||||||
subscribers?: string;
|
subscribers?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,19 +47,19 @@ export class LiveStream {
|
|||||||
private video_url: string;
|
private video_url: string;
|
||||||
/**
|
/**
|
||||||
* Timer used to update dash url so as to avoid 404 errors after long hours of streaming.
|
* Timer used to update dash url so as to avoid 404 errors after long hours of streaming.
|
||||||
*
|
*
|
||||||
* It updates dash_url every 30 minutes.
|
* It updates dash_url every 30 minutes.
|
||||||
*/
|
*/
|
||||||
private dash_timer: Timer;
|
private dash_timer: Timer;
|
||||||
/**
|
/**
|
||||||
* Segments of url that we recieve in dash file.
|
* Segments of url that we recieve in dash file.
|
||||||
*
|
*
|
||||||
* base_url + segment_urls[0] = One complete url for one segment.
|
* base_url + segment_urls[0] = One complete url for one segment.
|
||||||
*/
|
*/
|
||||||
private segments_urls: string[];
|
private segments_urls: string[];
|
||||||
/**
|
/**
|
||||||
* Incoming message that we recieve.
|
* Incoming message that we recieve.
|
||||||
*
|
*
|
||||||
* Storing this is essential.
|
* Storing this is essential.
|
||||||
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
||||||
*/
|
*/
|
||||||
@ -94,7 +94,7 @@ export class LiveStream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Updates dash url.
|
* Updates dash url.
|
||||||
*
|
*
|
||||||
* Used by dash_timer for updating dash_url every 30 minutes.
|
* Used by dash_timer for updating dash_url every 30 minutes.
|
||||||
*/
|
*/
|
||||||
private async dash_updater() {
|
private async dash_updater() {
|
||||||
@ -109,7 +109,7 @@ export class LiveStream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parses data recieved from dash_url.
|
* Parses data recieved from dash_url.
|
||||||
*
|
*
|
||||||
* Updates base_url , segments_urls array.
|
* Updates base_url , segments_urls array.
|
||||||
*/
|
*/
|
||||||
private async dash_getter() {
|
private async dash_getter() {
|
||||||
@ -126,7 +126,7 @@ export class LiveStream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This cleans every used variable in class.
|
* This cleans every used variable in class.
|
||||||
*
|
*
|
||||||
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
||||||
*/
|
*/
|
||||||
private cleanup() {
|
private cleanup() {
|
||||||
@ -143,7 +143,7 @@ export class LiveStream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This starts function in Live Stream Class.
|
* This starts function in Live Stream Class.
|
||||||
*
|
*
|
||||||
* Gets data from dash url and pass it to dash getter function.
|
* Gets data from dash url and pass it to dash getter function.
|
||||||
* Get data from complete segment url and pass data to Stream.
|
* Get data from complete segment url and pass data to Stream.
|
||||||
*/
|
*/
|
||||||
@ -197,14 +197,14 @@ export class Stream {
|
|||||||
/**
|
/**
|
||||||
* Readable Stream through which data passes
|
* Readable Stream through which data passes
|
||||||
*/
|
*/
|
||||||
stream: Readable;
|
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;
|
type: StreamType;
|
||||||
/**
|
/**
|
||||||
* Audio Endpoint Format Url to get data from.
|
* Audio Endpoint Format Url to get data from.
|
||||||
*/
|
*/
|
||||||
private url: string;
|
private url: string;
|
||||||
/**
|
/**
|
||||||
* Used to calculate no of bytes data that we have recieved
|
* Used to calculate no of bytes data that we have recieved
|
||||||
@ -236,7 +236,7 @@ export class Stream {
|
|||||||
private proxy: Proxy[] | undefined;
|
private proxy: Proxy[] | undefined;
|
||||||
/**
|
/**
|
||||||
* Incoming message that we recieve.
|
* Incoming message that we recieve.
|
||||||
*
|
*
|
||||||
* Storing this is essential.
|
* Storing this is essential.
|
||||||
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
* This helps to destroy the TCP connection completely if you stopped player in between the stream
|
||||||
*/
|
*/
|
||||||
@ -288,7 +288,7 @@ export class Stream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This cleans every used variable in class.
|
* This cleans every used variable in class.
|
||||||
*
|
*
|
||||||
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
* This is used to prevent re-use of this class and helping garbage collector to collect it.
|
||||||
*/
|
*/
|
||||||
private cleanup() {
|
private cleanup() {
|
||||||
@ -298,7 +298,7 @@ export class Stream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Getting data from audio endpoint url and passing it to stream.
|
* Getting data from audio endpoint url and passing it to stream.
|
||||||
*
|
*
|
||||||
* If 404 or 403 occurs, it will retry again.
|
* If 404 or 403 occurs, it will retry again.
|
||||||
*/
|
*/
|
||||||
private async loop() {
|
private async loop() {
|
||||||
@ -354,7 +354,7 @@ export class Stream {
|
|||||||
/**
|
/**
|
||||||
* Pauses timer.
|
* Pauses timer.
|
||||||
* Stops running of loop.
|
* Stops running of loop.
|
||||||
*
|
*
|
||||||
* Useful if you don't want to get excess data to be stored in stream.
|
* Useful if you don't want to get excess data to be stored in stream.
|
||||||
*/
|
*/
|
||||||
pause() {
|
pause() {
|
||||||
@ -370,7 +370,7 @@ export class Stream {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Timer Class.
|
* Timer Class.
|
||||||
*
|
*
|
||||||
* setTimeout + extra features ( re-starting, pausing, resuming ).
|
* setTimeout + extra features ( re-starting, pausing, resuming ).
|
||||||
*/
|
*/
|
||||||
export class Timer {
|
export class Timer {
|
||||||
@ -456,7 +456,7 @@ export class Timer {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Destroy timer.
|
* Destroy timer.
|
||||||
*
|
*
|
||||||
* It can't be used again.
|
* It can't be used again.
|
||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export class YouTubePlayList {
|
|||||||
/**
|
/**
|
||||||
* YouTube Playlist thumbnail Data
|
* YouTube Playlist thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail?: YouTubeThumbnail
|
thumbnail?: YouTubeThumbnail;
|
||||||
/**
|
/**
|
||||||
* Videos array containing data of first 100 videos
|
* Videos array containing data of first 100 videos
|
||||||
*/
|
*/
|
||||||
@ -121,7 +121,7 @@ export class YouTubePlayList {
|
|||||||
/**
|
/**
|
||||||
* Parses next segment of videos from playlist and returns parsed data.
|
* Parses next segment of videos from playlist and returns parsed data.
|
||||||
* @param limit Total no of videos to parse.
|
* @param limit Total no of videos to parse.
|
||||||
*
|
*
|
||||||
* Default = Infinity
|
* Default = Infinity
|
||||||
* @returns Array of YouTube Video Class
|
* @returns Array of YouTube Video Class
|
||||||
*/
|
*/
|
||||||
@ -157,12 +157,12 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches remaining data from playlist
|
* Fetches remaining data from playlist
|
||||||
*
|
*
|
||||||
* For fetching and getting all songs data, see `total_pages` property.
|
* For fetching and getting all songs data, see `total_pages` property.
|
||||||
* @param max Max no of videos to fetch
|
* @param max Max no of videos to fetch
|
||||||
*
|
*
|
||||||
* Default = Infinity
|
* Default = Infinity
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async fetch(max = Infinity): Promise<YouTubePlayList> {
|
async fetch(max = Infinity): Promise<YouTubePlayList> {
|
||||||
const continuation = this._continuation.token;
|
const continuation = this._continuation.token;
|
||||||
@ -173,7 +173,7 @@ export class YouTubePlayList {
|
|||||||
this.__count++;
|
this.__count++;
|
||||||
const res = await this.next();
|
const res = await this.next();
|
||||||
max -= res.length;
|
max -= res.length;
|
||||||
if(max <= 0) break;
|
if (max <= 0) break;
|
||||||
if (!res.length) break;
|
if (!res.length) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +181,14 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist is divided into pages.
|
* YouTube Playlist is divided into pages.
|
||||||
*
|
*
|
||||||
* For example, if you want to get 101 - 200 songs
|
* For example, if you want to get 101 - 200 songs
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const playlist = await play.playlist_info('playlist url')
|
* const playlist = await play.playlist_info('playlist url')
|
||||||
*
|
*
|
||||||
* await playlist.fetch()
|
* await playlist.fetch()
|
||||||
*
|
*
|
||||||
* const result = playlist.page(2)
|
* const result = playlist.page(2)
|
||||||
* ```
|
* ```
|
||||||
* @param number Page number
|
* @param number Page number
|
||||||
@ -201,16 +201,16 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets total no of pages in that playlist class.
|
* Gets total no of pages in that playlist class.
|
||||||
*
|
*
|
||||||
* For getting all songs in a playlist
|
* For getting all songs in a playlist
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const playlist = await play.playlist_info('playlist url');
|
* const playlist = await play.playlist_info('playlist url');
|
||||||
*
|
*
|
||||||
* await playlist.fetch();
|
* await playlist.fetch();
|
||||||
*
|
*
|
||||||
* let result = [];
|
* let result = [];
|
||||||
*
|
*
|
||||||
* for (let i = 0; i <= playlist.total_pages; i++) {
|
* for (let i = 0; i <= playlist.total_pages; i++) {
|
||||||
* result.push(playlist.page(i));
|
* result.push(playlist.page(i));
|
||||||
* }
|
* }
|
||||||
@ -221,7 +221,7 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This tells total no of videos that have been fetched so far.
|
* This tells total no of videos that have been fetched so far.
|
||||||
*
|
*
|
||||||
* This can be equal to videosCount if all videos in playlist have been fetched and they are not hidden.
|
* This can be equal to videosCount if all videos in playlist have been fetched and they are not hidden.
|
||||||
*/
|
*/
|
||||||
get total_videos() {
|
get total_videos() {
|
||||||
@ -230,9 +230,9 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Converts Playlist Class to a json parsed data.
|
* Converts Playlist Class to a json parsed data.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
toJSON() : PlaylistJSON {
|
toJSON(): PlaylistJSON {
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
@ -244,50 +244,50 @@ export class YouTubePlayList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PlaylistJSON{
|
interface PlaylistJSON {
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist ID
|
* YouTube Playlist ID
|
||||||
*/
|
*/
|
||||||
id?: string;
|
id?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist Name
|
* YouTube Playlist Name
|
||||||
*/
|
*/
|
||||||
title?: string;
|
title?: string;
|
||||||
/**
|
/**
|
||||||
* Total no of videos in that playlist
|
* Total no of videos in that playlist
|
||||||
*/
|
*/
|
||||||
videoCount?: number;
|
videoCount?: number;
|
||||||
/**
|
/**
|
||||||
* Time when playlist was last updated
|
* Time when playlist was last updated
|
||||||
*/
|
*/
|
||||||
lastUpdate?: string;
|
lastUpdate?: string;
|
||||||
/**
|
/**
|
||||||
* Total views of that playlist
|
* Total views of that playlist
|
||||||
*/
|
*/
|
||||||
views?: number;
|
views?: number;
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist url
|
* YouTube Playlist url
|
||||||
*/
|
*/
|
||||||
url?: string;
|
url?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist url with starting video url.
|
* YouTube Playlist url with starting video url.
|
||||||
*/
|
*/
|
||||||
link?: string;
|
link?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist channel data
|
* YouTube Playlist channel data
|
||||||
*/
|
*/
|
||||||
channel?: YouTubeChannel;
|
channel?: YouTubeChannel;
|
||||||
/**
|
/**
|
||||||
* YouTube Playlist thumbnail Data
|
* YouTube Playlist thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail?: {
|
thumbnail?: {
|
||||||
id: string | undefined;
|
id: string | undefined;
|
||||||
width: number | undefined;
|
width: number | undefined;
|
||||||
height: number | undefined;
|
height: number | undefined;
|
||||||
url: string | undefined;
|
url: string | undefined;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* first 100 videos in that playlist
|
* first 100 videos in that playlist
|
||||||
*/
|
*/
|
||||||
videos? : YouTubeVideo[]
|
videos?: YouTubeVideo[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,22 @@
|
|||||||
export class YouTubeThumbnail {
|
export class YouTubeThumbnail {
|
||||||
id : string;
|
id: string;
|
||||||
url : string;
|
url: string;
|
||||||
width : number;
|
width: number;
|
||||||
height : number;
|
height: number;
|
||||||
|
|
||||||
constructor(data : any){
|
constructor(data: any) {
|
||||||
this.id = data.id
|
this.id = data.id;
|
||||||
this.url = data.url
|
this.url = data.url;
|
||||||
this.width = data.width
|
this.width = data.width;
|
||||||
this.height = data.height
|
this.height = data.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(){
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
id : this.id,
|
id: this.id,
|
||||||
url : this.url,
|
url: this.url,
|
||||||
width : this.width,
|
width: this.width,
|
||||||
height : this.height
|
height: this.height
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,68 +5,68 @@ interface VideoOptions {
|
|||||||
/**
|
/**
|
||||||
* YouTube Video ID
|
* YouTube Video ID
|
||||||
*/
|
*/
|
||||||
id?: string;
|
id?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube video url
|
* YouTube video url
|
||||||
*/
|
*/
|
||||||
url: string;
|
url: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Video title
|
* YouTube Video title
|
||||||
*/
|
*/
|
||||||
title?: string;
|
title?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Video description.
|
* YouTube Video description.
|
||||||
*/
|
*/
|
||||||
description?: string;
|
description?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Video Duration Formatted
|
* YouTube Video Duration Formatted
|
||||||
*/
|
*/
|
||||||
durationRaw: string;
|
durationRaw: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Video Duration in seconds
|
* YouTube Video Duration in seconds
|
||||||
*/
|
*/
|
||||||
durationInSec: number;
|
durationInSec: number;
|
||||||
/**
|
/**
|
||||||
* YouTube Video Uploaded Date
|
* YouTube Video Uploaded Date
|
||||||
*/
|
*/
|
||||||
uploadedAt?: string;
|
uploadedAt?: string;
|
||||||
/**
|
/**
|
||||||
* YouTube Views
|
* YouTube Views
|
||||||
*/
|
*/
|
||||||
views: number;
|
views: number;
|
||||||
/**
|
/**
|
||||||
* YouTube Thumbnail Data
|
* YouTube Thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail?: {
|
thumbnail?: {
|
||||||
id: string | undefined;
|
id: string | undefined;
|
||||||
width: number | undefined;
|
width: number | undefined;
|
||||||
height: number | undefined;
|
height: number | undefined;
|
||||||
url: string | undefined;
|
url: string | undefined;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* YouTube Video's uploader Channel Data
|
* YouTube Video's uploader Channel Data
|
||||||
*/
|
*/
|
||||||
channel?: YouTubeChannel;
|
channel?: YouTubeChannel;
|
||||||
/**
|
/**
|
||||||
* YouTube Video's likes
|
* YouTube Video's likes
|
||||||
*/
|
*/
|
||||||
likes: number;
|
likes: number;
|
||||||
/**
|
/**
|
||||||
* YouTube Video's dislikes
|
* YouTube Video's dislikes
|
||||||
*/
|
*/
|
||||||
dislikes: number;
|
dislikes: number;
|
||||||
/**
|
/**
|
||||||
* YouTube Video live status
|
* YouTube Video live status
|
||||||
*/
|
*/
|
||||||
live: boolean;
|
live: boolean;
|
||||||
/**
|
/**
|
||||||
* YouTube Video private status
|
* YouTube Video private status
|
||||||
*/
|
*/
|
||||||
private: boolean;
|
private: boolean;
|
||||||
/**
|
/**
|
||||||
* YouTube Video tags
|
* YouTube Video tags
|
||||||
*/
|
*/
|
||||||
tags: string[];
|
tags: string[];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Class for YouTube Video url
|
* Class for YouTube Video url
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export { stream, stream_from_info, YouTubeStream } from './stream';
|
export { stream, stream_from_info, YouTubeStream } from './stream';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export { YouTube } from './search';
|
export { YouTube } from './search';
|
||||||
export { YouTubeVideo } from './classes/Video'
|
export { YouTubeVideo } from './classes/Video';
|
||||||
export { YouTubePlayList } from './classes/Playlist'
|
export { YouTubePlayList } from './classes/Playlist';
|
||||||
export { YouTubeChannel } from './classes/Channel'
|
export { YouTubeChannel } from './classes/Channel';
|
||||||
|
|||||||
@ -1,39 +1,39 @@
|
|||||||
import { YouTubeVideo } from "../classes/Video";
|
import { YouTubeVideo } from '../classes/Video';
|
||||||
|
|
||||||
export interface LiveStreamData {
|
export interface LiveStreamData {
|
||||||
isLive: boolean;
|
isLive: boolean;
|
||||||
dashManifestUrl: string | null
|
dashManifestUrl: string | null;
|
||||||
hlsManifestUrl: string | null
|
hlsManifestUrl: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface formatData {
|
export interface formatData {
|
||||||
itag: number;
|
itag: number;
|
||||||
mimeType: string
|
mimeType: string;
|
||||||
bitrate: number
|
bitrate: number;
|
||||||
width: number
|
width: number;
|
||||||
height: number
|
height: number;
|
||||||
lastModified: string
|
lastModified: string;
|
||||||
contentLength: string
|
contentLength: string;
|
||||||
quality: string
|
quality: string;
|
||||||
fps: number
|
fps: number;
|
||||||
qualityLabel: string
|
qualityLabel: string;
|
||||||
projectionType: string
|
projectionType: string;
|
||||||
averageBitrate: number
|
averageBitrate: number;
|
||||||
audioQuality: string
|
audioQuality: string;
|
||||||
approxDurationMs: string
|
approxDurationMs: string;
|
||||||
audioSampleRate: string
|
audioSampleRate: string;
|
||||||
audioChannels: number
|
audioChannels: number;
|
||||||
url : string
|
url: string;
|
||||||
signatureCipher : string;
|
signatureCipher: string;
|
||||||
cipher : string;
|
cipher: string;
|
||||||
loudnessDb : number;
|
loudnessDb: number;
|
||||||
targetDurationSec : number;
|
targetDurationSec: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InfoData{
|
export interface InfoData {
|
||||||
LiveStreamData : LiveStreamData
|
LiveStreamData: LiveStreamData;
|
||||||
html5player : string
|
html5player: string;
|
||||||
format : Partial<formatData>[]
|
format: Partial<formatData>[];
|
||||||
video_details : YouTubeVideo
|
video_details: YouTubeVideo;
|
||||||
related_videos: string[]
|
related_videos: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,3 +46,29 @@ export function setCookieToken(options: { cookie: string }) {
|
|||||||
youtubeData = { cookie };
|
youtubeData = { cookie };
|
||||||
youtubeData.file = false;
|
youtubeData.file = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates cookies locally either in file or in memory.
|
||||||
|
*
|
||||||
|
* Example
|
||||||
|
* ```ts
|
||||||
|
* const response = ... // Any https package get function.
|
||||||
|
*
|
||||||
|
* play.cookieHeaders(response.headers['set-cookie'])
|
||||||
|
* ```
|
||||||
|
* @param headCookie response headers['set-cookie'] array
|
||||||
|
* @returns Nothing
|
||||||
|
*/
|
||||||
|
export function cookieHeaders(headCookie: string[]): void {
|
||||||
|
if (!youtubeData?.cookie) return;
|
||||||
|
headCookie.forEach((x: string) => {
|
||||||
|
x.split(';').forEach((z) => {
|
||||||
|
const arr = z.split('=');
|
||||||
|
if (arr.length <= 1) return;
|
||||||
|
const key = arr.shift()?.trim() as string;
|
||||||
|
const value = arr.join('=').trim();
|
||||||
|
setCookie(key, value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
uploadCookie();
|
||||||
|
}
|
||||||
|
|||||||
@ -23,9 +23,9 @@ const playlist_pattern =
|
|||||||
/^((?:https?:)?\/\/)?(?:(?:www|m)\.)?(youtube\.com)\/(?:(playlist|watch))(.*)?((\?|\&)list=)(PL|UU|LL|RD|OL)[a-zA-Z\d_-]{16,41}(.*)?$/;
|
/^((?:https?:)?\/\/)?(?:(?:www|m)\.)?(youtube\.com)\/(?:(playlist|watch))(.*)?((\?|\&)list=)(PL|UU|LL|RD|OL)[a-zA-Z\d_-]{16,41}(.*)?$/;
|
||||||
/**
|
/**
|
||||||
* Validate YouTube URL or ID.
|
* Validate YouTube URL or ID.
|
||||||
*
|
*
|
||||||
* **CAUTION :** If your search word is 11-12 long, you might get it validated as video ID.
|
* **CAUTION :** If your search word is 11-12 long, you might get it validated as video ID.
|
||||||
*
|
*
|
||||||
* To avoid above, add one more condition to yt_validate
|
* To avoid above, add one more condition to yt_validate
|
||||||
* ```ts
|
* ```ts
|
||||||
* if (url.startsWith('https') && yt_validate(url) === 'video') {
|
* if (url.startsWith('https') && yt_validate(url) === 'video') {
|
||||||
@ -33,7 +33,7 @@ const playlist_pattern =
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
* @param url YouTube URL OR ID
|
* @param url YouTube URL OR ID
|
||||||
* @returns
|
* @returns
|
||||||
* ```
|
* ```
|
||||||
* 'playlist' | 'video' | 'search' | false
|
* 'playlist' | 'video' | 'search' | false
|
||||||
* ```
|
* ```
|
||||||
@ -114,7 +114,7 @@ export function extractID(url: string): string {
|
|||||||
* - `boolean` htmldata : given data is html data or not
|
* - `boolean` htmldata : given data is html data or not
|
||||||
* @returns Video Basic Info {@link InfoData}.
|
* @returns Video Basic Info {@link InfoData}.
|
||||||
*/
|
*/
|
||||||
export async function video_basic_info(url: string, options: InfoOptions = {}) : Promise<InfoData> {
|
export async function video_basic_info(url: string, options: InfoOptions = {}): Promise<InfoData> {
|
||||||
let body: string;
|
let body: string;
|
||||||
if (options.htmldata) {
|
if (options.htmldata) {
|
||||||
body = url;
|
body = url;
|
||||||
@ -147,11 +147,10 @@ export async function video_basic_info(url: string, options: InfoOptions = {}) :
|
|||||||
player_response.playabilityStatus.errorScreen.playerKavRenderer?.reason.simpleText
|
player_response.playabilityStatus.errorScreen.playerKavRenderer?.reason.simpleText
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
const ownerInfo = initial_response.contents.twoColumnWatchNextResults.results?.results?.contents[1]?.videoSecondaryInfoRenderer
|
const ownerInfo =
|
||||||
?.owner?.videoOwnerRenderer
|
initial_response.contents.twoColumnWatchNextResults.results?.results?.contents[1]?.videoSecondaryInfoRenderer
|
||||||
const badge =
|
?.owner?.videoOwnerRenderer;
|
||||||
ownerInfo?.badges &&
|
const badge = ownerInfo?.badges && ownerInfo?.badges[0];
|
||||||
ownerInfo?.badges[0];
|
|
||||||
const html5player = `https://www.youtube.com${body.split('"jsUrl":"')[1].split('"')[0]}`;
|
const html5player = `https://www.youtube.com${body.split('"jsUrl":"')[1].split('"')[0]}`;
|
||||||
const related: string[] = [];
|
const related: string[] = [];
|
||||||
initial_response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results.forEach(
|
initial_response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results.forEach(
|
||||||
@ -178,7 +177,7 @@ export async function video_basic_info(url: string, options: InfoOptions = {}) :
|
|||||||
url: `https://www.youtube.com/channel/${vid.channelId}`,
|
url: `https://www.youtube.com/channel/${vid.channelId}`,
|
||||||
verified: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('verified')),
|
verified: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('verified')),
|
||||||
artist: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('artist')),
|
artist: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('artist')),
|
||||||
icons : ownerInfo?.thumbnail?.thumbnails || undefined
|
icons: ownerInfo?.thumbnail?.thumbnails || undefined
|
||||||
},
|
},
|
||||||
views: vid.viewCount,
|
views: vid.viewCount,
|
||||||
tags: vid.keywords,
|
tags: vid.keywords,
|
||||||
|
|||||||
@ -134,8 +134,8 @@ export function parseVideo(data?: any): YouTubeVideo {
|
|||||||
data.videoRenderer.ownerText.runs[0].navigationEndpoint.browseEndpoint.canonicalBaseUrl ||
|
data.videoRenderer.ownerText.runs[0].navigationEndpoint.browseEndpoint.canonicalBaseUrl ||
|
||||||
data.videoRenderer.ownerText.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url
|
data.videoRenderer.ownerText.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url
|
||||||
}`,
|
}`,
|
||||||
icons : data.videoRenderer.channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail
|
icons: data.videoRenderer.channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail
|
||||||
.thumbnails,
|
.thumbnails,
|
||||||
verified: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('verified')),
|
verified: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('verified')),
|
||||||
artist: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('artist'))
|
artist: Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('artist'))
|
||||||
},
|
},
|
||||||
|
|||||||
@ -11,9 +11,34 @@ export {
|
|||||||
YouTubePlayList,
|
YouTubePlayList,
|
||||||
YouTubeVideo
|
YouTubeVideo
|
||||||
} from './YouTube';
|
} from './YouTube';
|
||||||
export { spotify, sp_validate, refreshToken, is_expired, SpotifyAlbum, SpotifyPlaylist, SpotifyTrack, Spotify } from './Spotify';
|
export {
|
||||||
export { soundcloud, so_validate, SoundCloud, SoundCloudStream, getFreeClientID, SoundCloudPlaylist, SoundCloudTrack } from './SoundCloud';
|
spotify,
|
||||||
export { deezer, dz_validate, dz_advanced_track_search, Deezer, DeezerTrack, DeezerPlaylist, DeezerAlbum } from './Deezer';
|
sp_validate,
|
||||||
|
refreshToken,
|
||||||
|
is_expired,
|
||||||
|
SpotifyAlbum,
|
||||||
|
SpotifyPlaylist,
|
||||||
|
SpotifyTrack,
|
||||||
|
Spotify
|
||||||
|
} from './Spotify';
|
||||||
|
export {
|
||||||
|
soundcloud,
|
||||||
|
so_validate,
|
||||||
|
SoundCloud,
|
||||||
|
SoundCloudStream,
|
||||||
|
getFreeClientID,
|
||||||
|
SoundCloudPlaylist,
|
||||||
|
SoundCloudTrack
|
||||||
|
} from './SoundCloud';
|
||||||
|
export {
|
||||||
|
deezer,
|
||||||
|
dz_validate,
|
||||||
|
dz_advanced_track_search,
|
||||||
|
Deezer,
|
||||||
|
DeezerTrack,
|
||||||
|
DeezerPlaylist,
|
||||||
|
DeezerAlbum
|
||||||
|
} from './Deezer';
|
||||||
export { setToken } from './token';
|
export { setToken } from './token';
|
||||||
|
|
||||||
enum AudioPlayerStatus {
|
enum AudioPlayerStatus {
|
||||||
@ -83,6 +108,56 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
|
|||||||
else return await yt_stream(url, options);
|
else return await yt_stream(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { deezer: 'album' } } & SearchOptions
|
||||||
|
): Promise<DeezerAlbum[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { deezer: 'playlist' } } & SearchOptions
|
||||||
|
): Promise<DeezerPlaylist[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { deezer: 'track' } } & SearchOptions
|
||||||
|
): Promise<DeezerTrack[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { soundcloud: 'albums' } } & SearchOptions
|
||||||
|
): Promise<SoundCloudPlaylist[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { soundcloud: 'playlists' } } & SearchOptions
|
||||||
|
): Promise<SoundCloudPlaylist[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { soundcloud: 'tracks' } } & SearchOptions
|
||||||
|
): Promise<SoundCloudTrack[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { spotify: 'album' } } & SearchOptions
|
||||||
|
): Promise<SpotifyAlbum[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { spotify: 'playlist' } } & SearchOptions
|
||||||
|
): Promise<SpotifyPlaylist[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { spotify: 'track' } } & SearchOptions
|
||||||
|
): Promise<SpotifyTrack[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { youtube: 'channel' } } & SearchOptions
|
||||||
|
): Promise<YouTubeChannel[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { youtube: 'playlist' } } & SearchOptions
|
||||||
|
): Promise<YouTubePlayList[]>;
|
||||||
|
export async function search(
|
||||||
|
query: string,
|
||||||
|
options: { source: { youtube: 'video' } } & SearchOptions
|
||||||
|
): Promise<YouTubeVideo[]>;
|
||||||
|
export async function search(query: string, options: { limit: number } & SearchOptions): Promise<YouTubeVideo[]>;
|
||||||
|
export async function search(query: string, options?: SearchOptions): Promise<YouTubeVideo[]>;
|
||||||
/**
|
/**
|
||||||
* Main Search Command for searching through various sources
|
* Main Search Command for searching through various sources
|
||||||
* @param query string to search.
|
* @param query string to search.
|
||||||
@ -90,20 +165,6 @@ export async function stream(url: string, options: StreamOptions = {}): Promise<
|
|||||||
* @returns Array of YouTube or Spotify or SoundCloud or Deezer
|
* @returns Array of YouTube or Spotify or SoundCloud or Deezer
|
||||||
deezer?: 'track' | 'playlist' | 'album';
|
deezer?: 'track' | 'playlist' | 'album';
|
||||||
*/
|
*/
|
||||||
export async function search( query: string, options: { source : { deezer : "album" } } & SearchOptions) : Promise<DeezerAlbum[]>;
|
|
||||||
export async function search( query: string, options: { source : { deezer : "playlist" } } & SearchOptions) : Promise<DeezerPlaylist[]>;
|
|
||||||
export async function search( query: string, options: { source : { deezer : "track" } } & SearchOptions) : Promise<DeezerTrack[]>;
|
|
||||||
export async function search( query: string, options: { source : { soundcloud : "albums" } } & SearchOptions) : Promise<SoundCloudPlaylist[]>;
|
|
||||||
export async function search( query: string, options: { source : { soundcloud : "playlists" } } & SearchOptions) : Promise<SoundCloudPlaylist[]>;
|
|
||||||
export async function search( query: string, options: { source : { soundcloud : "tracks" } } & SearchOptions) : Promise<SoundCloudTrack[]>;
|
|
||||||
export async function search( query: string, options: { source : { spotify : "album" } } & SearchOptions) : Promise<SpotifyAlbum[]>;
|
|
||||||
export async function search( query: string, options: { source : { spotify : "playlist" } } & SearchOptions) : Promise<SpotifyPlaylist[]>;
|
|
||||||
export async function search( query: string, options: { source : { spotify : "track" } } & SearchOptions) : Promise<SpotifyTrack[]>;
|
|
||||||
export async function search( query: string, options: { source : { youtube : "channel" } } & SearchOptions) : Promise<YouTubeChannel[]>;
|
|
||||||
export async function search( query: string, options: { source : { youtube : "playlist" } } & SearchOptions) : Promise<YouTubePlayList[]>;
|
|
||||||
export async function search( query: string, options: { source : { youtube : "video" } } & SearchOptions) : Promise<YouTubeVideo[]>;
|
|
||||||
export async function search( query: string, options: { limit : number } & SearchOptions ) : Promise<YouTubeVideo[]>;
|
|
||||||
export async function search( query: string, options? : SearchOptions) : Promise<YouTubeVideo[]>;
|
|
||||||
export async function search(
|
export async function search(
|
||||||
query: string,
|
query: string,
|
||||||
options: SearchOptions = {}
|
options: SearchOptions = {}
|
||||||
@ -114,7 +175,7 @@ export async function search(
|
|||||||
else if (options.source.spotify) return await sp_search(query, options.source.spotify, options.limit);
|
else if (options.source.spotify) return await sp_search(query, options.source.spotify, options.limit);
|
||||||
else if (options.source.soundcloud) return await so_search(query, options.source.soundcloud, options.limit);
|
else if (options.source.soundcloud) return await so_search(query, options.source.soundcloud, options.limit);
|
||||||
else if (options.source.deezer)
|
else if (options.source.deezer)
|
||||||
return await dz_search(query, { limit: options.limit, type: options.source.deezer, fuzzy : options.fuzzy });
|
return await dz_search(query, { limit: options.limit, type: options.source.deezer, fuzzy: options.fuzzy });
|
||||||
else throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.');
|
else throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,14 +17,14 @@ interface tokenOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets
|
* Sets
|
||||||
*
|
*
|
||||||
* i> YouTube :- cookies.
|
* i> YouTube :- cookies.
|
||||||
*
|
*
|
||||||
* ii> SoundCloud :- client ID.
|
* ii> SoundCloud :- client ID.
|
||||||
*
|
*
|
||||||
* iii> Spotify :- client ID, client secret, refresh token, market.
|
* iii> Spotify :- client ID, client secret, refresh token, market.
|
||||||
*
|
*
|
||||||
* locally in memory.
|
* locally in memory.
|
||||||
* @param options {@link tokenOptions}
|
* @param options {@link tokenOptions}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user