Added property to get all tracks in playlist, album

This commit is contained in:
killer069
2022-01-03 15:02:52 +05:30
parent 2e1476745d
commit 433ec4976b
4 changed files with 93 additions and 49 deletions

View File

@@ -491,6 +491,21 @@ export class DeezerAlbum {
return this;
}
/**
* Fetches all the tracks in the album and returns them
*
* ```ts
* const album = await play.deezer('album url')
*
* const tracks = await album.all_tracks()
* ```
* @returns An array of {@link DeezerTrack}
*/
async all_tracks(): Promise<DeezerTrack[]> {
await this.fetch()
return this.tracks as DeezerTrack[]
}
/**
* Converts instances of this class to JSON data
* @returns JSON data.
@@ -746,6 +761,21 @@ export class DeezerPlaylist {
return this;
}
/**
* Fetches all the tracks in the playlist and returns them
*
* ```ts
* const playlist = await play.deezer('playlist url')
*
* const tracks = await playlist.all_tracks()
* ```
* @returns An array of {@link DeezerTrack}
*/
async all_tracks(): Promise<DeezerTrack[]> {
await this.fetch()
return this.tracks as DeezerTrack[]
}
/**
* Converts instances of this class to JSON data
* @returns JSON data.