diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html
index 06bb7ba6..2b33eb24 100644
--- a/data/interfaces/default/artist.html
+++ b/data/interfaces/default/artist.html
@@ -16,7 +16,7 @@
%endif
%if artist['IncludeExtras']:
-
+
%else:
diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js
index 9b46369c..c28faf15 100644
--- a/data/interfaces/default/js/script.js
+++ b/data/interfaces/default/js/script.js
@@ -316,6 +316,10 @@ function doAjaxCall(url,elem,reload,form) {
}
if ( reload == "tabs") refreshTab();
if ( reload == "page") location.reload();
+ if ( reload == "submenu&table") {
+ refreshSubmenu();
+ refreshTable();
+ }
if ( form ) {
// Change the option to 'choose...'
$(formID + " select").children('option[disabled=disabled]').attr('selected','selected');
diff --git a/headphones/importer.py b/headphones/importer.py
index 35c956dd..79026040 100644
--- a/headphones/importer.py
+++ b/headphones/importer.py
@@ -210,6 +210,9 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
myDB.action('DELETE from releases WHERE ReleaseGroupID=?', [items['AlbumID']])
logger.info("[%s] Removing all references to release group %s to reflect MusicBrainz" % (artist['artist_name'], items['AlbumID']))
force_repackage = 1
+ elif extrasonly:
+ # Not really sure what we're doing here but don't want to log the message below if we're fetching extras only
+ pass
else:
logger.info("[%s] There was either an error pulling data from MusicBrainz or there might not be any releases for this category" % artist['artist_name'])
@@ -469,10 +472,34 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
if skip_log == 0:
logger.info(u"[%s] No new releases, so no changes made to %s" % (artist['artist_name'], rg['title']))
+ finalize_update(artistid, artist['artist_name'], errors)
+
+ logger.info(u"Seeing if we need album art for: %s" % artist['artist_name'])
+ cache.getThumb(ArtistID=artistid)
+
+ if errors:
+ logger.info("[%s] Finished updating artist: %s but with errors, so not marking it as updated in the database" % (artist['artist_name'], artist['artist_name']))
+ else:
+ myDB.action('DELETE FROM newartists WHERE ArtistName = ?', [artist['artist_name']])
+ logger.info(u"Updating complete for: %s" % artist['artist_name'])
+
+ # Start searching for newly added albums
+ if album_searches:
+ from headphones import searcher
+ logger.info("Start searching for %d albums.", len(album_searches))
+
+ for album_search in album_searches:
+ searcher.searchforalbum(albumid=album_search)
+
+def finalize_update(artistid, artistname, errors=False):
+ # Moving this little bit to it's own function so we can update have tracks & latest album when deleting extras
+
+ myDB = db.DBConnection()
+
latestalbum = myDB.action('SELECT AlbumTitle, ReleaseDate, AlbumID from albums WHERE ArtistID=? order by ReleaseDate DESC', [artistid]).fetchone()
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=?', [artistid]))
#havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist['artist_name']]))
- havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND Matched = "Failed"', [artist['artist_name']]))
+ havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND Matched = "Failed"', [artistname]))
controlValueDict = {"ArtistID": artistid}
@@ -493,23 +520,6 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
myDB.upsert("artists", newValueDict, controlValueDict)
- logger.info(u"Seeing if we need album art for: %s" % artist['artist_name'])
- cache.getThumb(ArtistID=artistid)
-
- if errors:
- logger.info("[%s] Finished updating artist: %s but with errors, so not marking it as updated in the database" % (artist['artist_name'], artist['artist_name']))
- else:
- myDB.action('DELETE FROM newartists WHERE ArtistName = ?', [artist['artist_name']])
- logger.info(u"Updating complete for: %s" % artist['artist_name'])
-
- # Start searching for newly added albums
- if album_searches:
- from headphones import searcher
- logger.info("Start searching for %d albums.", len(album_searches))
-
- for album_search in album_searches:
- searcher.searchforalbum(albumid=album_search)
-
def addReleaseById(rid):
myDB = db.DBConnection()
diff --git a/headphones/mb.py b/headphones/mb.py
index 25061bf3..1f5b66df 100644
--- a/headphones/mb.py
+++ b/headphones/mb.py
@@ -233,18 +233,20 @@ def getArtist(artistid, extrasonly=False):
i += 1
for include in includes:
-
- artist = None
-
+
+ mb_extras_list = []
+
try:
- artist = musicbrainzngs.get_artist_by_id(artistid,includes=["releases","release-groups"],release_status=['official'],release_type=include)['artist']
+ limit = 200
+ newRgs = None
+ while newRgs == None or len(newRgs) >= limit:
+ newRgs = musicbrainzngs.browse_release_groups(artistid,release_type=include,offset=len(mb_extras_list),limit=limit)['release-group-list']
+ mb_extras_list += newRgs
except WebServiceError, e:
logger.warn('Attempt to retrieve artist information from MusicBrainz failed for artistid: %s (%s)' % (artistid, str(e)))
time.sleep(5)
-
- if not artist:
- continue
- for rg in artist['release-group-list']:
+
+ for rg in mb_extras_list:
releasegroups.append({
'title': unicode(rg['title']),
'id': unicode(rg['id']),
diff --git a/headphones/webserve.py b/headphones/webserve.py
index ef76dad5..322e1e40 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -163,7 +163,7 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
getExtras.exposed = True
- def removeExtras(self, ArtistID):
+ def removeExtras(self, ArtistID, ArtistName):
myDB = db.DBConnection()
controlValueDict = {'ArtistID': ArtistID}
newValueDict = {'IncludeExtras': 0}
@@ -175,6 +175,7 @@ class WebInterface(object):
myDB.action('DELETE from allalbums WHERE ArtistID=? AND AlbumID=?', [ArtistID, album['AlbumID']])
myDB.action('DELETE from alltracks WHERE ArtistID=? AND AlbumID=?', [ArtistID, album['AlbumID']])
myDB.action('DELETE from releases WHERE ReleaseGroupID=?', [album['AlbumID']])
+ importer.finalize_update(ArtistID, ArtistName)
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
removeExtras.exposed = True