Added a blacklist table to the database, modified webserve to put artistids on the blacklist if they're manually deleted, modified importer to skip blacklisted artistids if automatic import, if manually adding artist, delete from blacklist

This commit is contained in:
rembo10
2012-07-01 12:05:20 +05:30
parent 93187dcd9a
commit 1b00a7d94e
3 changed files with 15 additions and 3 deletions

View File

@@ -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)')

View File

@@ -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

View File

@@ -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'}