Skip to content

Beets import crash with lyrics plugin for file w/o lyrics #5583

@satmandu

Description

@satmandu

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import "Allegro Con Brio.m4a" -q --quiet-fallback asis                                                                 

Led to this problem:

user configuration: /home/satadru/.config/beets/config.yaml
data directory: /home/satadru/.config/beets
plugin paths: 
ImageMagick version check failed: [Errno 2] No such file or directory: 'magick'
artresizer: method is ImageMagick
thumbnails: using ImageMagick to write metadata
thumbnails: using GIO to compute URIs
fetchart: google: Disabling art source due to missing key
fetchart: lastfm: Disabling art source due to missing key
lyrics: Disabling google source: no API key configured.
Sending event: pluginload
library database: /home/satadru/data/musiclibrary.db
library directory: <PATH>/music
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
Looking up: <PATH>/Ludwig van Beethoven/Allegro Con Brio.m4a
Tagging Ludwig van Beethoven - Beethoven: Symphonies Nos 1-2 'Erotica' - 5
No album ID found.
Search terms: Ludwig van Beethoven - Beethoven: Symphonies Nos 1-2 'Erotica' - 5
Album might be VA: False
Searching for MusicBrainz releases with: {'release': "beethoven: symphonies nos 1-2 'erotica' - 5", 'artist': 'ludwig van beethoven', 'tracks': '1'}
Requesting MusicBrainz release a8edbb9e-343d-48a2-8cbb-51a8e3b06ceb
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Ludwig van Beethoven - Symphonies nos. 5 & 6 (a8edbb9e-343d-48a2-8cbb-51a8e3b06ceb)
Computing track assignment...
...done.
Success. Distance: 0.69
Requesting MusicBrainz release bf438e51-00a9-45e9-88a6-d74bf8bacef3
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Ludwig van Beethoven - The Complete Beethoven Symphonies (bf438e51-00a9-45e9-88a6-d74bf8bacef3)
Computing track assignment...
...done.
Success. Distance: 0.89
Requesting MusicBrainz release dc0e91e2-72c0-4b28-97b2-88dc99c96b70
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Ludwig van Beethoven - Beethoven: The Great Symphonies (dc0e91e2-72c0-4b28-97b2-88dc99c96b70)
Computing track assignment...
...done.
Success. Distance: 0.77
Requesting MusicBrainz release bf6c4258-0b16-47fe-a8f0-a6bf67323b06
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Ludwig van Beethoven - Classic FM: Symphonies Nos 5 & 7 (bf6c4258-0b16-47fe-a8f0-a6bf67323b06)
Computing track assignment...
...done.
Success. Distance: 0.61
Requesting MusicBrainz release 7c0bff22-bccf-4b75-b381-c5ccd75fa3e0
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Ludwig van Beethoven ; André Cluytens - Beethoven: Symphonies No 5 (7c0bff22-bccf-4b75-b381-c5ccd75fa3e0)
Computing track assignment...
...done.
Success. Distance: 0.71
Evaluating 5 candidates.

<PATH>/Allegro Con Brio.m4a (1 items)
Sending event: import_task_before_choice
Importing as-is.
Sending event: import_task_choice
0 of 1 items replaced
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
fetchart: trying source filesystem for album Ludwig van Beethoven - Beethoven: Symphonies Nos 1-2 'Erotica' - 5
lastgenre: added last.fm album genre (artist): Classical
Sending event: database_change
Sending event: database_change
Traceback (most recent call last):
  File "/home/satadru/beets/bin/beet", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/satadru/src/beets/beets/ui/__init__.py", line 1870, in main
    _raw_main(args)
  File "/home/satadru/src/beets/beets/ui/__init__.py", line 1849, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/satadru/src/beets/beets/ui/commands.py", line 1399, in import_func
    import_files(lib, paths, query)
  File "/home/satadru/src/beets/beets/ui/commands.py", line 1330, in import_files
    session.run()
  File "/home/satadru/src/beets/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/satadru/src/beets/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/satadru/src/beets/beets/util/pipeline.py", line 311, in run
    out = self.coro.send(msg)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/satadru/src/beets/beets/util/pipeline.py", line 194, in coro
    func(*(args + (task,)))
  File "/home/satadru/src/beets/beets/importer.py", line 1667, in plugin_stage
    func(session, task)
  File "/home/satadru/src/beets/beets/plugins.py", line 142, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/satadru/src/beets/beetsplug/lyrics.py", line 973, in imported
    self.fetch_item_lyrics(
  File "/home/satadru/src/beets/beetsplug/lyrics.py", line 991, in fetch_item_lyrics
    self.get_lyrics(artist, title, album=album, length=length)
  File "/home/satadru/src/beets/beetsplug/lyrics.py", line 1027, in get_lyrics
    lyrics = backend.fetch(artist, title, album=album, length=length)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satadru/src/beets/beetsplug/lyrics.py", line 387, in fetch
    return self._scrape_lyrics_from_html(html)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satadru/src/beets/beetsplug/lyrics.py", line 448, in _scrape_lyrics_from_html
    while lyrics[-1] == "\n":
          ~~~~~~^^^^
IndexError: string index out of range

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

Setup

  • OS: Ubuntu
  • Python version: 3.12.7
  • beets version: 2.2.0
  • Turning off plugins made problem go away (yes/no): yes

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
    synced: no                                                                         sources:                                                                           - google                                                                           - genius                                                                           - tekstowo                                                                         - lrclib                                                                           dist_thresh: 0.1
directory: /music                              
# --------------- Main ---------------                                                                                                                                library: ~/data/musiclibrary.db                                                                                                                                       # --------------- Plugins ---------------                                                                                                                             plugins: duplicates fetchart lyrics lastgenre mbcollection mbsync thumbnails web                                                                                      import:                                                                                reflinks: auto
    write: yes
    log: beetslog.txt
art_filename: albumart
fetchart:
    art_filename: cover.jpg
    minwidth: 500
    sources: filesystem coverart itunes amazon albumart
    auto: yes
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    store_source: no
    high_resolution: no
    deinterlace: no
    cover_format:
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    lastfm_key: REDACTED

ui:
    color: yes
paths:
    default: $genre/$albumartist/$album/$track $title
    singleton: Singletons/$artist - $title
    comp: $genre/$album/$track $title                                                  albumtype:soundtrack: Soundtracks/$album/$track $title                         acoustid:                                                                              apikey: BnsM8aEu8l                                                             chroma:                                                                                auto: yes                                                                      musicbrainz:
    user: satadru                                                                      pass: REDACTED                                                                                                                                                    # --------------- Performance ---------------                                                                                                                         threaded: yes                                                                      ignore: .AppleDouble ._* *~ .DS_Store                                              duplicates:                                                                            album: no                                                                          checksum: ''                                                                       copy: ''                                                                           count: no                                                                          delete: no                                                                         format: ''                                                                         full: no                                                                           keys: []                                                                           merge: no                                                                          move: ''                                                                           path: no                                                                           tiebreak: {}
    strict: no                                                                         tag: ''
mbcollection:
    auto: no
    collection: ''
    remove: no
web:
    host: 127.0.0.1
    port: 8337
    cors: ''
    cors_supports_credentials: no
    reverse_proxy: no
    include_paths: no
    readonly: yes
lastgenre:
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
    title_case: yes
thumbnails:
    auto: yes
    force: no
    dolphin: no

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions