From afac16a0bfcd8ba1323e6357593d6b65ecfc56ca Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Tue, 17 Jan 2017 19:57:48 -0800 Subject: [PATCH] Added a catch for album art. --- irs/manager.py | 7 +++++-- irs/metadata.py | 25 ++++++++++++++----------- setup.py | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/irs/manager.py b/irs/manager.py index 85cdfbb..b9a1442 100644 --- a/irs/manager.py +++ b/irs/manager.py @@ -317,8 +317,11 @@ class Manager: if tracknum: mp3.add_track_number(tracknum) - image_url = mp3.add_album_art(self.get_album_art(artist, mp3.get_attr('album'))) - exclaim_good("Album art: ", image_url) + try: + image_url = mp3.add_album_art(self.get_album_art(artist, mp3.get_attr('album'))) + exclaim_good("Album art: ", image_url) + except Exception: + print (bc.FAIL + "Album art not added." + bc.ENDC) print (color(song, ["BOLD", "UNDERLINE"]) + bc.OKGREEN + ' downloaded successfully!'+ bc.ENDC) diff --git a/irs/metadata.py b/irs/metadata.py index a76a34b..73a86b5 100644 --- a/irs/metadata.py +++ b/irs/metadata.py @@ -107,19 +107,22 @@ class Metadata: pass if not image_url: - image_url = self.get_album_art(self.args.artist, self.mp3["album"][0]) + image_url = self.get_album_art(self.artist, self.mp3["album"][0]) - mp3.tags.add( - APIC( - encoding = 3, - mime = 'image/png', - type = 3, - desc = 'cover', - data = urlopen(image_url).read() + try: + mp3.tags.add( + APIC( + encoding = 3, + mime = 'image/png', + type = 3, + desc = 'cover', + data = urlopen(image_url).read() + ) ) - ) - mp3.save() - return image_url + mp3.save() + return image_url + except Exception: + return False def search_google(self, search_terms=""): diff --git a/setup.py b/setup.py index 178a232..d289192 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='irs', - version='2.7.18', + version='2.7.19', description='A music downloader that just gets metadata.', url='https://github.com/kepoorhampond/irs', author='Kepoor Hampond',