diff --git a/headphones/helpers.py b/headphones/helpers.py index 5b103cb1..cfd69872 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -402,11 +402,11 @@ def extract_metadata(f): albums = new_albums # All files have the same metadata, so it's trivial - if len(artists) == 1 and len(albums) == 1 and len(years) == 1: + if len(artists) == 1 and len(albums) == 1: return (artists[0], albums[0], years[0]) # (Lots of) different artists. Could be a featuring album, so test for this. - if len(artists) > 1 and len(albums) == 1 and len(years) == 1: + if len(artists) > 1 and len(albums) == 1: split_artists = [ RE_FEATURING.split(artist) for artist in artists ] featurings = [ len(split_artist) - 1 for split_artist in split_artists ] logger.info("Album seem to feature %d different artists" % sum(featurings)) diff --git a/headphones/lastfm.py b/headphones/lastfm.py index 4ea83280..9f12601c 100644 --- a/headphones/lastfm.py +++ b/headphones/lastfm.py @@ -62,13 +62,17 @@ def getSimilar(): for result in results[:12]: data = request_lastfm("artist.getsimilar", mbid=result['ArtistId']) + time.sleep(10) if data and "similarartists" in data: artists = data["similarartists"]["artist"] for artist in artists: - artist_mbid = artist["mbid"] - artist_name = artist["name"] + try: + artist_mbid = artist["mbid"] + artist_name = artist["name"] + except TypeError: + continue if not any(artist_mbid in x for x in results): artistlist.append((artist_name, artist_mbid)) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index dbd54698..73131944 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -19,7 +19,7 @@ import glob from beets.mediafile import MediaFile import headphones -from headphones import db, logger, helpers, importer +from headphones import db, logger, helpers, importer, lastfm # You can scan a single directory and append it to the current library by specifying append=True, ArtistID & ArtistName def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=False): @@ -329,6 +329,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [havetracks, ArtistID]) update_album_status() + lastfm.getSimilar() logger.info('Library scan complete') #ADDED THIS SECTION TO MARK ALBUMS AS DOWNLOADED IF ARTISTS ARE ADDED EN MASSE BEFORE LIBRARY IS SCANNED diff --git a/headphones/lyrics.py b/headphones/lyrics.py index c3e35f57..aa3c952a 100644 --- a/headphones/lyrics.py +++ b/headphones/lyrics.py @@ -26,7 +26,7 @@ def getLyrics(artist, song): } url = 'http://lyrics.wikia.com/api.php' - data = request.request_minidom(url, params) + data = request.request_minidom(url, params=params) if not data: return @@ -42,7 +42,7 @@ def getLyrics(artist, song): lyricspage = request.request_content(lyricsurl) if not lyricspage: - logger.warn('Error fetching lyrics from: %s. Error: %s' % (lyricsurl, e)) + logger.warn('Error fetching lyrics from: %s' % lyricsurl) return m = re.compile('''
.*?
(.*?)