Neurrone / beets-audible

Organize Your Audiobook Collection With Beets
MIT License
115 stars 19 forks source link

Gapless in M4B causes issue on reimport in beets #15

Open SenorSmartyPants opened 2 years ago

SenorSmartyPants commented 2 years ago

If gapless is set in my M4B files and I try to reimport using beets an error is generated. Using Picard to delete gapless removes this error.

beet -c /config/config-audiobook.yaml import -It .
Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.6.1', 'console_scripts', 'beet')())
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1304, in main
    _raw_main(args)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1291, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 973, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.9/site-packages/beets/ui/commands.py", line 943, in import_files
    session.run()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 340, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/usr/lib/python3.9/site-packages/beets/util/pipeline.py", line 260, in run
    msg = next(self.coro)
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1320, in read_tasks
    yield from task_factory.tasks()
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1145, in tasks
    tasks = self._create(self.album(paths, dirs))
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1224, in album
    items = [item for item in items if item]
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1224, in <listcomp>
    items = [item for item in items if item]
  File "/usr/lib/python3.9/site-packages/beets/importer.py", line 1273, in read_item
    return library.Item.from_path(path)
  File "/usr/lib/python3.9/site-packages/beets/library.py", line 606, in from_path
    i.read(path)
  File "/usr/lib/python3.9/site-packages/beets/library.py", line 718, in read
    value = getattr(mediafile, key)
  File "/config/.local/lib/python3.9/site-packages/mediafile-0.6.0-py3.9.egg/mediafile.py", line 1198, in __get__
    out = style.get(mediafile.mgfile)
  File "/config/.local/lib/python3.9/site-packages/mediafile-0.6.0-py3.9.egg/mediafile.py", line 487, in get
    return self.deserialize(self.fetch(mutagen_file))
  File "/config/.local/lib/python3.9/site-packages/mediafile-0.6.0-py3.9.egg/mediafile.py", line 494, in fetch
    return mutagen_file[self.key][0]
TypeError: 'bool' object is not subscriptable

M4Bs are typically a single file and I wouldn't think they need gapless set.

SenorSmartyPants commented 2 years ago

This may be an issue with the LSIO container as I noticed it has an older mediafile than the latest installed.

SenorSmartyPants commented 2 years ago

Something in 616bad003a790b82e5edb6d0accb3247bbcae2b8 is causing this issue. I checked out commits until this error didn't occur.

SenorSmartyPants commented 2 years ago

Something is wrong in these lines

https://github.com/Neurrone/beets-audible/blob/0c50320a03bfc133cd2e24dcc5dd706630300557/audible.py#L59-L62

When I comment that out, no error is generated.

Neurrone commented 2 years ago

Thanks a lot for the bug report!

I've fixed this by not setting the gapless flag.

I tried setting it to match the audiobook guide, but this seems to be causing more problems than its worth.

I'll leave this open till a better way of setting the flag is found.