kernitus / beets-oldestdate

Beets plugin that finds oldest possible track recording or release date
MIT License
4 stars 1 forks source link

beet import fails with oldestdate enabled #17

Open scolbeck opened 1 year ago

scolbeck commented 1 year ago

First I want to say thanks for writing this plugin! I been annoyed by songs appearing incorrectly in my decade-based playlists.

While beet oldestdate works on an existing album already imported by beets, beet import fails with the oldestdate plugin enabled. Import works when I disable the plugin.

I have the optimal configuration set from the README.

$ beet import /data/music/tmp/Import/
Traceback (most recent call last):
  File "/home/scolbeck/.local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1285, in main
    _raw_main(args)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/commands.py", line 973, in import_func
    import_files(lib, paths, query)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/commands.py", line 943, in import_files
    session.run()
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 340, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/util/pipeline.py", line 260, in run
    msg = next(self.coro)
          ^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1320, in read_tasks
    yield from task_factory.tasks()
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1145, in tasks
    tasks = self._create(self.album(paths, dirs))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1165, in _create
    tasks = task.handle_created(self.session)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 646, in handle_created
    tasks = plugins.send('import_task_created', session=session, task=self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/plugins.py", line 488, in send
    result = handler(**arguments)
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beetsplug/oldestdate.py", line 229, in _import_task_created
    task.item.mb_trackid = None
    ^^^^^^^^^
AttributeError: 'ImportTask' object has no attribute 'item'. Did you mean: 'items'?

Version info:

$ pipx list --include-injected
   package beets 1.6.0, installed using Python 3.11.2
    - beet
    Injected Packages:
      - beets-oldestdate 1.1.4
      - pylast 5.2.0
      - requests 2.31.0
      - rgain 1.3.4
kernitus commented 1 year ago

Does it work with version 1.1.3?

scolbeck commented 1 year ago

No same problem with 1.1.3, just different line number:

Traceback (most recent call last):
  File "/home/scolbeck/.local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1285, in main
    _raw_main(args)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/commands.py", line 973, in import_func
    import_files(lib, paths, query)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/commands.py", line 943, in import_files
    session.run()
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 340, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/util/pipeline.py", line 260, in run
    msg = next(self.coro)
          ^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1320, in read_tasks
    yield from task_factory.tasks()
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1145, in tasks
    tasks = self._create(self.album(paths, dirs))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 1165, in _create
    tasks = task.handle_created(self.session)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/importer.py", line 646, in handle_created
    tasks = plugins.send('import_task_created', session=session, task=self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/plugins.py", line 488, in send
    result = handler(**arguments)
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/scolbeck/.local/pipx/venvs/beets/lib/python3.11/site-packages/beetsplug/oldestdate.py", line 228, in _import_task_created
    task.item.mb_trackid = None
    ^^^^^^^^^
AttributeError: 'ImportTask' object has no attribute 'item'. Did you mean: 'items'?
   package beets 1.6.0, installed using Python 3.11.2
    - beet
    Injected Packages:
      - beets-oldestdate 1.1.3
      - pylast 5.2.0
      - requests 2.31.0
      - rgain 1.3.4
kernitus commented 1 year ago

Ah, are you perhaps using the plugin in album mode instead of singleton mode?

scolbeck commented 1 year ago

I did see your README comment on best running in singleton mode but don't know how to specify that other than having the oldestdate query be restrictive to a single song.

How do I prevent album mode when I import the album and oldestdate runs automatically on the imported album. Unless are you suggesting changing the auto option to false?

I don't know if album mode is the issue though. When I disable oldestdate to successfully import import an album, after re-enabling oldestdate and manually running oldestdate on the album, it correctly processes all songs in that album.

kernitus commented 8 months ago

You can pass the -s flag to the import to run in singleton mode:

https://beets.readthedocs.io/en/stable/guides/tagger.html?highlight=singleton#options