Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:ERROR - SOMETHING VERY BAD HAPPENED on every run #7

Open
Bujiraso opened this issue Jun 1, 2019 · 1 comment
Open

:ERROR - SOMETHING VERY BAD HAPPENED on every run #7

Bujiraso opened this issue Jun 1, 2019 · 1 comment

Comments

@Bujiraso
Copy link

Bujiraso commented Jun 1, 2019

The real bug here is that I don't have much to go on for debugging or troubleshooting.

Bonus feature requesting a "--verbose" switch here, too, which could be a good thing to have as well as a better error message.

$ covergrabber Nightwish/
2019-06-01 07:48:39,738: cover_grabber :INFO - Scanning Nightwish/
2019-06-01 07:48:39,767: cover_grabber :INFO - LastFM: Searching for "Nightwish - Once"
2019-06-01 07:48:40,211: cover_grabber :ERROR - SOMETHING VERY BAD HAPPENED during processing of "Nightwish - Once"
$ covergrabber Silverchair/
2019-06-01 07:48:59,096: cover_grabber :INFO - Scanning Silverchair/
2019-06-01 07:48:59,098: cover_grabber :INFO - LastFM: Searching for "Silverchair - Frogstomp"
2019-06-01 07:48:59,549: cover_grabber :ERROR - SOMETHING VERY BAD HAPPENED during processing of "Silverchair - Frogstomp"
@gligneul
Copy link

This patch solves the issue:

diff --git a/cover_grabber/downloader/lastfm_downloader.py b/cover_grabber/downloader/lastfm_downloader.py
index fec1433..dbae57f 100644
--- a/cover_grabber/downloader/lastfm_downloader.py
+++ b/cover_grabber/downloader/lastfm_downloader.py
@@ -14,10 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

 import urllib
-try:
-    import xml.etree.cElementTree as ETree
-except:
-    import xml.etree.ElementTree as ETree
+from lxml import etree as ETree

 from cover_grabber.logging.config import logger

@@ -42,7 +39,8 @@ class LastFMDownloader(object):

         logger.info(u'LastFM: Searching for "{artist_name} - {album_name}"'.format(artist_name=self.artist_name, album_name=self.album_name))
         response = urllib.urlopen(self.url).read() # Send HTTP request to LastFM
-        xml_data = ETree.fromstring(response) # Read in XML data
+        parser = ETree.XMLParser(recover=True)
+        xml_data = ETree.fromstring(response, parser) # Read in XML data

         for element in xml_data.getiterator("album"):
             if (element.find('artist').text.lower() == self.artist_name.lower().encode("utf-8")):

You also need to install lxml with pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants