Using Mediafile to read the WOAF attribute fails on mp3 files
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
### Problem
This was first reported by @noahbaculi in https://github.com/Neurrone/beets-audible/issues/71
Importing mp3 files that don't have the WOAF attribute causes Beets to crash with a "'WOAF' object has no attribute 'text'" error.
```sh
Traceback (most recent call last):
File "/lsiopy/bin/beet", line 8, in
sys.exit(main())
^^^^^^
File "/lsiopy/lib/python3.12/site-packages/beets/ui/__init__.py", line 1870, in main
_raw_main(args)
File "/lsiopy/lib/python3.12/site-packages/beets/ui/__init__.py", line 1849, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/lsiopy/lib/python3.12/site-packages/beets/ui/commands.py", line 1398, in import_func
import_files(lib, paths, query)
File "/lsiopy/lib/python3.12/site-packages/beets/ui/commands.py", line 1329, in import_files
session.run()
File "/lsiopy/lib/python3.12/site-packages/beets/importer.py", line 360, in run
pl.run_parallel(QUEUE_SIZE)
File "/lsiopy/lib/python3.12/site-packages/beets/util/pipeline.py", line 446, in run_parallel
raise exc_info[1].with_traceback(exc_info[2])
File "/lsiopy/lib/python3.12/site-packages/beets/util/pipeline.py", line 260, in run
msg = next(self.coro)
^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/beets/importer.py", line 1444, in read_tasks
yield from task_factory.tasks()
File "/lsiopy/lib/python3.12/site-packages/beets/importer.py", line 1267, in tasks
tasks = self._create(self.album(paths, dirs))
^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/beets/importer.py", line 1347, in album
items = [item for item in items if item]
^^^^^
File "/lsiopy/lib/python3.12/site-packages/beets/importer.py", line 1396, in read_item
return library.Item.from_path(path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/beets/library.py", line 697, in from_path
i.read(path)
File "/lsiopy/lib/python3.12/site-packages/beets/library.py", line 811, in read
value = getattr(mediafile, key)
^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/mediafile.py", line 1254, in __get__
out = style.get(mediafile.mgfile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/mediafile.py", line 492, in get
return self.deserialize(self.fetch(mutagen_file))
^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/mediafile.py", line 769, in fetch
return mutagen_file[self.key].text[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WOAF' object has no attribute 'text'
```
### Setup
Linuxserver docker image, lscr.io/linuxserver/beets:2.2.0-ls266
I'm importing books with my Beets-audible plugin, which [uses the Woaf attribute](https://github.com/Neurrone/beets-audible/blob/ffeb6ebbc99c3b71a63086c17126340980968a0a/beetsplug/audible.py#L114).
Contributor guide
Research direction
Start with beets/library.py around Item.read and the mediafile.py fetch path shown in the traceback; the linked audible.py usage is also relevant. Reproduce the import with an MP3 lacking WOAF, then verify that importing it no longer crashes and that the affected metadata remains handled consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100