Add error checking to importer, so we don't mark an artist as being updated if not all albums were added/refreshed

This commit is contained in:
rembo10
2012-08-20 22:37:37 +05:30
parent bbf74a544d
commit 2f8abf7dca

View File

@@ -103,6 +103,9 @@ def addArtisttoDB(artistid, extrasonly=False):
logger.warn('Cannot import Various Artists.')
return
# We'll use this to see if we should update the 'LastUpdated' time stamp
errors = False
myDB = db.DBConnection()
# Delete from blacklist if it's on there
@@ -171,6 +174,7 @@ def addArtisttoDB(artistid, extrasonly=False):
continue
if not releaselist:
errors = True
continue
# This will be used later to build a hybrid release
@@ -186,10 +190,12 @@ def addArtisttoDB(artistid, extrasonly=False):
try:
releasedict = mb.getRelease(releaseid, include_artist_info=False)
except Exception, e:
errors = True
logger.info('Unable to get release information for %s: %s' % (release['id'], e))
continue
if not releasedict:
errors = True
continue
controlValueDict = {"ReleaseID": release['id']}
@@ -412,14 +418,18 @@ def addArtisttoDB(artistid, extrasonly=False):
"TotalTracks": totaltracks,
"HaveTracks": havetracks}
newValueDict['LastUpdated'] = helpers.now()
if not errors:
newValueDict['LastUpdated'] = helpers.now()
myDB.upsert("artists", newValueDict, controlValueDict)
logger.info(u"Seeing if we need album art for: " + artist['artist_name'])
cache.getThumb(ArtistID=artistid)
logger.info(u"Updating complete for: " + artist['artist_name'])
if errors:
logger.info("Finished updating artist: " + artist['artist_name'] + " but with errors, so not marking it as updated in the database")
else:
logger.info(u"Updating complete for: " + artist['artist_name'])
def addReleaseById(rid):