diff --git a/headphones/__init__.py b/headphones/__init__.py index 3ec235d0..42acc958 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -679,6 +679,7 @@ def dbcheck(): c.execute('CREATE TABLE IF NOT EXISTS have (ArtistName TEXT, AlbumTitle TEXT, TrackNumber TEXT, TrackTitle TEXT, TrackLength TEXT, BitRate TEXT, Genre TEXT, Date TEXT, TrackID TEXT, Location TEXT, CleanName TEXT, Format TEXT)') c.execute('CREATE TABLE IF NOT EXISTS lastfmcloud (ArtistName TEXT, ArtistID TEXT, Count INTEGER)') c.execute('CREATE TABLE IF NOT EXISTS descriptions (ArtistID TEXT, ReleaseGroupID TEXT, ReleaseID TEXT, Summary TEXT, Content TEXT, LastUpdated TEXT)') + c.execute('CREATE TABLE IF NOT EXISTS blacklist (ArtistID TEXT UNIQUE)') c.execute('CREATE TABLE IF NOT EXISTS releases (ReleaseID TEXT, ReleaseGroupID TEXT, UNIQUE(ReleaseID, ReleaseGroupID))') c.execute('CREATE INDEX IF NOT EXISTS tracks_albumid ON tracks(AlbumID ASC)') c.execute('CREATE INDEX IF NOT EXISTS album_artistid_reldate ON albums(ArtistID ASC, ReleaseDate DESC)') diff --git a/headphones/importer.py b/headphones/importer.py index 73ececfd..fc0c1f56 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -56,14 +56,20 @@ def artistlist_to_mbids(artistlist, forced=False): except IndexError: logger.info('MusicBrainz query turned up no matches for: %s' % artist) continue + + # Check if it's blacklisted/various artists + myDB = db.DBConnection() + bl_artist = myDB.action('SELECT * FROM blacklist WHERE ArtistID=?', [artistid]).fetchone() + if bl_artist or artistid == various_artists_mbid: + logger.info("Artist ID for '%s' is either blacklisted or Various Artists. Not Adding: %s (to add artist, you must do it manually)" % (name, artistid)) + continue # Add to database if it doesn't exist - if artistid != various_artists_mbid and not is_exists(artistid): + if not is_exists(artistid): addArtisttoDB(artistid) # Just update the tracks if it does else: - myDB = db.DBConnection() havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=?', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist])) myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [havetracks, artistid]) @@ -82,7 +88,7 @@ def addArtistIDListToDB(artistidlist): def addArtisttoDB(artistid, extrasonly=False): - # Putting this here to get around the circular import + # Putting this here to get around the circular import. We're using this to update thumbnails for artist/albums from headphones import cache # Can't add various artists - throws an error from MB @@ -91,6 +97,9 @@ def addArtisttoDB(artistid, extrasonly=False): return myDB = db.DBConnection() + + # Delete from blacklist if it's on there + myDB.action('DELETE from blacklist WHERE ArtistID=?', [ArtistID]) # We need the current minimal info in the database instantly # so we don't throw a 500 error when we redirect to the artistPage diff --git a/headphones/webserve.py b/headphones/webserve.py index dcdb3ad7..40638337 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -138,6 +138,7 @@ 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('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) raise cherrypy.HTTPRedirect("home") deleteArtist.exposed = True @@ -245,6 +246,7 @@ 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('INSERT OR REPLACE into blacklist VALUES (?)', [ArtistID]) elif action == 'pause': controlValueDict = {'ArtistID': ArtistID} newValueDict = {'Status': 'Paused'}