lyrics: Don't crash when BeautifulSoup isn't found

This commit is contained in:
Adrian Sampson 2018-01-30 22:31:15 -05:00
parent b47e3ec565
commit e7417e3683
3 changed files with 22 additions and 0 deletions

View file

@ -659,6 +659,13 @@ class LyricsPlugin(plugins.BeetsPlugin):
u'the documentation for further details.')
sources.remove('google')
if 'genius' in sources and not HAS_BEAUTIFUL_SOUP:
self._log.debug(
u'The Genius backend requires BeautifulSoup, which is not '
u'installed, so the source is disabled.'
)
sources.remove('google')
self.config['bing_lang_from'] = [
x.lower() for x in self.config['bing_lang_from'].as_str_seq()]
self.bing_auth_token = None

View file

@ -24,6 +24,9 @@ Fixes:
``ignore_video_tracks`` has been added to control if video tracks should be
ignored or not. :bug:`1210`
* :doc:`/plugins/replaygain`: Fix a corner-case with the ``bs1770gain`` backend where ReplayGain values were assigned to the wrong files. Now ``bs1770gain`` version 0.4.6 or later is required. :bug:`2777`
* :doc:`/plugins/lyrics`: The plugin no longer crashes in the Genius source
when BeautifulSoup is not found. Instead, it just logs a message and
disables the source.
1.4.6 (December 21, 2017)

View file

@ -62,6 +62,8 @@ configuration file. The available options are:
Default: ``google lyricwiki musixmatch genius``, i.e., all the
available sources. The `google` source will be automatically
deactivated if no ``google_API_key`` is setup.
Both it and the `genius` source will only be enabled if BeautifulSoup is
installed.
Here's an example of ``config.yaml``::
@ -154,6 +156,16 @@ After that, the lyrics plugin will fall back on other declared data sources.
.. _pip: http://www.pip-installer.org/
.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/bs4/doc/
Activate Genius Lyrics
----------------------
Like the Google backend, the Genius backend requires the `BeautifulSoup`_
library. Install it by typing::
pip install beautifulsoup4
The backend is enabled by default.
.. _lyrics-translation:
Activate On-the-Fly Translation