mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 17:16:07 +01:00
Merge remote-tracking branch 'upstream/master' into coverarturl
This commit is contained in:
commit
17d1a431bc
1 changed files with 61 additions and 26 deletions
|
|
@ -253,6 +253,17 @@ class ArtSource(RequestMixin):
|
||||||
self._config = config
|
self._config = config
|
||||||
self.match_by = match_by or self.VALID_MATCHING_CRITERIA
|
self.match_by = match_by or self.VALID_MATCHING_CRITERIA
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_default_config(config):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def available(cls, log, config):
|
||||||
|
"""Return whether or not all dependencies are met and the art source is
|
||||||
|
in fact usable.
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
def get(self, album, plugin, paths):
|
def get(self, album, plugin, paths):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
@ -465,6 +476,21 @@ class GoogleImages(RemoteArtSource):
|
||||||
self.key = self._config['google_key'].get(),
|
self.key = self._config['google_key'].get(),
|
||||||
self.cx = self._config['google_engine'].get(),
|
self.cx = self._config['google_engine'].get(),
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_default_config(config):
|
||||||
|
config.add({
|
||||||
|
'google_key': None,
|
||||||
|
'google_engine': '001442825323518660753:hrh5ch1gjzm',
|
||||||
|
})
|
||||||
|
config['google_key'].redact = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def available(cls, log, config):
|
||||||
|
has_key = bool(config['google_key'].get())
|
||||||
|
if not has_key:
|
||||||
|
log.debug("google: Disabling art source due to missing key")
|
||||||
|
return has_key
|
||||||
|
|
||||||
def get(self, album, plugin, paths):
|
def get(self, album, plugin, paths):
|
||||||
"""Return art URL from google custom search engine
|
"""Return art URL from google custom search engine
|
||||||
given an album title and interpreter.
|
given an album title and interpreter.
|
||||||
|
|
@ -514,6 +540,13 @@ class FanartTV(RemoteArtSource):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.client_key = self._config['fanarttv_key'].get()
|
self.client_key = self._config['fanarttv_key'].get()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_default_config(config):
|
||||||
|
config.add({
|
||||||
|
'fanarttv_key': None,
|
||||||
|
})
|
||||||
|
config['fanarttv_key'].redact = True
|
||||||
|
|
||||||
def get(self, album, plugin, paths):
|
def get(self, album, plugin, paths):
|
||||||
if not album.mb_releasegroupid:
|
if not album.mb_releasegroupid:
|
||||||
return
|
return
|
||||||
|
|
@ -854,6 +887,20 @@ class LastFM(RemoteArtSource):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.key = self._config['lastfm_key'].get(),
|
self.key = self._config['lastfm_key'].get(),
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_default_config(config):
|
||||||
|
config.add({
|
||||||
|
'lastfm_key': None,
|
||||||
|
})
|
||||||
|
config['lastfm_key'].redact = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def available(cls, log, config):
|
||||||
|
has_key = bool(config['lastfm_key'].get())
|
||||||
|
if not has_key:
|
||||||
|
log.debug("lastfm: Disabling art source due to missing key")
|
||||||
|
return has_key
|
||||||
|
|
||||||
def get(self, album, plugin, paths):
|
def get(self, album, plugin, paths):
|
||||||
if not album.mb_albumid:
|
if not album.mb_albumid:
|
||||||
return
|
return
|
||||||
|
|
@ -900,6 +947,14 @@ class Spotify(RemoteArtSource):
|
||||||
|
|
||||||
SPOTIFY_ALBUM_URL = 'https://open.spotify.com/album/'
|
SPOTIFY_ALBUM_URL = 'https://open.spotify.com/album/'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def available(cls, log, config):
|
||||||
|
if not HAS_BEAUTIFUL_SOUP:
|
||||||
|
log.debug('To use Spotify as an album art source, '
|
||||||
|
'you must install the beautifulsoup4 module. See '
|
||||||
|
'the documentation for further details.')
|
||||||
|
return HAS_BEAUTIFUL_SOUP
|
||||||
|
|
||||||
def get(self, album, plugin, paths):
|
def get(self, album, plugin, paths):
|
||||||
if not len(album.mb_albumid) == 22:
|
if not len(album.mb_albumid) == 22:
|
||||||
self._log.debug("Invalid Spotify album_id: {}", album.mb_albumid)
|
self._log.debug("Invalid Spotify album_id: {}", album.mb_albumid)
|
||||||
|
|
@ -943,9 +998,6 @@ class CoverArtUrl(RemoteArtSource):
|
||||||
|
|
||||||
# Try each source in turn.
|
# Try each source in turn.
|
||||||
|
|
||||||
SOURCES_ALL = ['filesystem', 'coverart', 'itunes', 'amazon', 'albumart',
|
|
||||||
'spotify', 'wikipedia', 'google', 'fanarttv', 'lastfm', 'cover_art_url']
|
|
||||||
|
|
||||||
ART_SOURCES = {
|
ART_SOURCES = {
|
||||||
'filesystem': FileSystem,
|
'filesystem': FileSystem,
|
||||||
'coverart': CoverArtArchive,
|
'coverart': CoverArtArchive,
|
||||||
|
|
@ -986,18 +1038,13 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
||||||
'cover_names': ['cover', 'front', 'art', 'album', 'folder'],
|
'cover_names': ['cover', 'front', 'art', 'album', 'folder'],
|
||||||
'sources': ['filesystem', 'coverart', 'itunes', 'amazon',
|
'sources': ['filesystem', 'coverart', 'itunes', 'amazon',
|
||||||
'albumart', 'cover_art_url'],
|
'albumart', 'cover_art_url'],
|
||||||
'google_key': None,
|
|
||||||
'google_engine': '001442825323518660753:hrh5ch1gjzm',
|
|
||||||
'fanarttv_key': None,
|
|
||||||
'lastfm_key': None,
|
|
||||||
'store_source': False,
|
'store_source': False,
|
||||||
'high_resolution': False,
|
'high_resolution': False,
|
||||||
'deinterlace': False,
|
'deinterlace': False,
|
||||||
'cover_format': None,
|
'cover_format': None,
|
||||||
})
|
})
|
||||||
self.config['google_key'].redact = True
|
for source in ART_SOURCES.values():
|
||||||
self.config['fanarttv_key'].redact = True
|
source.add_default_config(self.config)
|
||||||
self.config['lastfm_key'].redact = True
|
|
||||||
|
|
||||||
self.minwidth = self.config['minwidth'].get(int)
|
self.minwidth = self.config['minwidth'].get(int)
|
||||||
self.maxwidth = self.config['maxwidth'].get(int)
|
self.maxwidth = self.config['maxwidth'].get(int)
|
||||||
|
|
@ -1039,22 +1086,10 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
||||||
self.import_stages = [self.fetch_art]
|
self.import_stages = [self.fetch_art]
|
||||||
self.register_listener('import_task_files', self.assign_art)
|
self.register_listener('import_task_files', self.assign_art)
|
||||||
|
|
||||||
available_sources = list(SOURCES_ALL)
|
available_sources = [(s_name, c)
|
||||||
if not self.config['google_key'].get() and \
|
for (s_name, s_cls) in ART_SOURCES.items()
|
||||||
'google' in available_sources:
|
if s_cls.available(self._log, self.config)
|
||||||
available_sources.remove('google')
|
for c in s_cls.VALID_MATCHING_CRITERIA]
|
||||||
if not self.config['lastfm_key'].get() and \
|
|
||||||
'lastfm' in available_sources:
|
|
||||||
available_sources.remove('lastfm')
|
|
||||||
if not HAS_BEAUTIFUL_SOUP and \
|
|
||||||
'spotify' in available_sources:
|
|
||||||
self._log.debug('To use Spotify as an album art source, '
|
|
||||||
'you must install the beautifulsoup4 module. See '
|
|
||||||
'the documentation for further details.')
|
|
||||||
available_sources.remove('spotify')
|
|
||||||
available_sources = [(s, c)
|
|
||||||
for s in available_sources
|
|
||||||
for c in ART_SOURCES[s].VALID_MATCHING_CRITERIA]
|
|
||||||
sources = plugins.sanitize_pairs(
|
sources = plugins.sanitize_pairs(
|
||||||
self.config['sources'].as_pairs(default_value='*'),
|
self.config['sources'].as_pairs(default_value='*'),
|
||||||
available_sources)
|
available_sources)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue