Subsonic: Read created from album too

Fixes #526
This commit is contained in:
Jonas Kvinge
2020-10-11 00:05:06 +02:00
parent eb43a812d6
commit 7afeabd288
2 changed files with 11 additions and 3 deletions

View File

@@ -442,6 +442,11 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
}
QJsonArray array_songs = json_song.toArray();
qint64 created = 0;
if (obj_album.contains("created")) {
created = QDateTime::fromString(obj_album["created"].toString(), Qt::ISODate).toSecsSinceEpoch();
}
bool compilation = false;
bool multidisc = false;
SongList songs;
@@ -456,7 +461,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
++songs_received;
Song song(Song::Source_Subsonic);
ParseSong(song, obj_song, artist_id, album_id, album_artist);
ParseSong(song, obj_song, artist_id, album_id, album_artist, created);
if (!song.is_valid()) continue;
if (song.disc() >= 2) multidisc = true;
if (song.is_compilation()) compilation = true;
@@ -497,7 +502,7 @@ void SubsonicRequest::SongsFinishCheck() {
}
QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, const QString &artist_id_requested, const QString &album_id_requested, const QString &album_artist) {
QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, const QString &artist_id_requested, const QString &album_id_requested, const QString &album_artist, qint64 album_created) {
Q_UNUSED(artist_id_requested);
Q_UNUSED(album_id_requested);
@@ -631,6 +636,9 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons
if (json_obj.contains("created")) {
created = QDateTime::fromString(json_obj["created"].toString(), Qt::ISODate).toSecsSinceEpoch();
}
else {
created = album_created;
}
QUrl url;
url.setScheme(url_handler_->scheme());

View File

@@ -100,7 +100,7 @@ class SubsonicRequest : public SubsonicBaseRequest {
void AddAlbumSongsRequest(const QString &artist_id, const QString &album_id, const QString &album_artist, const int offset = 0);
void FlushAlbumSongsRequests();
QString ParseSong(Song &song, const QJsonObject &json_obj, const QString &artist_id_requested = QString(), const QString &album_id_requested = QString(), const QString &album_artist = QString());
QString ParseSong(Song &song, const QJsonObject &json_obj, const QString &artist_id_requested = QString(), const QString &album_id_requested = QString(), const QString &album_artist = QString(), qint64 album_created = 0);
void GetAlbumCovers();
void AddAlbumCoverRequest(Song &song);