From 5e514c42b6d46c167b4ea8e6c5b1e5aeb75625cd Mon Sep 17 00:00:00 2001 From: David Sansome Date: Tue, 29 Dec 2009 20:11:03 +0000 Subject: [PATCH] Actually scrobble --- src/lastfmservice.cpp | 20 +++++++++++++------- src/lastfmservice.h | 6 +++--- src/mainwindow.cpp | 2 +- src/playlist.cpp | 4 ++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/lastfmservice.cpp b/src/lastfmservice.cpp index 04d5dbcfe..9277a07fc 100644 --- a/src/lastfmservice.cpp +++ b/src/lastfmservice.cpp @@ -265,22 +265,28 @@ void LastFMService::NowPlaying(const Song &song) { if (!InitScrobbler()) return; - scrobbler_->nowPlaying(TrackFromSong(song)); + last_track_ = TrackFromSong(song); + + lastfm::MutableTrack mtrack(last_track_); + mtrack.stamp(); + + scrobbler_->nowPlaying(last_track_); } -void LastFMService::Scrobble(const Song& song) { +void LastFMService::Scrobble() { if (!InitScrobbler()) return; - scrobbler_->cache(TrackFromSong(song)); + scrobbler_->cache(last_track_); + scrobbler_->submit(); } -void LastFMService::Love(const Song& song) { - lastfm::MutableTrack mtrack(TrackFromSong(song)); +void LastFMService::Love() { + lastfm::MutableTrack mtrack(last_track_); mtrack.love(); } -void LastFMService::Ban(const Song& song) { - lastfm::MutableTrack mtrack(TrackFromSong(song)); +void LastFMService::Ban() { + lastfm::MutableTrack mtrack(last_track_); mtrack.ban(); } diff --git a/src/lastfmservice.h b/src/lastfmservice.h index 71a4fdffb..b0fc95e35 100644 --- a/src/lastfmservice.h +++ b/src/lastfmservice.h @@ -41,9 +41,9 @@ class LastFMService : public RadioService { void Authenticate(const QString& username, const QString& password); void NowPlaying(const Song& song); - void Scrobble(const Song& song); - void Love(const Song& song); - void Ban(const Song& song); + void Scrobble(); + void Love(); + void Ban(); signals: void AuthenticationComplete(bool success); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0ad497858..d4279f426 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -342,7 +342,7 @@ void MainWindow::UpdateTrackPosition() { if (!playlist_->has_scrobbled() && position >= playlist_->scrobble_point()) { - radio_model_->GetLastFMService()->Scrobble(playlist_->current_item_metadata()); + radio_model_->GetLastFMService()->Scrobble(); playlist_->set_scrobbled(true); } } diff --git a/src/playlist.cpp b/src/playlist.cpp index 774e14b6a..8588d0c0b 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -21,9 +21,9 @@ const char* Playlist::kSettingsGroup = "Playlist"; Playlist::Playlist(QObject *parent) : QAbstractListModel(parent), current_is_paused_(false), - ignore_sorting_(false), scrobble_point_(-1), - has_scrobbled_(false) + has_scrobbled_(false), + ignore_sorting_(false) { }