Rafiuth/Soggfy

Duplicate song in playlist not exported

DadiBit opened this issue · 0 comments

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.