From e7417e3683940f9d0870a5c342f2947c602eb05f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 30 Jan 2018 22:31:15 -0500 Subject: [PATCH] lyrics: Don't crash when BeautifulSoup isn't found --- beetsplug/lyrics.py | 7 +++++++ docs/changelog.rst | 3 +++ docs/plugins/lyrics.rst | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 1987b67e7..7dba483ba 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -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 diff --git a/docs/changelog.rst b/docs/changelog.rst index c3e120ac1..e93e644c0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) diff --git a/docs/plugins/lyrics.rst b/docs/plugins/lyrics.rst index e1f00e67f..4131c85d9 100644 --- a/docs/plugins/lyrics.rst +++ b/docs/plugins/lyrics.rst @@ -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