From fd078e3034fa15e054778287a632efcce7749fa0 Mon Sep 17 00:00:00 2001 From: sbuser Date: Thu, 11 Aug 2011 10:43:12 -0500 Subject: [PATCH 1/5] Added used "new" to unqueueAlbum definition - hitting "mark as skipped" in the web ui was throwing an error without it. --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index c03c2790..392a3561 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -163,7 +163,7 @@ class WebInterface(object): raise cherrypy.HTTPRedirect(redirect) queueAlbum.exposed = True - def unqueueAlbum(self, AlbumID, ArtistID): + def unqueueAlbum(self, AlbumID, ArtistID, new): logger.info(u"Marking album: " + AlbumID + "as skipped...") myDB = db.DBConnection() controlValueDict = {'AlbumID': AlbumID} From 1bd4f803763395b02fcd78862c5d5c7446671b7c Mon Sep 17 00:00:00 2001 From: sbuser Date: Thu, 11 Aug 2011 13:21:54 -0500 Subject: [PATCH 2/5] Change in beets so it only writes tags that have values. This should prevent things like disc reading as "0" instead of null. To reiterate: the tag isn't blank - it's not written at all. I'm not sure what implications that has. --- lib/beets/autotag/__init__.py | 4 ++-- lib/beets/library.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/beets/autotag/__init__.py b/lib/beets/autotag/__init__.py index fb3c6de4..43d72d1f 100644 --- a/lib/beets/autotag/__init__.py +++ b/lib/beets/autotag/__init__.py @@ -378,8 +378,8 @@ def apply_metadata(items, info): # Compilation flag. item.comp = info['va'] - item.comments = 'tagged by headphones/beets' - + item.comments = 'tagged by headphones/beets' + def match_by_id(items): """If the items are tagged with a MusicBrainz album ID, returns an info dict for the corresponding album. Otherwise, returns None. diff --git a/lib/beets/library.py b/lib/beets/library.py index 213d42dd..3ebc0c1d 100644 --- a/lib/beets/library.py +++ b/lib/beets/library.py @@ -204,7 +204,8 @@ class Item(object): """ f = MediaFile(syspath(self.path)) for key in ITEM_KEYS_WRITABLE: - setattr(f, key, getattr(self, key)) + if getattr(self, key): #make sure it has a value before we set it and create blank tags with wrong types + setattr(f, key, getattr(self, key)) f.save() From 3a255b1aa1827d5193ae7a10274418551eaca77b Mon Sep 17 00:00:00 2001 From: sbuser Date: Fri, 12 Aug 2011 00:57:30 -0500 Subject: [PATCH 3/5] Exception handling for MediaFile for debugging. --- headphones/postprocessor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 2b1f87c9..6a9a0310 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -121,7 +121,8 @@ def verify(albumid, albumpath): for downloaded_track in downloaded_track_list: try: f = MediaFile(downloaded_track) - except: + except Exception, e: + logger.info("Exception from MediaFile for: " + downloaded_track + " : " + str(e)) continue if helpers.latinToAscii(f.artist.lower()).encode('UTF-8') == helpers.latinToAscii(release['ArtistName'].lower()).encode('UTF-8') and helpers.latinToAscii(f.album.lower()).encode('UTF-8') == helpers.latinToAscii(release['AlbumTitle'].lower()).encode('UTF-8'): doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list) From a584014bcd0e6ba11704b566868bc4985ad6c5d9 Mon Sep 17 00:00:00 2001 From: sbuser Date: Fri, 12 Aug 2011 20:27:05 -0500 Subject: [PATCH 4/5] Added a try/except block so the post-processor continues when it finds a file that beets/mutagen can't parse. It should probably fail post-processing here but I'm not sure about the best way to do that. Without the try block the post-processor (automatic) just dies without comment after "Writing Metadata" - the force would show an error but the auto would just silently die. --- headphones/postprocessor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 19b1c7b5..92496278 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -356,7 +356,10 @@ def correctMetadata(albumid, release, downloaded_track_list): logger.info('Writing metadata') items = [] for downloaded_track in downloaded_track_list: - items.append(beets.library.Item.from_path(downloaded_track)) + try: + items.append(beets.library.Item.from_path(downloaded_track)) + except Exception, e: + logger.error("Beets couldn't create an Item from: " + downloaded_track + " - not a media file?" + str(e)) cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=release['ArtistName'], search_album=release['AlbumTitle']) @@ -383,6 +386,7 @@ def renameFiles(albumpath, downloaded_track_list, release): try: f = MediaFile(downloaded_track) except: + logger.info("MediaFile couldn't parse: " + downloaded_track) continue if not f.track: From 4db710e4a3ea32d77d006a045b98415697bccc64 Mon Sep 17 00:00:00 2001 From: sbuser Date: Fri, 12 Aug 2011 20:31:17 -0500 Subject: [PATCH 5/5] eyeroll. --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index c026cf5c..399d22ee 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -163,7 +163,7 @@ class WebInterface(object): raise cherrypy.HTTPRedirect(redirect) queueAlbum.exposed = True - def unqueueAlbum(self, AlbumID, ArtistID, new): + def unqueueAlbum(self, AlbumID, ArtistID): logger.info(u"Marking album: " + AlbumID + "as skipped...") myDB = db.DBConnection() controlValueDict = {'AlbumID': AlbumID}