[GH-ISSUE #74] Duplicate song in playlist not exported #67

Open
opened 2026-02-27 15:48:08 +03:00 by kerem · 0 comments
Owner

Originally created by @DadiBit on GitHub (Apr 8, 2023).
Original GitHub issue: https://github.com/Rafiuth/Soggfy/issues/74

If a playlist has the same song twice (e.g.: in 9th position and 14th position) the exported m3u8 playlist won't contain nor the first nor the second.
Looking at the exporting for loop:

for (let track of tracks) {
    let loc = statusResp.results[track.uri];
    if (!loc) continue;  // If the song is not downloaded do not export it
    
    data += `#EXTINF:${(track.durationMs / 1000).toFixed(0)},${track.vars.artist_name} - ${track.vars.track_name}\n`;
    data += `${loc.path.replaceAll('\\', '/')}\n\n`;
    numExported++;
}

So the issue is likely in the tracks array itself, walking up the stack of called functions we reach the getPlaylistTracks one:

static async getPlaylistTracks(uri: string, sorted = true) {
    let api = Platform.getPlaylistAPI();
    let metadata = await api.getMetadata(uri);

    let sortState = sorted ? SpotifyUtils.getPlaylistSortState(uri) : undefined;
    let contents = await api.getContents(uri, { sort: sortState }); // here something goes wrong

    return { ...metadata, tracks: contents };
}

Honestly, I couldn't debug further than this.

Originally created by @DadiBit on GitHub (Apr 8, 2023). Original GitHub issue: https://github.com/Rafiuth/Soggfy/issues/74 If a playlist has the same song twice (e.g.: in 9th position and 14th position) the exported m3u8 playlist won't contain nor the first nor the second. Looking at the [exporting for loop](https://github.com/Rafiuth/Soggfy/blob/a4aca17b4434e3040d1ed5c5c77e68243af041d4/Sprinkles/src/ui/ui.ts#L90-L97): ```typescript for (let track of tracks) { let loc = statusResp.results[track.uri]; if (!loc) continue; // If the song is not downloaded do not export it data += `#EXTINF:${(track.durationMs / 1000).toFixed(0)},${track.vars.artist_name} - ${track.vars.track_name}\n`; data += `${loc.path.replaceAll('\\', '/')}\n\n`; numExported++; } ``` So the issue is likely in the tracks array itself, walking up the stack of called functions we reach the [getPlaylistTracks one](https://github.com/Rafiuth/Soggfy/blob/a4aca17b4434e3040d1ed5c5c77e68243af041d4/Sprinkles/src/resources.ts#L23-L31): ```typescript static async getPlaylistTracks(uri: string, sorted = true) { let api = Platform.getPlaylistAPI(); let metadata = await api.getMetadata(uri); let sortState = sorted ? SpotifyUtils.getPlaylistSortState(uri) : undefined; let contents = await api.getContents(uri, { sort: sortState }); // here something goes wrong return { ...metadata, tracks: contents }; } ``` Honestly, I couldn't debug further than this.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Soggfy#67
No description provided.