Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes TypeError in the Discogs plugin #5415

Merged
merged 11 commits into from
Sep 19, 2024

Conversation

amogus07
Copy link
Contributor

@amogus07 amogus07 commented Sep 10, 2024

Description

Fixes the following error:

Traceback (most recent call last):
  File "/home/konstantink/.local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/ui/commands.py", line 1395, in import_func
    import_files(lib, paths, query)
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/ui/commands.py", line 1326, in import_files
    session.run()
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/util/pipeline.py", line 447, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/util/pipeline.py", line 195, in coro
    func(*(args + (task,)))
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/importer.py", line 1497, in lookup_candidates
    task.lookup_candidates()
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/importer.py", line 688, in lookup_candidates
    artist, album, prop = autotag.tag_album(
                          ^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/autotag/match.py", line 548, in tag_album
    for matched_candidate in hooks.album_candidates(
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/plugins.py", line 593, in decorated
    for v in generator(*args, **kwargs):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/autotag/hooks.py", line 759, in album_candidates
    yield from plugins.candidates(items, artist, album, va_likely, extra_tags)
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beets/plugins.py", line 390, in candidates
    yield from plugin.candidates(
               ^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beetsplug/discogs.py", line 188, in candidates
    return self.get_albums(query)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beetsplug/discogs.py", line 335, in get_albums
    return [
           ^
  File "/home/konstantink/.local/share/pipx/venvs/beets/lib64/python3.12/site-packages/beetsplug/discogs.py", line 419, in get_album_info
    ", ".join(result.data["formats"][0].get("descriptions", []))
TypeError: can only join an iterable

IDK what exactly caused it, but this seems to have fixed it without causing additional problems.

To Do

  • Documentation.
  • Changelog.
  • Tests.

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it with a release that has a couple of formats and I think we'd want to re-think the solution. Could you by any chance share the URL of the release that caused the issue?

beetsplug/discogs.py Outdated Show resolved Hide resolved
@snejus
Copy link
Member

snejus commented Sep 13, 2024

I tested it with a release that has a couple of formats and I think we'd want to re-think the solution. Could you by any chance share the URL of the release that caused the issue?

@amogus07 can you please share the URL of the release that caused the failure you reported above, for testing?

@amogus07
Copy link
Contributor Author

I tested it with a release that has a couple of formats and I think we'd want to re-think the solution. Could you by any chance share the URL of the release that caused the issue?

@amogus07 can you please share the URL of the release that caused the failure you reported above, for testing?

I don't have it, unfortunately

@mwean
Copy link

mwean commented Sep 17, 2024

I'm getting this error too. Here is one example. The result formats data is [{'name': 'CD', 'qty': '1', 'descriptions': None}].

@amogus07
Copy link
Contributor Author

I'm getting this error too. Here is one example. The result formats data is [{'name': 'CD', 'qty': '1', 'descriptions': None}].

oh, so the problem occurs when description is empty?

@snejus
Copy link
Member

snejus commented Sep 17, 2024

I'm getting this error too. Here is one example. The result formats data is [{'name': 'CD', 'qty': '1', 'descriptions': None}].

Here we go, that's amazing, thanks @mwean! I sensed that the description may have been None in this case.

beetsplug/discogs.py Outdated Show resolved Hide resolved
@amogus07
Copy link
Contributor Author

amogus07 commented Sep 18, 2024

now, someone needs to add a test case (idk how to do that) and this should be good to get merged, right?

docs/changelog.rst Outdated Show resolved Hide resolved
@snejus
Copy link
Member

snejus commented Sep 19, 2024

now, someone needs to add a test case (idk how to do that) and this should be good to get merged, right?

Indeed. I can help you with the test :)

@snejus
Copy link
Member

snejus commented Sep 19, 2024

@amogus07 have just isolated this change into a separate method and added a test

@snejus snejus merged commit 796c9ad into beetbox:master Sep 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants