From 490b4bc90952436656d3adba24b403407a755d63 Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Fri, 14 Sep 2012 11:40:02 +0200 Subject: [PATCH] Ignore bootlegs and similar that have their release group type set to "Album". Fixes Issue #536 --- headphones/importer.py | 15 ++++++++++++++- headphones/mb.py | 7 ++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 98e3c46e..54d88399 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -158,6 +158,16 @@ def addArtisttoDB(artistid, extrasonly=False): myDB.upsert("artists", newValueDict, controlValueDict) + # See if we need to grab extras. Artist specific extras take precedence over global option + # Global options are set when adding a new artist + myDB = db.DBConnection() + + try: + db_artist = myDB.action('SELECT IncludeExtras, Extras from artists WHERE ArtistID=?', [artistid]).fetchone() + includeExtras = db_artist['IncludeExtras'] + except IndexError: + includeExtras = False + for rg in artist['releasegroups']: logger.info("Now adding/updating: " + rg['title']) @@ -167,7 +177,10 @@ def addArtisttoDB(artistid, extrasonly=False): # check if the album already exists rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() - releases = mb.get_all_releases(rgid) + releases = mb.get_all_releases(rgid,includeExtras) + if releases == []: + logger.info('No official releases in release group %s' % rg['title']) + continue if not releases: errors = True logger.info('Unable to get release information for %s - there may not be any official releases in this release group' % rg['title']) diff --git a/headphones/mb.py b/headphones/mb.py index 4dc15956..8dbcc5e8 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -329,7 +329,7 @@ def getRelease(releaseid, include_artist_info=True): return release -def get_all_releases(rgid): +def get_all_releases(rgid,includeExtras=False): results = [] try: limit = 100 @@ -352,6 +352,11 @@ def get_all_releases(rgid): releases = [] for releasedata in results: + #releasedata.get will return None if it doesn't have a status + #all official releases should have the Official status included + if not includeExtras and releasedata.get('status') != 'Official': + continue + release = {} release['AlbumTitle'] = unicode(releasedata['title']) release['AlbumID'] = unicode(rgid)