From cd3cc7c8110d5f6ee6cd77168555b2466226f725 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 6 Apr 2014 13:14:11 -0700 Subject: [PATCH] Added a last catchall by assuming the folder name == album name (pretty common) --- headphones/mb.py | 5 ++++- headphones/postprocessor.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/headphones/mb.py b/headphones/mb.py index b45dcfe1..cdcc999a 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -566,7 +566,10 @@ def findAlbumID(artist=None, album=None): results = None try: - term = '"'+album+'" AND artist:"'+artist+'"' + if album and artist: + term = '"'+album+'" AND artist:"'+artist+'"' + else: + term = album results = musicbrainzngs.search_release_groups(term,1).get('release-group-list') except WebServiceError, e: logger.warn('Attempt to query MusicBrainz for %s - %s failed (%s)' % (artist, album, str(e))) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 1129ce5b..90d55ea7 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -1090,3 +1090,26 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None): logger.info('Found a (possibly) valid Musicbrainz identifier in album folder name - continuing post-processing') verify(rgid, folder, forced=True) continue + + # Attempt 4: Hail mary. Just assume the folder name is the album name if it doesn't have a separator in it + if '-' not in folder: + release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE AlbumTitle LIKE ?', [folder]).fetchone() + if release: + logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle']) + verify(release['AlbumID'], folder) + continue + else: + logger.info('Querying MusicBrainz for the release group id for: %s', folder) + from headphones import mb + try: + rgid = mb.findAlbumID(album=helpers.latinToAscii(folder)) + except: + logger.error('Can not get release information for this album') + rgid = None + + if rgid: + verify(rgid, folder) + continue + else: + logger.info('No match found on MusicBrainz for: %s - %s', name, album) +