From e32cff60e597267afd31d13f7bbac32622c4b529 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 8 Jul 2015 22:26:55 -0700 Subject: [PATCH] Took out some unneccessary functions if we're just scanning an artist --- headphones/librarysync.py | 8 +++++--- headphones/webserve.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 2bdb8488..a5a58f57 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -23,7 +23,7 @@ from headphones import db, logger, helpers, importer, lastfm # You can scan a single directory and append it to the current library by # specifying append=True, ArtistID and ArtistName. def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, - cron=False): + cron=False, artistScan=False): if cron and not headphones.CONFIG.LIBRARYSCAN: return @@ -36,7 +36,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, # If we're appending a dir, it's coming from the post processor which is # already bytestring - if not append: + if not append or artistScan: dir = dir.encode(headphones.SYS_ENCODING) if not os.path.isdir(dir): @@ -287,7 +287,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, logger.info('Completed matching tracks from directory: %s' % dir.decode(headphones.SYS_ENCODING, 'replace')) - if not append: + if not append or artistScan: logger.info('Updating scanned artist track counts') # Clean up the new artist list @@ -346,6 +346,8 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, if not append: update_album_status() + + if not append or not scanArtist: lastfm.getSimilar() logger.info('Library scan complete') diff --git a/headphones/webserve.py b/headphones/webserve.py index 9e708198..b247e067 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -269,9 +269,9 @@ class WebInterface(object): def scanArtist(self, ArtistID): myDB = db.DBConnection() - artist = myDB.select('SELECT DISTINCT ArtistName FROM artists WHERE ArtistID=?', [ArtistID])[0][0] + artist_name = myDB.select('SELECT DISTINCT ArtistName FROM artists WHERE ArtistID=?', [ArtistID])[0][0] - logger.info(u"Scanning artist: %s", artist) + logger.info(u"Scanning artist: %s", artist_name) full_folder_format = headphones.CONFIG.FOLDER_FORMAT folder_format = re.findall(r'(.*[Aa]rtist?)\.*', full_folder_format)[0] @@ -283,7 +283,7 @@ class WebInterface(object): return # Format the folder to match the settings - artist = artist.replace('/', '_') + artist = artist_name.replace('/', '_') if headphones.CONFIG.FILE_UNDERSCORES: artist = artist.replace(' ', '_') @@ -332,7 +332,7 @@ class WebInterface(object): if not os.path.isdir(artistfolder): logger.debug("Cannot find directory: " + artistfolder) continue - threading.Thread(target=librarysync.libraryScan, kwargs={"dir":artistfolder}).start() + threading.Thread(target=librarysync.libraryScan, kwargs={"dir":artistfolder, "artistScan":True, "ArtistID":ArtistID, "ArtistName":artist_name}).start() raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) @cherrypy.expose