QobuzRequest: Handle multiple discs in integration

Albums with multiple discs are not being handled which results in tracks
being listed out of order. If the disc (media_number) is present in
JSON, we use it to set the disc in the Song object.
This commit is contained in:
Gaganpreet Arora 2023-03-28 21:18:09 +02:00 committed by Jonas Kvinge
parent af1c46543b
commit c1d0702b4d
1 changed files with 6 additions and 0 deletions

View File

@ -1079,12 +1079,17 @@ void QobuzRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
QString title = json_obj["title"].toString();
int track = json_obj["track_number"].toInt();
int disc = 0;
QString copyright = json_obj["copyright"].toString();
qint64 duration = json_obj["duration"].toInt() * kNsecPerSec;
//bool streamable = json_obj["streamable"].toBool();
QString composer;
QString performer;
if (json_obj.contains("media_number")) {
disc = json_obj["media_number"].toInt();
}
Artist song_artist = album_artist;
Album song_album = album;
if (json_obj.contains("album")) {
@ -1193,6 +1198,7 @@ void QobuzRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
song.set_artist_id(song_artist.artist_id);
song.set_album(song_album.album);
song.set_artist(song_artist.artist);
song.set_disc(disc);
if (!album_artist.artist.isEmpty() && album_artist.artist != song_artist.artist) {
song.set_albumartist(album_artist.artist);
}