diff --git a/headphones/importer.py b/headphones/importer.py index ecf74a1f..a186f304 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -116,9 +116,13 @@ def addArtisttoDB(artistid, extrasonly=False): # Don't replace a known artist name with an "Artist ID" placeholder dbartist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [artistid]).fetchone() - if dbartist is None: + + # Only modify the Include Extras stuff if it's a new artist. We need it early so we know what to fetch + if not dbartist: newValueDict = {"ArtistName": "Artist ID: %s" % (artistid), - "Status": "Loading"} + "Status": "Loading", + "IncludeExtras": headphones.INCLUDE_EXTRAS, + "Extras": headphones.EXTRAS } else: newValueDict = {"Status": "Loading"} @@ -149,9 +153,6 @@ def addArtisttoDB(artistid, extrasonly=False): "DateAdded": helpers.today(), "Status": "Loading"} - if headphones.INCLUDE_EXTRAS: - newValueDict['IncludeExtras'] = 1 - myDB.upsert("artists", newValueDict, controlValueDict) for rg in artist['releasegroups']: diff --git a/headphones/mb.py b/headphones/mb.py index 5f9d168d..83767d84 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -229,16 +229,28 @@ def getArtist(artistid, extrasonly=False): 'type': unicode(rg['type']) }) - # See if we need to grab extras + # See if we need to grab extras. Artist specific extras take precedence over global option myDB = db.DBConnection() try: - includeExtras = myDB.select('SELECT IncludeExtras from artists WHERE ArtistID=?', [artistid])[0][0] + db_artist = myDB.select('SELECT IncludeExtras, Extras from artists WHERE ArtistID=?', [artistid]).fetchone() + includeExtras = db_artist['IncludeExtras'] except IndexError: includeExtras = False - if includeExtras or headphones.INCLUDE_EXTRAS: - includes = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"] + if includeExtras: + + # Need to convert extras string from something like '2,5.6' to ['ep','live','remix'] + extras = db_artist['Extras'] + extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"] + includes = [] + + i = 1 + for extra in extras_list: + if str(i) in extras: + includes.append(extra) + i += 1 + for include in includes: artist = None