Skip to content

Commit cbb67a9

Browse files
fixed iteration of spotify playlist
1 parent 36a1c60 commit cbb67a9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/methods/spotifyHandlers.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,29 @@ export async function spotifyPlaylistHandler(
9191
);
9292
}
9393

94-
do {
94+
let offset = playlist.tracks.offset;
95+
while (offset < playlist.tracks.total) {
9596
await replyWithMutlipleSongs(ctx, playlist.tracks, {
9697
disable_notification: true,
9798
});
99+
offset += playlist.tracks.limit;
98100
if (playlist.tracks.next) {
99101
playlist.tracks = await spotify.playlists.getPlaylistItems(
100102
playlist.id,
101103
undefined,
102104
undefined,
103105
playlist.tracks.limit as 50 | undefined,
104-
playlist.tracks.offset + playlist.tracks.limit
106+
offset
105107
);
106108
}
107-
} while (playlist.tracks.next);
109+
}
108110
await ctx.reply(`🎵 ${playlist.name} playlist downloaded`);
109111
} else {
110112
const reply_markup = {
111113
inline_keyboard: [
112114
[
113115
{
114-
text: `Download ${playlist.tracks.items.length} songs`,
116+
text: `Download ${playlist.tracks.total} songs`,
115117
callback_data: `spotify----${playlist.id}----playlist-dl`,
116118
},
117119
],

0 commit comments

Comments
 (0)