beetbox / pyacoustid

Python bindings for Chromaprint acoustic fingerprinting and the Acoustid Web service
MIT License
330 stars 66 forks source link

`KeyError` when submitting acoustic fingerprints #65

Closed qak closed 3 years ago

qak commented 3 years ago

Submitting acoustic fingerprints doesn't seem to work anymore with pyacoustid 1.2.1. I'm using pyacoustid via the Beets chromaprint/acoustid plugin. I get the following error when using the latest Git version of Beets (https://github.com/beetbox/beets/commit/75223eedb76ecc1e610e1781065c36105ee900b4):

Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.5.1', 'console_scripts', 'beet')())
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1280, in main
    _raw_main(args)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1267, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.9/site-packages/beetsplug/chroma.py", line 226, in submit_cmd_func
    submit_items(self._log, apikey, lib.items(ui.decargs(args)))
  File "/usr/lib/python3.9/site-packages/beetsplug/chroma.py", line 311, in submit_items
    submit_chunk()
  File "/usr/lib/python3.9/site-packages/beetsplug/chroma.py", line 276, in submit_chunk
    acoustid.submit(API_KEY, userkey, data)
  File "/usr/lib/python3.9/site-packages/acoustid.py", line 403, in submit
    response = _api_request(_get_submit_url(), args, timeout)
  File "/usr/lib/python3.9/site-packages/acoustid.py", line 167, in __call__
    return self.fun(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/acoustid.py", line 185, in _api_request
    if isinstance(params['meta'], list):
KeyError: 'meta'

Downgrading to pyacoustid 1.2.0 resolves the issue. Could it be that the relevant code is simply missing a check for the presence of meta in params?

sampsyo commented 3 years ago

Argh! This is definitely a regression in #64. Yes, we need a check to avoid crashing when that parameter isn't passed. I'll try to throw that together real quick…

sampsyo commented 3 years ago

OK, opened #65 to this effect. Any chance you could give this a shot and confirm that it actually fixes the problem? If so, I'll merge it and release a new version posthaste.

qak commented 3 years ago

I've confirmed that PR #66 fixes the issue.

sampsyo commented 3 years ago

Thank you, @qak!!