From ac55b2283944b9e907fcd47dfb58ed706fb94a7a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 25 Apr 2020 01:15:23 +0200 Subject: [PATCH] Fix scrobble duration --- src/scrobbler/listenbrainzscrobbler.cpp | 4 +++- src/scrobbler/scrobblingapi20.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/scrobbler/listenbrainzscrobbler.cpp b/src/scrobbler/listenbrainzscrobbler.cpp index 9d27c0416..7c7ece248 100644 --- a/src/scrobbler/listenbrainzscrobbler.cpp +++ b/src/scrobbler/listenbrainzscrobbler.cpp @@ -568,7 +568,9 @@ void ListenBrainzScrobbler::CheckScrobblePrevSong() { quint64 duration = QDateTime::currentDateTime().toTime_t() - timestamp_; if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.source() == Song::Source_Stream && duration > 30) { - Scrobble(song_playing_); + Song song(song_playing_); + song.set_length_nanosec(duration * kNsecPerSec); + Scrobble(song); } } diff --git a/src/scrobbler/scrobblingapi20.cpp b/src/scrobbler/scrobblingapi20.cpp index 4db37aae1..3bb2daace 100644 --- a/src/scrobbler/scrobblingapi20.cpp +++ b/src/scrobbler/scrobblingapi20.cpp @@ -995,10 +995,12 @@ QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const { void ScrobblingAPI20::CheckScrobblePrevSong() { - quint64 time = QDateTime::currentDateTime().toTime_t() - timestamp_; + quint64 duration = QDateTime::currentDateTime().toTime_t() - timestamp_; - if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.source() == Song::Source_Stream && time > 30) { - Scrobble(song_playing_); + if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.source() == Song::Source_Stream && duration > 30) { + Song song(song_playing_); + song.set_length_nanosec(duration * kNsecPerSec); + Scrobble(song); } }