beetbox / beets

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

Lyrics Plugin: AttributeError: 'NoneType' object has no attribute 'get_text' #3582

Closed gcoter closed 4 years ago

gcoter commented 4 years ago

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import ~/Nextcloud/Music/A\ RANGER/Collection/Alon\ Mor

Led to this problem:

lyrics: failed to fetch: http://lyrics.wikia.com/Alon_Mor:El_Despertar (404)
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Alon-Mor/El-Despertar (404)
lyrics: lyrics not found: Alon Mor - Long Awaited Journey - El Despertar
lyrics: failed to fetch: http://lyrics.wikia.com/Alon_Mor:Mania (404)
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Alon-Mor/Mania (404)
lyrics: lyrics not found: Alon Mor - Long Awaited Journey - Mania
lyrics: failed to fetch: http://lyrics.wikia.com/Alon_Mor:Presudeos (404)
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Alon-Mor/Presudeos (404)
Traceback (most recent call last):
  File "/home/gcoter/.local/bin/beet", line 10, in <module>
    sys.exit(main())
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/ui/commands.py", line 955, in import_func
    import_files(lib, paths, query)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/ui/commands.py", line 925, in import_files
    session.run()
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/importer.py", line 329, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/util/pipeline.py", line 445, in run_parallel
    six.reraise(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/lib/python3/dist-packages/six.py", line 693, in reraise
    raise value
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/importer.py", line 1511, in plugin_stage
    func(session, task)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beets/plugins.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 827, in imported
    False, self.config['force'])
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 840, in fetch_item_lyrics
    lyrics = [self.get_lyrics(artist, title) for title in titles]
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 840, in <listcomp>
    lyrics = [self.get_lyrics(artist, title) for title in titles]
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 873, in get_lyrics
    lyrics = backend.fetch(artist, title)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 403, in fetch
    return self.lyrics_from_song_api_path(song_api_path)
  File "/home/gcoter/.local/lib/python3.6/site-packages/beetsplug/lyrics.py", line 375, in lyrics_from_song_api_path
    lyrics = html.find("div", class_="lyrics").get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

Setup

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    auto: yes
    fallback: ''
    force: no
    sources: lyricwiki musixmatch genius
    bing_client_secret: REDACTED
    bing_lang_to:
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    local: no
directory: ~/Nextcloud/Music/Collection/
library: ~/Nextcloud/Music/Collection/beets_library.db

paths:
    default: $albumartist/$album%aunique{}/$track $title
    singleton: $artist/$title

plugins: scrub missing duplicates fromfilename lastgenre lyrics fetchart
lastgenre:
    auto: yes
    count: 3
    whitelist: ~/projects/beets-config/lastgenre/genres.txt
    min_weight: 10
    fallback:
    canonical: no
    source: album
    force: yes
    separator: ', '
    prefer_specific: 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
scrub:
    auto: yes
duplicates:
    album: no
    checksum: ''
    copy: ''
    count: no
    delete: no
    format: ''
    full: no
    keys: []
    merge: no
    move: ''
    path: no
    tiebreak: {}
    strict: no
    tag: ''
missing:
    count: no
    total: no
    album: no
gcoter commented 4 years ago

Basically, it looks like the lyrics plugin failed to handle the 404 error. This album is almost entirely instrumental, so it is expected that some tracks don't have lyrics. In such case, I would expect the plugin to leave the lyrics field empty.

sampsyo commented 4 years ago

Hello! Please see #3535.

gcoter commented 4 years ago

Ok thanks, sorry for the duplicate!