diff --git a/headphones/importer.py b/headphones/importer.py index 15c3b5e7..11dc15d2 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -48,7 +48,12 @@ def scanMusic(dir=None): else: continue - myDB.action('INSERT INTO have VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)', [artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid]) + if not f.album: + album = None + else: + album = f.album + + myDB.action('INSERT INTO have VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)', [artist, album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid]) # Get the average bitrate if the option is selected if headphones.DETECT_BITRATE: diff --git a/headphones/mb.py b/headphones/mb.py index 53f87631..2646403b 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -400,7 +400,7 @@ def findArtistbyAlbum(name): myDB = db.DBConnection() - artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL', [name]).fetchone() + artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL ORDER BY RANDOM()', [name]).fetchone() if not artist: return False diff --git a/headphones/searcher.py b/headphones/searcher.py index c83f975d..42807109 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -437,17 +437,17 @@ def verifyresult(title, artistterm, term): title = re.sub('[\.\-\/\_]', ' ', title) - if artistterm != 'Various Artists': - - if not re.search('^' + re.escape(artistterm), title, re.IGNORECASE): - logger.info("Removed from results: " + title + " (artist not at string start).") - return False - elif re.search(re.escape(artistterm) + '\w', title, re.IGNORECASE | re.UNICODE): - logger.info("Removed from results: " + title + " (post substring result).") - return False - elif re.search('\w' + re.escape(artistterm), title, re.IGNORECASE | re.UNICODE): - logger.info("Removed from results: " + title + " (pre substring result).") - return False + #if artistterm != 'Various Artists': + # + # if not re.search('^' + re.escape(artistterm), title, re.IGNORECASE): + # #logger.info("Removed from results: " + title + " (artist not at string start).") + # #return False + # elif re.search(re.escape(artistterm) + '\w', title, re.IGNORECASE | re.UNICODE): + # logger.info("Removed from results: " + title + " (post substring result).") + # return False + # elif re.search('\w' + re.escape(artistterm), title, re.IGNORECASE | re.UNICODE): + # logger.info("Removed from results: " + title + " (pre substring result).") + # return False #another attempt to weed out substrings. We don't want "Vol III" when we were looking for "Vol II" tokens = re.split('\W', term, re.IGNORECASE | re.UNICODE)