fetchart: import itunes only if necessary

This commit is contained in:
Fabrice Laporte 2014-11-09 20:40:45 +01:00
parent 41d0f4d674
commit 4d9ce94426

View file

@ -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 ###############################################################