Added a last catchall by assuming the folder name == album name (pretty common)

This commit is contained in:
rembo10
2014-04-06 13:14:11 -07:00
parent 686ea47449
commit cd3cc7c811
2 changed files with 27 additions and 1 deletions

View File

@@ -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)))

View File

@@ -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)