mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 11:19:18 +01:00
Scrobble radio streams even if we don't know the length of each individual part. Fixes issue 681
This commit is contained in:
parent
f7e614684d
commit
12b6bbd166
@ -1056,7 +1056,12 @@ void Song::ToLastFM(lastfm::Track* track) const {
|
||||
mtrack.setTitle(d->title_);
|
||||
mtrack.setDuration(length_nanosec() / kNsecPerSec);
|
||||
mtrack.setTrackNumber(d->track_);
|
||||
mtrack.setSource(lastfm::Track::Player);
|
||||
|
||||
if (d->filetype_ == Type_Stream && d->end_ == -1) {
|
||||
mtrack.setSource(lastfm::Track::NonPersonalisedBroadcast);
|
||||
} else {
|
||||
mtrack.setSource(lastfm::Track::Player);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_LIBLASTFM
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <lastfm/misc.h>
|
||||
#include <lastfm/RadioStation>
|
||||
#include <lastfm/Scrobble>
|
||||
#include <lastfm/ScrobblePoint>
|
||||
#include <lastfm/ws.h>
|
||||
#include <lastfm/XmlQuery>
|
||||
|
||||
@ -467,6 +468,24 @@ void LastFMService::NowPlaying(const Song &song) {
|
||||
if (!InitScrobbler())
|
||||
return;
|
||||
|
||||
// Scrobbling streams is difficult if we don't have length of each individual
|
||||
// part. In Song::ToLastFm we set the Track's source to
|
||||
// NonPersonalisedBroadcast if it's such a stream, so we have to scrobble it
|
||||
// when we change to a different track, but only if enough time has elapsed
|
||||
// since it started playing.
|
||||
if (!last_track_.isNull() &&
|
||||
last_track_.source() == lastfm::Track::NonPersonalisedBroadcast) {
|
||||
const int duration_secs = last_track_.timestamp().secsTo(QDateTime::currentDateTime());
|
||||
if (duration_secs >= ScrobblePoint::kScrobbleMinLength) {
|
||||
lastfm::MutableTrack mtrack(last_track_);
|
||||
mtrack.setDuration(duration_secs);
|
||||
|
||||
qDebug() << "Scrobbling stream track" << mtrack.title() << "length" << duration_secs;
|
||||
scrobbler_->cache(mtrack);
|
||||
scrobbler_->submit();
|
||||
}
|
||||
}
|
||||
|
||||
lastfm::MutableTrack mtrack(TrackFromSong(song));
|
||||
mtrack.stamp();
|
||||
last_track_ = mtrack;
|
||||
|
Loading…
Reference in New Issue
Block a user