Scrobble a track again if it's loved after it's scrobbled

This commit is contained in:
David Sansome 2011-04-16 15:27:41 +00:00
parent 343b6d6c3a
commit 9030c5a49e
2 changed files with 11 additions and 0 deletions

View File

@ -64,6 +64,7 @@ const char* LastFMService::kTitleCustom = QT_TR_NOOP("Last.fm Custom Radio: %1")
LastFMService::LastFMService(RadioModel* parent) LastFMService::LastFMService(RadioModel* parent)
: RadioService(kServiceName, parent), : RadioService(kServiceName, parent),
scrobbler_(NULL), scrobbler_(NULL),
already_scrobbled_(false),
station_dialog_(new LastFMStationDialog), station_dialog_(new LastFMStationDialog),
context_menu_(new QMenu), context_menu_(new QMenu),
initial_tune_(false), initial_tune_(false),
@ -365,6 +366,7 @@ PlaylistItem::SpecialLoadResult LastFMService::LoadNext(const QUrl&) {
lastfm::MutableTrack track = playlist_.dequeue(); lastfm::MutableTrack track = playlist_.dequeue();
track.stamp(); track.stamp();
already_scrobbled_ = false;
last_track_ = track; last_track_ = track;
if (playlist_.empty()) { if (playlist_.empty()) {
FetchMoreTracks(); FetchMoreTracks();
@ -490,6 +492,7 @@ void LastFMService::NowPlaying(const Song &song) {
lastfm::MutableTrack mtrack(TrackFromSong(song)); lastfm::MutableTrack mtrack(TrackFromSong(song));
mtrack.stamp(); mtrack.stamp();
already_scrobbled_ = false;
last_track_ = mtrack; last_track_ = mtrack;
//check immediately if the song is valid //check immediately if the song is valid
@ -510,6 +513,7 @@ void LastFMService::Scrobble() {
scrobbler_->cache(last_track_); scrobbler_->cache(last_track_);
scrobbler_->submit(); scrobbler_->submit();
already_scrobbled_ = true;
} }
void LastFMService::Love() { void LastFMService::Love() {
@ -519,6 +523,12 @@ void LastFMService::Love() {
lastfm::MutableTrack mtrack(last_track_); lastfm::MutableTrack mtrack(last_track_);
mtrack.love(); mtrack.love();
last_track_ = mtrack; last_track_ = mtrack;
if (already_scrobbled_) {
// The love only takes effect when the song is scrobbled, but we've already
// scrobbled this one so we have to do it again.
Scrobble();
}
} }
void LastFMService::Ban() { void LastFMService::Ban() {

View File

@ -177,6 +177,7 @@ class LastFMService : public RadioService {
lastfm::Track last_track_; lastfm::Track last_track_;
lastfm::Track next_metadata_; lastfm::Track next_metadata_;
QQueue<lastfm::Track> playlist_; QQueue<lastfm::Track> playlist_;
bool already_scrobbled_;
boost::scoped_ptr<LastFMStationDialog> station_dialog_; boost::scoped_ptr<LastFMStationDialog> station_dialog_;