Backend stuff in mb & importer to use the new IncludeExtras & Extras format

This commit is contained in:
rembo10
2012-08-19 13:28:50 +05:30
parent 2cc9685877
commit d1b5d2a960
2 changed files with 22 additions and 9 deletions

View File

@@ -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']:

View File

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