mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-06 19:59:44 +01:00
Optimized a few scan functions.
This commit is contained in:
@@ -315,13 +315,14 @@ def update_album_status(AlbumID=None):
|
||||
album_completion = 0
|
||||
logger.info('Album %s does not have any tracks in database' % album['AlbumTitle'])
|
||||
|
||||
if album['Status'] == "Downloaded" or album['Status'] == "Skipped":
|
||||
if album_completion >= headphones.ALBUM_COMPLETION_PCT:
|
||||
new_album_status = "Downloaded"
|
||||
myDB.upsert("albums", {'Status' : "Downloaded"}, {'AlbumID' : album['AlbumID']})
|
||||
else:
|
||||
if album_completion >= headphones.ALBUM_COMPLETION_PCT:
|
||||
new_album_status = "Downloaded"
|
||||
else:
|
||||
if album['Status'] == "Skipped" or album['Status'] == "Downloaded":
|
||||
new_album_status = "Skipped"
|
||||
myDB.upsert("albums", {'Status' : "Skipped"}, {'AlbumID' : album['AlbumID']})
|
||||
if new_album_status != album['Status']:
|
||||
logger.info('Album %s changed to %s' % (album['AlbumTitle'], new_album_status))
|
||||
else:
|
||||
new_album_status = album['Status']
|
||||
myDB.upsert("albums", {'Status' : new_album_status}, {'AlbumID' : album['AlbumID']})
|
||||
if new_album_status != album['Status']:
|
||||
logger.info('Album %s changed to %s' % (album['AlbumTitle'], new_album_status))
|
||||
logger.info('Album status update complete')
|
||||
@@ -408,17 +408,18 @@ class WebInterface(object):
|
||||
match_alltracks = myDB.action('SELECT CleanName from alltracks WHERE CleanName=?', [new_clean_filename]).fetchone()
|
||||
if match_alltracks:
|
||||
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
||||
match_tracks = myDB.action('SELECT CleanName from tracks WHERE CleanName=?', [new_clean_filename]).fetchone()
|
||||
match_tracks = myDB.action('SELECT CleanName, AlbumID from tracks WHERE CleanName=?', [new_clean_filename]).fetchone()
|
||||
if match_tracks:
|
||||
myDB.upsert("tracks", newValueDict, controlValueDict)
|
||||
myDB.action('UPDATE have SET Matched="Manual" WHERE CleanName=?', [new_clean_filename])
|
||||
album_id = match_tracks['AlbumID']
|
||||
update_count+=1
|
||||
#This was throwing errors and I don't know why, but it seems to be working fine.
|
||||
#else:
|
||||
#logger.info("There was an error modifying Artist %s. This should not have happened" % existing_artist)
|
||||
logger.info("Manual matching yielded %s new matches for Artist %s" % (update_count, new_artist))
|
||||
if update_count > 0:
|
||||
librarysync.update_album_status()
|
||||
librarysync.update_album_status(album_id)
|
||||
else:
|
||||
logger.info("Artist %s already named appropriately; nothing to modify" % existing_artist)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user