Hi, I've been playing with the Rockbox scrobble support to try and get avoid wasting all the time with manually marking things as played. I noticed it had a few problems with entries missing the optional fields so I id the following patch. It doesn't fix everything but it makes it better.
-- Alex, homepage: http://www.bennee.com/~alex/ http://www.half-llama.co.uk
From a0bf42476a098d8f87a15cd2a94c2d93dfa6cb01 Mon Sep 17 00:00:00 2001 From: Alex Bennee <[email protected]> Date: Thu, 8 Oct 2009 17:20:46 +0100 Subject: [PATCH] Clean up the parsing of .scrobbler.log so it hits more often than it misses. * Split on \t instead of using regex. Some fields are optional and the regex got confused * Store album/track instead of artist/track which gets more "hits" This fixes up some of the problems I've been seeing however as the scrobbling device is working from the id3/tag information on the track in it's log we really should use tags for matching. --- src/gpodder/sync.py | 38 +++++++++++++++++++++++++++----------- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gpodder/sync.py b/src/gpodder/sync.py index e295c07..4c89d8c 100644 --- a/src/gpodder/sync.py +++ b/src/gpodder/sync.py @@ -561,10 +561,12 @@ class MP3PlayerDevice(Device): log('Cannot create folder on MP3 player: %s', folder, sender=self) return False - if (self._config.mp3_player_use_scrobbler_log and not episode.is_played - and [episode.channel.title, episode.title] in self.scrobbler_log): - log('Marking "%s" from "%s" as played', episode.title, episode.channel.title, sender=self) - episode.mark(is_played=True) + if self._config.mp3_player_use_scrobbler_log and not episode.is_played: + # FIXME: This misses some things when channel.title<>album tag which is what + # the scrobbling entity will be using. + if [episode.channel.title, episode.title] in self.scrobbler_log: + log('Marking "%s" from "%s" as played', episode.title, episode.channel.title, sender=self) + episode.mark(is_played=True) if self._config.rockbox_copy_coverart and not os.path.exists(os.path.join(folder, 'cover.bmp')): log('Creating Rockbox album art for "%s"', episode.channel.title, sender=self) @@ -733,14 +735,28 @@ class MP3PlayerDevice(Device): return False try: - # regex that can be used to get all the data from a scrobbler.log entry - entry_re = re.compile('^(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)$') + # Scrobble Log Format: http://www.audioscrobbler.net/wiki/Portable_Player_Logging + # Notably some fields are optional so will appear as \t\t. + # Conforming scrobblers should strip any \t's from the actual fields. for entry in entries: - match_obj = re.match(entry_re, entry) - # L means at least 50% of the track was listened to (S means < 50%) - if match_obj and match_obj.group(6).strip().lower() == 'l': - # append [artist_name, track_name] - self.scrobbler_log.append([match_obj.group(1), match_obj.group(3)]) + a = entry.split("\t") + if len(a)>6: + artist=a[0] + album=a[1] + track=a[2] + length=a[4] + rating=a[5].strip().lower() + # L means at least 50% of the track was listened to (S means < 50%) + if rating == 'l': + # Whatever is writing the logs will only have the taginfo in the + # file to work from. Mostly album~=channel name + if len(track): + self.scrobbler_log.append([album, track]) + else: + log('Skipping logging of %s (missing track)', album) + else: + log('Skipping scrobbler entry: %d elements %s', len(a), entry) + except: log('Error while parsing "%s".', log_file, sender=self) -- 1.6.4.4
_______________________________________________ gpodder-devel mailing list [email protected] https://lists.berlios.de/mailman/listinfo/gpodder-devel
