--- /home/tf/Downloads/coverlovin/coverlovin.py 2012-12-18 06:03:15.000000000 +0100 +++ coverlovin_last_patch.py 2013-04-02 22:12:05.557841660 +0200 @@ -10,7 +10,7 @@ import os, sys import urllib, urllib2 import simplejson -import id3reader +import mutagen import logging from optparse import OptionParser @@ -126,6 +126,8 @@ dirs = [] files = [] + artist = '' + album = '' # read directory contents if os.path.exists(thisDir): @@ -159,20 +161,20 @@ fileFullPath = os.path.join(thisDir, file) # check file for id3 tag info try: - id3r = id3reader.Reader(fileFullPath) + id3r = mutagen.File(fileFullPath, easy=True) + # get values and sanitise nulls + if 'artist' in id3r: + artist = id3r['artist'][0] + if 'album' in id3r: + album = id3r['album'][0] + # if either artist or album found, append to results and return + if artist or album: + log.info("album details found: %s/%s in %s" % (artist, album, file)) + results.append((thisDir, artist, album)) + return results except Exception, err: log.error('exception: ' + str(err)) continue - # get values and sanitise nulls - artist = id3r.getValue('performer') - album = id3r.getValue('album') - if artist == None: artist = '' - if album == None: album = '' - # if either artist or album found, append to results and return - if artist or album: - log.info("album details found: %s/%s in %s" % (artist, album, file)) - results.append((thisDir, artist, album)) - return results # no artist or album info found, return results unchanged return results