beetbox / beets

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

KeyError: 'title' during import [fromfilename plugin] #5297

Open guerda opened 2 weeks ago

guerda commented 2 weeks ago

Problem

During a rather large import, after selecting a specific (to skip), beets just fails with a KeyError. From the stacktrace, it seems it comes from the fromfilename plugin:

$ beet -vv import
user configuration: /home/pi/.config/beets/config.yaml
data directory: /home/pi/.config/beets
plugin paths:
fetchart: google: Disabling art source due to missing key
fetchart: lastfm: Disabling art source due to missing key
Sending event: pluginload
library database: /home/pi/.beets/musiclibrary.db
library directory: /media/audio
Sending event: library_opened
Sending event: import_begin
ignoring b'.mediaartlocal' due to ignore rule b'.*'
ignoring b'.DS_Store' due to ignore rule b'.*'
[...]
Sending event: import_task_created
Sending event: import_task_choice
Traceback (most recent call last):
  File "/home/pi/.local/bin/beet", line 8, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.10/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/ui/commands.py", line 1395, in import_func
    import_files(lib, paths, query)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/ui/commands.py", line 1326, in import_files
    session.run()
  File "/home/pi/.local/lib/python3.10/site-packages/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/util/pipeline.py", line 447, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/pi/.local/lib/python3.10/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/util/pipeline.py", line 195, in coro
    func(*(args + (task,)))
  File "/home/pi/.local/lib/python3.10/site-packages/beets/importer.py", line 1490, in lookup_candidates
    plugins.send("import_task_start", session=session, task=task)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/plugins.py", line 507, in send
    result = handler(**arguments)
  File "/home/pi/.local/lib/python3.10/site-packages/beets/plugins.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/pi/.local/lib/python3.10/site-packages/beetsplug/fromfilename.py", line 165, in filename_task
    apply_matches(d, self._log)
  File "/home/pi/.local/lib/python3.10/site-packages/beetsplug/fromfilename.py", line 124, in apply_matches
    item.title = str(d[item][title_field])
KeyError: 'title'

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

Setup

My configuration (output of beet config) is:

terminal_encoding: utf-8
directory: /media/audio
library: ~/.beets/musiclibrary.db
match:
  preferred:
    countries: ['DE', 'US', 'GB|UK']
    media: ['CD', 'Digital Media|File']
    original_year: yes
duplicate_action: keep

import:
  copy: no
  write: yes
  move: yes
plugins: inline convert web chroma replaygain duplicates fromfilename fetchart
replaygain:
  backend: command
  auto: no
web:
  host: 0.0.0.0

acoustid:
  apikey: ltYFb9EEwR

fetchart:
  auto: yes
  cautious: yes

https://github.com/beetbox/beets/blob/master/beetsplug/fromfilename.py#L124 offending line

Unfortunately, I cannot pinpoint the offending MP3 file (neither from the logs nor from the progress during the import).

guerda commented 2 weeks ago

Could be a duplicate of #5218