From 7b115126c9cca8ccce94569c5e4b9fa8e06dc6ad Mon Sep 17 00:00:00 2001 From: delphiactual Date: Sat, 3 May 2014 23:10:57 -0600 Subject: [PATCH 01/11] Fix version check --- headphones/versioncheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/versioncheck.py b/headphones/versioncheck.py index d8ab0f87..65889e58 100644 --- a/headphones/versioncheck.py +++ b/headphones/versioncheck.py @@ -76,7 +76,7 @@ def getVersion(): logger.error('Couldn\'t find latest installed version.') cur_commit_hash = None - cur_commit_hash = output + cur_commit_hash = str(output) if not re.match('^[a-z0-9]+$', cur_commit_hash): logger.error('Output doesn\'t look like a hash, not using it') From 585f5560067fb3359b1b5618469e6b11f02f34e1 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 14:26:44 -0700 Subject: [PATCH 02/11] Fix for #1598: Active artist update no longer updates any existing release groups --- headphones/importer.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 79026040..370c0268 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -226,15 +226,11 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): skip_log = 0 #Make a user configurable variable to skip update of albums with release dates older than this date (in days) pause_delta = headphones.MB_IGNORE_AGE - - check_release_date = myDB.action("SELECT ReleaseDate, Status from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() - - #Skip update if Status set - if check_release_date and check_release_date[1]: - logger.info("[%s] Not updating: %s (Status is %s, skipping)" % (artist['artist_name'], rg['title'], check_release_date[1])) - continue + + rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() if not forcefull: + check_release_date = myDB.action("SELECT ReleaseDate from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() if check_release_date: if check_release_date[0] is None: logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title'])) @@ -268,11 +264,6 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): logger.info("[%s] Now adding/updating: %s (Comprehensive Force)" % (artist['artist_name'], rg['title'])) new_releases = mb.get_new_releases(rgid,includeExtras,forcefull) - #What this does is adds new releases per artist to the allalbums + alltracks databases - #new_releases = mb.get_new_releases(rgid,includeExtras) - #print al_title - #print new_releases - if new_releases != 0: #Dump existing hybrid release since we're repackaging/replacing it myDB.action("DELETE from albums WHERE ReleaseID=?", [rg['id']]) @@ -381,7 +372,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): # If there's no release in the main albums tables, add the default (hybrid) # If there is a release, check the ReleaseID against the AlbumID to see if they differ (user updated) # check if the album already exists - rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() + if not rg_exists: releaseid = rg['id'] else: @@ -402,11 +393,14 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): "ReleaseFormat": album['ReleaseFormat'] } - if not rg_exists: - + if rg_exists: + newValueDict['DateAdded'] = rg_exists['DateAdded'] + newValueDict['Status'] = rg_exists['Status'] + + else: today = helpers.today() - newValueDict['DateAdded']= today + newValueDict['DateAdded'] = today if headphones.AUTOWANT_ALL: newValueDict['Status'] = "Wanted" From 497fafb555f96c6f6180f0816046002dabd5df62 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 15:09:58 -0700 Subject: [PATCH 03/11] Don't need to query the db twice --- headphones/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index 370c0268..c442ff07 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -230,7 +230,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() if not forcefull: - check_release_date = myDB.action("SELECT ReleaseDate from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() + check_release_date = rg_exists['ReleaseDate'] if check_release_date: if check_release_date[0] is None: logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title'])) From b763ccdd08d47dc92d3f7ecdb56c738df08f81ec Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 16:41:55 -0700 Subject: [PATCH 04/11] Don't update all artist statuses when appending a single dir from the postprocessor. Also, don't change any other status but Skipped->Downloaded --- headphones/librarysync.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 2371d918..4a4a4e16 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -328,12 +328,12 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal 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])) myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [havetracks, ArtistID]) - update_album_status() if not append: + update_album_status() lastfm.getSimilar() logger.info('Library scan complete') - #ADDED THIS SECTION TO MARK ALBUMS AS DOWNLOADED IF ARTISTS ARE ADDED EN MASSE BEFORE LIBRARY IS SCANNED +#ADDED THIS SECTION TO MARK ALBUMS AS DOWNLOADED IF ARTISTS ARE ADDED EN MASSE BEFORE LIBRARY IS SCANNED def update_album_status(AlbumID=None): myDB = db.DBConnection() logger.info('Counting matched tracks to mark albums as skipped/downloaded') @@ -355,13 +355,21 @@ def update_album_status(AlbumID=None): album_completion = 0 logger.info('Album %s does not have any tracks in database' % album['AlbumTitle']) - if album_completion >= headphones.ALBUM_COMPLETION_PCT: + if album_completion >= headphones.ALBUM_COMPLETION_PCT and album['Status'] == 'Skipped': new_album_status = "Downloaded" + + # I don't think we want to change Downloaded->Skipped..... + # I think we can only automatically change Skipped->Downloaded when updating + # There was a bug report where this was causing infinite downloads if the album was + # recent, but matched to less than 80%. It would go Downloaded->Skipped->Wanted->Downloaded->Skipped->Wanted->etc.... + #else: + # if album['Status'] == "Skipped" or album['Status'] == "Downloaded": + # new_album_status = "Skipped" + # else: + # new_album_status = album['Status'] else: - if album['Status'] == "Skipped" or album['Status'] == "Downloaded": - new_album_status = "Skipped" - else: - new_album_status = album['Status'] + new_album_status = album['Status'] + myDB.upsert("albums", {'Status' : new_album_status}, {'AlbumID' : album['AlbumID']}) if new_album_status != album['Status']: logger.info('Album %s changed to %s' % (album['AlbumTitle'], new_album_status)) From 2a0fcc7566e19909038c49139e0a32cff0fde2a0 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 16:49:43 -0700 Subject: [PATCH 05/11] Fix for importer failing on adding new release groups --- headphones/importer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index c442ff07..d73293ef 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -230,7 +230,12 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() if not forcefull: - check_release_date = rg_exists['ReleaseDate'] + + try: + check_release_date = rg_exists['ReleaseDate'] + except TypeError: + check_release_date = None + if check_release_date: if check_release_date[0] is None: logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title'])) From 4ca42c9c11614799d1e08ee8d14916376a6747fc Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 18 Apr 2014 00:59:35 -0700 Subject: [PATCH 06/11] Initial changes to stop artist page from refreshing when artist is loading --- data/interfaces/default/artist.html | 59 ++++++++++++++++++++--------- headphones/webserve.py | 6 +++ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index 423fa014..beb3695d 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -42,14 +42,8 @@
-

