Merge pull request #97 from cjh980402/patch-1
Fix invalid parameter of fetched_tracks.get
This commit is contained in:
commit
23142402df
@ -163,7 +163,7 @@ export class SpotifyPlaylist {
|
|||||||
|
|
||||||
get total_tracks() {
|
get total_tracks() {
|
||||||
const page_number: number = this.total_pages;
|
const page_number: number = this.total_pages;
|
||||||
return (page_number - 1) * 100 + (this.fetched_tracks.get(`page${page_number}`) as SpotifyVideo[]).length;
|
return (page_number - 1) * 100 + (this.fetched_tracks.get(`${page_number}`) as SpotifyVideo[]).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
@ -267,7 +267,7 @@ export class SpotifyAlbum {
|
|||||||
|
|
||||||
get total_tracks() {
|
get total_tracks() {
|
||||||
const page_number: number = this.total_pages;
|
const page_number: number = this.total_pages;
|
||||||
return (page_number - 1) * 100 + (this.fetched_tracks.get(`page${page_number}`) as SpotifyVideo[]).length;
|
return (page_number - 1) * 100 + (this.fetched_tracks.get(`${page_number}`) as SpotifyVideo[]).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export class PlayList {
|
|||||||
this.thumbnail = data.thumbnail || undefined;
|
this.thumbnail = data.thumbnail || undefined;
|
||||||
this.videos = data.videos || [];
|
this.videos = data.videos || [];
|
||||||
this.__count++;
|
this.__count++;
|
||||||
this.fetched_videos.set(`page${this.__count}`, this.videos as Video[]);
|
this.fetched_videos.set(`${this.__count}`, this.videos as Video[]);
|
||||||
this._continuation.api = data.continuation?.api ?? undefined;
|
this._continuation.api = data.continuation?.api ?? undefined;
|
||||||
this._continuation.token = data.continuation?.token ?? undefined;
|
this._continuation.token = data.continuation?.token ?? undefined;
|
||||||
this._continuation.clientVersion = data.continuation?.clientVersion ?? '<important data>';
|
this._continuation.clientVersion = data.continuation?.clientVersion ?? '<important data>';
|
||||||
@ -89,7 +89,7 @@ export class PlayList {
|
|||||||
if (!contents) return [];
|
if (!contents) return [];
|
||||||
|
|
||||||
const playlist_videos = getPlaylistVideos(contents, limit);
|
const playlist_videos = getPlaylistVideos(contents, limit);
|
||||||
this.fetched_videos.set(`page${this.__count}`, playlist_videos);
|
this.fetched_videos.set(`${this.__count}`, playlist_videos);
|
||||||
this._continuation.token = getContinuationToken(contents);
|
this._continuation.token = getContinuationToken(contents);
|
||||||
return playlist_videos;
|
return playlist_videos;
|
||||||
}
|
}
|
||||||
@ -115,8 +115,8 @@ export class PlayList {
|
|||||||
|
|
||||||
page(number: number): Video[] {
|
page(number: number): Video[] {
|
||||||
if (!number) throw new Error('Page number is not provided');
|
if (!number) throw new Error('Page number is not provided');
|
||||||
if (!this.fetched_videos.has(`page${number}`)) throw new Error('Given Page number is invalid');
|
if (!this.fetched_videos.has(`${number}`)) throw new Error('Given Page number is invalid');
|
||||||
return this.fetched_videos.get(`page${number}`) as Video[];
|
return this.fetched_videos.get(`${number}`) as Video[];
|
||||||
}
|
}
|
||||||
|
|
||||||
get total_pages() {
|
get total_pages() {
|
||||||
@ -125,7 +125,7 @@ export class PlayList {
|
|||||||
|
|
||||||
get total_videos() {
|
get total_videos() {
|
||||||
const page_number: number = this.total_pages;
|
const page_number: number = this.total_pages;
|
||||||
return (page_number - 1) * 100 + (this.fetched_videos.get(`page${page_number}`) as Video[]).length;
|
return (page_number - 1) * 100 + (this.fetched_videos.get(`${page_number}`) as Video[]).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user