diff --git a/headphones/webserve.py b/headphones/webserve.py index 0f1e65c3..0edefa4a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -188,24 +188,32 @@ class WebInterface(object): myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from albums WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from tracks WHERE ArtistID=?', [ArtistID]) + myDB.action('DELETE from allalbums WHERE ArtistID=?', [ArtistID]) + myDB.action('DELETE from alltracks WHERE ArtistID=?', [ArtistID]) myDB.action('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) raise cherrypy.HTTPRedirect("home") deleteArtist.exposed = True - + def returnEmptyArtists(self): + mydb = db.DBConnection() + emptyArtistNames = [row['ArtistID'] for row in myDB.select("SELECT ArtistName FROM artists WHERE LatestAlbum == None")] + return EmptyArtistNames + returnEmptyArtists.exposed = True + def deleteEmptyArtists(self): logger.info(u"Deleting all empty artists") myDB = db.DBConnection() - emptyArtistIDs = [row['ArtistID'] for row in myDB.select("SELECT ArtistID FROM artists WHERE HaveTracks == 0")] + emptyArtistIDs = [row['ArtistID'] for row in myDB.select("SELECT ArtistID FROM artists WHERE LatestAlbum == None")] for ArtistID in emptyArtistIDs: logger.info(u"Deleting all traces of artist: " + ArtistID) myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from albums WHERE ArtistID=?', [ArtistID]) myDB.action('DELETE from tracks WHERE ArtistID=?', [ArtistID]) + myDB.action('DELETE from allalbums WHERE ArtistID=?', [ArtistID]) + myDB.action('DELETE from alltracks WHERE ArtistID=?', [ArtistID]) myDB.action('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) deleteEmptyArtists.exposed = True - - + def refreshArtist(self, ArtistID): threading.Thread(target=importer.addArtisttoDB, args=[ArtistID]).start() raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)