- %if artist['Status'] == 'Loading': - - %endif +

${artist['ArtistName']} - %if artist['Status'] == 'Loading': -

(Album information for this artist is currently being loaded)

- %endif
@@ -156,9 +150,6 @@ <%def name="headIncludes()"> - %if artist['Status'] == 'Loading': - - %endif <%def name="javascriptIncludes()"> @@ -171,7 +162,6 @@ getInfo(elem,id,'artist'); } - <% if headphones.SONGKICK_FILTER_ENABLED: songkick_filter_enabled = "true" @@ -240,6 +230,41 @@ }); } + var loadingMessage = false; + var spinner_active = false; + var loadingtext_active = false; + + function checkArtistStatus() { + $.ajax({ + url: "getArtistStatus?ArtistID=${artist['ArtistID']}", + complete: function(result) { + if (result.responseText == "Loading"){ + refreshTable(); + if (loadingMessage == false){ + showMsg("Getting artist information",true); + loadingMessage = true; + } + if (spinner_active == false){ + $('#artistname').prepend('') + spinner_active = true; + } + if (loadingtext_active == false){ + $('#artistname').append('

(Album information for this artist is currently being loaded)

') + loadingtext_active = true; + } + } + else{ + $('#artistnamespinner').remove() + $('#loadingtext').remove() + $('#ajaxMsg').remove() + spinner_active = false + loadingtext_active = false + loadingMessage = false + } + } + }); + } + function initThisPage() { $('#menu_link_getextra').click(function() { $('#dialog').dialog(); @@ -248,10 +273,6 @@ $('#menu_link_modifyextra').click(function() { $('#dialog').dialog(); }); - - %if artist['Status'] == 'Loading': - showMsg("Getting artist information",true); - %endif $('#album_table').dataTable({ "bDestroy": true, "aoColumns": [ @@ -291,8 +312,12 @@ initThisPage(); getArtistBio(); if( ${songkick_enabled} ){ - getArtistsCalendar(); - } + getArtistsCalendar(); + } + checkArtistStatus(); + setInterval(function(){ + checkArtistStatus(); + }, 3000); }); diff --git a/headphones/webserve.py b/headphones/webserve.py index 39ddb88f..81b06f8a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -854,6 +854,12 @@ class WebInterface(object): return json_albums getAlbumsByArtist_json.exposed=True + def getArtistStatus(self, ArtistID): + myDB = db.DBConnection() + artist = myDB.action('SELECT Status FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() + return artist['Status'] + getArtistStatus.exposed=True + def clearhistory(self, type=None, date_added=None, title=None): myDB = db.DBConnection() if type: From d80fc36b29cb6ab60be3a4d84a74d3deb8da0034 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 15:40:01 -0700 Subject: [PATCH 07/11] Move to json so we can get the artist name as well --- data/interfaces/default/artist.html | 8 +++++--- headphones/webserve.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index beb3695d..b3d9ad2a 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -43,7 +43,7 @@

- ${artist['ArtistName']} + ${artist['ArtistName']}

@@ -236,10 +236,12 @@ function checkArtistStatus() { $.ajax({ - url: "getArtistStatus?ArtistID=${artist['ArtistID']}", + url: "getArtistjson?ArtistID=${artist['ArtistID']}", + dataType: "jsonp", complete: function(result) { - if (result.responseText == "Loading"){ + if (result.Status == "Loading"){ refreshTable(); + $('#artistnamelink').text(result.ArtistName); if (loadingMessage == false){ showMsg("Getting artist information",true); loadingMessage = true; diff --git a/headphones/webserve.py b/headphones/webserve.py index 81b06f8a..6db4c1f3 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -854,11 +854,15 @@ class WebInterface(object): return json_albums getAlbumsByArtist_json.exposed=True - def getArtistStatus(self, ArtistID): + def getArtistjson(self, ArtistID, **kwargs): myDB = db.DBConnection() - artist = myDB.action('SELECT Status FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() - return artist['Status'] - getArtistStatus.exposed=True + artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() + artist_json = json.dumps({ + 'ArtistName': artist['ArtistName'], + 'Status': artist['Status'] + }) + return artist_json + getArtistjson.exposed=True def clearhistory(self, type=None, date_added=None, title=None): myDB = db.DBConnection() From 0f5aeea345a9790fa8c2286f00dcf0c643684c73 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 15:59:47 -0700 Subject: [PATCH 08/11] some fixes --- data/interfaces/default/artist.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index b3d9ad2a..e0b0a8f9 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -235,13 +235,11 @@ var loadingtext_active = false; function checkArtistStatus() { - $.ajax({ - url: "getArtistjson?ArtistID=${artist['ArtistID']}", - dataType: "jsonp", - complete: function(result) { - if (result.Status == "Loading"){ + $.getJSON("getArtistjson?ArtistID=${artist['ArtistID']}", function(data) { + if (data['Status'] == "Loading"){ refreshTable(); - $('#artistnamelink').text(result.ArtistName); + showMsg("Getting artist information",true) + $('#artistnamelink').text(data["ArtistName"]); if (loadingMessage == false){ showMsg("Getting artist information",true); loadingMessage = true; @@ -263,8 +261,7 @@ loadingtext_active = false loadingMessage = false } - } - }); + }); } function initThisPage() { From 75b38df3d693285a8bbd4d941e582396ff47b7a7 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 16:46:58 -0700 Subject: [PATCH 09/11] Typo --- data/interfaces/default/artist.html | 1 - 1 file changed, 1 deletion(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index e0b0a8f9..c55954bf 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -238,7 +238,6 @@ $.getJSON("getArtistjson?ArtistID=${artist['ArtistID']}", function(data) { if (data['Status'] == "Loading"){ refreshTable(); - showMsg("Getting artist information",true) $('#artistnamelink').text(data["ArtistName"]); if (loadingMessage == false){ showMsg("Getting artist information",true); From f52ec56a0f377d06ae62901c90ddd5cd5b4b4db3 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 17:38:18 -0700 Subject: [PATCH 10/11] Couple fixes to get everything looking nice --- data/interfaces/default/artist.html | 7 ++++--- data/interfaces/default/js/script.js | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index c55954bf..863a4717 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -8,7 +8,7 @@ <%def name="headerIncludes()">
- Refresh Artist + Refresh Artist Delete Artist %if artist['Status'] == 'Paused': Resume Artist @@ -255,7 +255,8 @@ else{ $('#artistnamespinner').remove() $('#loadingtext').remove() - $('#ajaxMsg').remove() + $('#ajaxMsg').empty() + $('#ajaxMsg').removeAttr('style') spinner_active = false loadingtext_active = false loadingMessage = false @@ -315,7 +316,7 @@ checkArtistStatus(); setInterval(function(){ checkArtistStatus(); - }, 3000); + }, 1500); }); diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index c28faf15..b2e56b52 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -334,6 +334,10 @@ function doAjaxCall(url,elem,reload,form) { }); } +function doSimpleAjaxCall(url) { + $.ajax(url); +} + function resetFilters(text){ if ( $(".dataTables_filter").length > 0 ) { $(".dataTables_filter input").attr("placeholder","filter " + text + ""); From 1d7415b91dc6f218e03d7f7aabd2934f1b47405b Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 18:56:47 -0700 Subject: [PATCH 11/11] Catch errors if we can't grab release info in post processor (#1602) --- headphones/postprocessor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 05e90880..787db7a8 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -71,17 +71,21 @@ def verify(albumid, albumpath, Kind=None, forced=False): try: release_list = mb.getReleaseGroup(albumid) except Exception, e: - logger.info('Unable to get release information for manual album with rgid: %s. Error: %s' % (albumid, e)) + logger.error('Unable to get release information for manual album with rgid: %s. Error: %s' % (albumid, e)) return if not release_list: - logger.info('Unable to get release information for manual album with rgid: %s' % albumid) + logger.error('Unable to get release information for manual album with rgid: %s' % albumid) return # Since we're just using this to create the bare minimum information to insert an artist/album combo, use the first release releaseid = release_list[0]['id'] release_dict = mb.getRelease(releaseid) + + if not release_dict: + logger.error('Unable to get release information for manual album with rgid: %s. Cannot continue' % albumid) + return logger.info(u"Now adding/updating artist: " + release_dict['artist_name'])