Open Bujiraso opened 5 years ago
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.
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.