From 2d49b71bc97a945162ea472bea79d28c167f563e Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Mon, 31 Aug 2020 17:05:09 +0200 Subject: [PATCH] Read song creation time from subsonic API Fixes #526 --- src/subsonic/subsonicrequest.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/subsonic/subsonicrequest.cpp b/src/subsonic/subsonicrequest.cpp index fed82f2f8..b82f371b7 100644 --- a/src/subsonic/subsonicrequest.cpp +++ b/src/subsonic/subsonicrequest.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -614,6 +615,11 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons } } + qint64 created = 0; + if (json_obj.contains("created")) { + created = QDateTime::fromString(json_obj["created"].toString(), Qt::ISODate).toSecsSinceEpoch(); + } + QUrl url; url.setScheme(url_handler_->scheme()); url.setPath(song_id); @@ -654,8 +660,8 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons song.set_directory_id(0); song.set_filetype(filetype); song.set_filesize(size); - song.set_mtime(0); - song.set_ctime(0); + song.set_mtime(created); + song.set_ctime(created); song.set_bitrate(bitrate); song.set_valid(true);