From 1ed711fb85503bd73bbac9c8dde32541ea12c16f Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 24 Aug 2010 18:45:32 +0200 Subject: [PATCH] Do not scrobble if duration is <30s --- mopidy/frontends/lastfm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mopidy/frontends/lastfm.py b/mopidy/frontends/lastfm.py index 2f539a51..18f48cf2 100644 --- a/mopidy/frontends/lastfm.py +++ b/mopidy/frontends/lastfm.py @@ -105,12 +105,14 @@ class LastfmFrontendProcess(BaseProcess): logger.error(u'Last.fm now playing error: %s', e) def scrobble(self, track): + duration = track.length // 1000 artists = ', '.join([a.name for a in track.artists]) + if duration < 30: + logger.debug(u'Track too short to scrobble.') + return logger.debug(u'Scrobbling track: %s - %s', artists, track.name) # TODO Scrobble if >50% or >240s of a track has been played - # TODO Do not scrobble if duration <30s # FIXME Get actual time when track started playing - duration = track.length // 1000 time_started = int(time.time()) - duration try: self.scrobbler.scrobble(