beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.68k stars 1.81k forks source link

lyrics: Incorrect disabling of Genius backend #2911

Closed rachmadaniHaryono closed 6 years ago

rachmadaniHaryono commented 6 years ago

Problem

i try debugging beets and meet an error on lyric plugin.

installing bs4 will fix the error but unfortunately i can't reproduce the error after that, even with new virtualenv

Running this command in verbose (-vv) mode:

$ # before install bs4 package
$ beet import -s ./Windows版「シュタインズ・ゲート\(STEINS\;GATE\)」OP.m4a
$ # (error here, see below)
$ # after installing bs4 package
$ beet -vv import -s ./Windows版「シュタインズ・ゲート\(STEINS\;GATE\)」OP.m4a

Led to this problem:

(Pdb++) n
Traceback (most recent call last):
  File "/home/q/envs/beets/bin/beet", line 11, in <module>
    sys.exit(main())
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/ui/__init__.py", line 1257, in main
    _raw_main(args)
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/ui/__init__.py", line 1239, in _raw_main
    subcommands, plugins, lib = _setup(options, lib)
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/ui/__init__.py", line 1130, in _setup
    plugins = _load_plugins(config)
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/ui/__init__.py", line 1116, in _load_plugins
    plugins.send("pluginload")
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/plugins.py", line 475, in send
    for handler in event_handlers()[event]:
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/plugins.py", line 458, in event_handlers
    for plugin in find_plugins():
  File "/home/q/envs/beets/lib/python3.6/site-packages/beets/plugins.py", line 304, in find_plugins
    _instances[cls] = cls()
  File "/home/q/envs/beets/lib/python3.6/site-packages/beetsplug/lyrics.py", line 682, in __init__
    sources.remove('google')
ValueError: list.remove(x): x not in list

Here's a link to the music files that trigger the bug (if relevant):

https://www.youtube.com/watch?v=tiCNSLJ8Ihc

Setup

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    auto: yes
    bing_client_secret: REDACTED
    bing_lang_to:
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    fallback:
    force: no
    local: no
    sources:
    - google
    - lyricwiki
    - musixmatch
    - genius

plugins: inline convert web fromfilename play fetchart lyrics lastgenre
convert:
    dest:
    pretend: no
    threads: 2
    format: mp3
    formats:
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    max_bitrate: 500
    auto: no
    tmpdir:
    quiet: no
    embed: yes

    paths: {}
    no_convert: ''
    never_convert_lossy_files: no
    copy_album_art: no
    album_art_maxwidth: 0
web:
    host: 127.0.0.1
    port: 8337
    cors: ''
    reverse_proxy: no
    include_paths: no
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    store_source: no
play:
    command:
    use_folders: no
    relative_to:
    raw: no
    warning_threshold: 100
pathfields: {}
item_fields: {}
album_fields: {}
lastgenre:
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
rachmadaniHaryono commented 6 years ago
diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py
index d9db8ea..54bdd5f 100644
--- a/beetsplug/lyrics.py
+++ b/beetsplug/lyrics.py
@@ -679,7 +679,8 @@ class LyricsPlugin(plugins.BeetsPlugin):
                 u'The Genius backend requires BeautifulSoup, which is not '
                 u'installed, so the source is disabled.'
             )
-            sources.remove('google')
+            if 'google' in sources:
+                sources.remove('google')

         self.config['bing_lang_from'] = [
             x.lower() for x in self.config['bing_lang_from'].as_str_seq()]

will skip it (not quite sure on side effect)

sampsyo commented 6 years ago

Thanks! I think that line should be sources.remove('genius') instead. Can you please open a pull request?