1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Only update a song's play count once if scrobbling is disabled. Fixes issue 1766

This commit is contained in:
David Sansome 2011-04-16 23:17:48 +00:00
parent 5ed1fcd5e1
commit 012eeee46a

View File

@ -1050,8 +1050,12 @@ void MainWindow::UpdateTrackPosition() {
if (RadioModel::Service<LastFMService>()->IsScrobblingEnabled()) { if (RadioModel::Service<LastFMService>()->IsScrobblingEnabled()) {
qDebug() << "Scrobbling at" << scrobble_point; qDebug() << "Scrobbling at" << scrobble_point;
radio_model_->RadioModel::Service<LastFMService>()->Scrobble(); radio_model_->RadioModel::Service<LastFMService>()->Scrobble();
} } else
#endif #endif
// If we're not scrobbling or last.fm is compiled out, mark the song
// as "won't scrobble", so we only update the play count below once.
playlists_->active()->set_lastfm_status(Playlist::LastFM_Invalid);
// Update the play count for the song if it's from the library // Update the play count for the song if it's from the library
if (item->IsLocalLibraryItem() && item->Metadata().id() != -1) { if (item->IsLocalLibraryItem() && item->Metadata().id() != -1) {
library_->backend()->IncrementPlayCountAsync(item->Metadata().id()); library_->backend()->IncrementPlayCountAsync(item->Metadata().id());
@ -2120,24 +2124,36 @@ void MainWindow::SetToggleScrobblingIcon(bool value) {
#ifdef HAVE_LIBLASTFM #ifdef HAVE_LIBLASTFM
void MainWindow::ScrobblerStatus(int value) { void MainWindow::ScrobblerStatus(int value) {
bool last_fm_enabled = ui_->action_toggle_scrobbling->isVisible() && RadioModel::Service<LastFMService>()->IsScrobblingEnabled() && RadioModel::Service<LastFMService>()->IsAuthenticated(); const LastFMService* lastfm_service = RadioModel::Service<LastFMService>();
const bool last_fm_enabled = ui_->action_toggle_scrobbling->isVisible() &&
lastfm_service->IsScrobblingEnabled() &&
lastfm_service->IsAuthenticated();
if (value == -1) { switch (value) {
//custom error value got from initial validity check case -1:
playlists_->active()->set_lastfm_status(Playlist::LastFM_Invalid); // custom error value got from initial validity check
} playlists_->active()->set_lastfm_status(Playlist::LastFM_Invalid);
//we should get 3 for a correct scrobbling, but I just get 2 for mysterious reasons break;
//seems to scrobble fine though, so for now we accept it as correct
if (value == 2 || value == 3) { case 2:
playlists_->active()->set_lastfm_status(Playlist::LastFM_Scrobbled); case 3:
//update the button icon // we should get 3 for a correct scrobbling, but I just get 2 for
if (last_fm_enabled) // mysterious reasons
ui_->action_toggle_scrobbling->setIcon(QIcon(":/last.fm/as.png")); // seems to scrobble fine though, so for now we accept it as correct
} playlists_->active()->set_lastfm_status(Playlist::LastFM_Scrobbled);
if (value > 3) {
//we're for sure in an error state // update the button icon
playlists_->active()->set_lastfm_status(Playlist::LastFM_Error); if (last_fm_enabled)
qWarning() << "Last.fm scrobbling error: " << value; ui_->action_toggle_scrobbling->setIcon(QIcon(":/last.fm/as.png"));
break;
default:
if (value > 3) {
// we're for sure in an error state
playlists_->active()->set_lastfm_status(Playlist::LastFM_Error);
qWarning() << "Last.fm scrobbling error: " << value;
}
break;
} }
} }
#endif #endif