From 3a73553aac2b78c2be74cec69b54d38b25e33fe1 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Fri, 15 Jul 2022 15:34:43 +0300 Subject: [PATCH] Send more information to ListenBrainz - Track duration and number. - Player name and version. --- src/scrobbler/listenbrainzscrobbler.cpp | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/scrobbler/listenbrainzscrobbler.cpp b/src/scrobbler/listenbrainzscrobbler.cpp index 908d0ed24..ea6499b41 100644 --- a/src/scrobbler/listenbrainzscrobbler.cpp +++ b/src/scrobbler/listenbrainzscrobbler.cpp @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -447,6 +448,19 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) { object_track_metadata.insert("track_name", QJsonValue::fromVariant(title)); + QJsonObject object_additional_info; + + object_additional_info.insert("duration_ms", song.length_nanosec() / kNsecPerMsec); + + if (const int track = song.track(); track > 0) { + object_additional_info.insert("tracknumber", track); + } + + object_additional_info.insert("submission_client", QCoreApplication::applicationName()); + object_additional_info.insert("submission_client_version", QCoreApplication::applicationVersion()); + + object_track_metadata.insert("additional_info", object_additional_info); + QJsonObject object_listen; object_listen.insert("track_metadata", object_track_metadata); @@ -569,6 +583,19 @@ void ListenBrainzScrobbler::Submit() { object_track_metadata.insert("release_name", QJsonValue::fromVariant(item->album_)); } + QJsonObject object_additional_info; + + object_additional_info.insert("duration_ms", item->duration_ / kNsecPerMsec); + + if (item->track_ > 0) { + object_additional_info.insert("tracknumber", item->track_); + } + + object_additional_info.insert("submission_client", QCoreApplication::applicationName()); + object_additional_info.insert("submission_client_version", QCoreApplication::applicationVersion()); + + object_track_metadata.insert("additional_info", object_additional_info); + object_track_metadata.insert("track_name", QJsonValue::fromVariant(item->song_)); object_listen.insert("track_metadata", object_track_metadata); array.append(QJsonValue::fromVariant(object_listen));