Persist new artists through restart (new artists now stored in db table 'newartists'), delete artist from newartists when added. Modified templates to use db instead of variable

This commit is contained in:
rembo10
2012-07-13 15:31:06 +05:30
parent 6ee3a1aa9c
commit 5fc03e782a
8 changed files with 17 additions and 11 deletions

View File

@@ -20,7 +20,7 @@
</tr>
</thead>
<tbody>
%for artist in headphones.NEW_ARTISTS:
%for artist in newartists:
<tr class="gradeZ">
<td id="select"><input type="checkbox" name="${artist}" class="checkbox" /></td>
<td id="name">${artist}</a></td>
@@ -49,4 +49,4 @@
});
});
</script>
</%def>
</%def>

View File

@@ -20,7 +20,7 @@
</tr>
</thead>
<tbody>
%for artist in headphones.NEW_ARTISTS:
%for artist in newartists:
<tr class="gradeZ">
<td id="select"><input type="checkbox" name="${artist}" class="checkbox" /></td>
<td id="name">${artist}</a></td>
@@ -49,4 +49,4 @@
});
});
</script>
</%def>
</%def>

View File

@@ -31,7 +31,7 @@
</tr>
</thead>
<tbody>
%for artist in headphones.NEW_ARTISTS:
%for artist in newartists:
<tr class="gradeZ">
<td id="select"><input type="checkbox" name="${artist}" class="checkbox" /></td>
<td id="name">${artist}</a></td>
@@ -64,4 +64,4 @@
initActions();
});
</script>
</%def>
</%def>

View File

@@ -20,7 +20,7 @@
</tr>
</thead>
<tbody>
%for artist in headphones.NEW_ARTISTS:
%for artist in newartists:
<tr class="gradeZ">
<td id="select"><input type="checkbox" name="${artist}" class="checkbox" /></td>
<td id="name">${artist}</a></td>
@@ -49,4 +49,4 @@
});
});
</script>
</%def>
</%def>

View File

@@ -89,7 +89,6 @@ PREFERRED_QUALITY = None
PREFERRED_BITRATE = None
DETECT_BITRATE = False
ADD_ARTISTS = False
NEW_ARTISTS = []
CORRECT_METADATA = False
MOVE_FILES = False
RENAME_FILES = False
@@ -698,6 +697,7 @@ def dbcheck():
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 newartists (ArtistName 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

@@ -245,6 +245,8 @@ def addArtisttoDB(artistid, extrasonly=False):
myDB.upsert("artists", newValueDict, controlValueDict)
myDB.action('DELETE from newartists WHERE ArtistName=?', [artist['artist_name']])
logger.debug(u"Updating cache for: " + artist['artist_name'])
cache.getThumb(ArtistID=artistid)

View File

@@ -126,7 +126,9 @@ def libraryScan(dir=None):
importer.artistlist_to_mbids(artist_list)
else:
logger.info('To add these artists, go to Manage->Manage New Artists')
headphones.NEW_ARTISTS = artist_list
myDB.action('DELETE * from newartists')
for artist in artist_list:
myDB.action('INSERT into newartists VALUES (?)', [artist])
if headphones.DETECT_BITRATE:
headphones.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000

View File

@@ -236,7 +236,9 @@ class WebInterface(object):
manageAlbums.exposed = True
def manageNew(self):
return serve_template(templatename="managenew.html", title="Manage New Artists")
myDB = db.DBConnection()
newartists = myDB.select('SELECT * from newartists')
return serve_template(templatename="managenew.html", title="Manage New Artists", newartists=newartists)
manageNew.exposed = True
def markArtists(self, action=None, **args):