From 4d9ce9442618e7feb7e4610ad9f3463a8e9aca65 Mon Sep 17 00:00:00 2001 From: Fabrice Laporte Date: Sun, 9 Nov 2014 20:40:45 +0100 Subject: [PATCH] fetchart: import itunes only if necessary --- beetsplug/fetchart.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index b001c7b9b..0f883f858 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -29,11 +29,6 @@ from beets import ui from beets import util from beets import config -try: - import itunes - HAVE_ITUNES = True -except ImportError: - HAVE_ITUNES = False IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg'] CONTENT_TYPES = ('image/jpeg',) @@ -292,8 +287,11 @@ def sanitize_sources(sources): if s in SOURCES_ALL + ['*']: if not (s in seen or seen.add(s)): res.extend(list(others_sources) if s == '*' else [s]) - if not HAVE_ITUNES and 'itunes' in res: - res.remove('itunes') + if 'itunes' in res: + try: + import itunes + except ImportError: + res.remove('itunes') return res # PLUGIN LOGIC ###############################################################