Samik081 / beets-beatport4

Beatport API v4 compatible beets plugin
MIT License
25 stars 2 forks source link

NoneType object has no attribute artists #7

Closed mybuntu-git2 closed 1 year ago

mybuntu-git2 commented 1 year ago

hi, I got a similar error to #4

(...)
  File "/usr/local/lib/python3.10/dist-packages/beetsplug/beatport4.py", line 600, in _get_album_info
    va = len(release.artists) > 3
AttributeError: 'NoneType' object has no attribute 'artists'

my beets setup is set to tag from scratch, and I move the 'artists' tag to 'artist' if that is not present, then I wipe 'artists' because the subsonic api reads artists first then artist if it is empty, which is kinda annoying as sometimes 'artists' is kind of unrelated to 'artist' which is usually the right one. my preference would be, if some critical info is missing for beatport api to run, do not run it without crashing, but also have the artists-> artist fallback.

Samik081 commented 1 year ago

Hey @mybuntu-git2, thank you for spotting this one!

Could you please provide me some of these, so I can reproduce the issue and make sure I'll have it fixed?

JOJ0 commented 1 year ago

Hi @Samik081, sorry for crashing in. I can confirm this bug, I came across it a few times during the last days. Here's a longer output including import command. Don't mind the debug print statements on the very top. They are there because I'm investigating something else, they might even help here or at least don't hurt, so I left them there:

beet import "/remote/data/music-library/DrumnbassJungleDrumfunk/0-Single-Tracks/Calibre - 0 - Inflicted _ Always - Always.mp3"

This is criteria
{'artist': 'calibre',
 'label': 'creative source',
 'release': 'inflicted / always',
 'tracks': '1'}

We were called from:
album_candidates
extra_tags is
{'label': 'Creative Source', 'catalognum': ''}
Traceback (most recent call last):
  File "/home/jojo/.pyenv/versions/beets/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets', 'console_scripts', 'beet')())
  File "/home/jojo/git/beets/beets/ui/__init__.py", line 1304, in main
    _raw_main(args)
  File "/home/jojo/git/beets/beets/ui/__init__.py", line 1291, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/jojo/git/beets/beets/ui/commands.py", line 1034, in import_func
    import_files(lib, paths, query)
  File "/home/jojo/git/beets/beets/ui/commands.py", line 974, in import_files
    session.run()
  File "/home/jojo/git/beets/beets/importer.py", line 340, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/jojo/git/beets/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/jojo/git/beets/beets/util/pipeline.py", line 311, in run
    out = self.coro.send(msg)
  File "/home/jojo/git/beets/beets/util/pipeline.py", line 193, in coro
    func(*(args + (task,)))
  File "/home/jojo/git/beets/beets/importer.py", line 1408, in lookup_candidates
    task.lookup_candidates()
  File "/home/jojo/git/beets/beets/importer.py", line 661, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/home/jojo/git/beets/beets/autotag/match.py", line 461, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/home/jojo/git/beets/beets/plugins.py", line 573, in decorated
    for v in generator(*args, **kwargs):
  File "/home/jojo/git/beets/beets/autotag/hooks.py", line 632, in album_candidates
    yield from plugins.candidates(items, artist, album, va_likely, extra_tags)
  File "/home/jojo/git/beets/beets/plugins.py", line 384, in candidates
    yield from plugin.candidates(items, artist, album, va_likely,
  File "/home/jojo/git/beets-beatport4/beetsplug/beatport4.py", line 537, in candidates
    return self._get_releases(query)
  File "/home/jojo/git/beets-beatport4/beetsplug/beatport4.py", line 593, in _get_releases
    albums = [self._get_album_info(x)
  File "/home/jojo/git/beets-beatport4/beetsplug/beatport4.py", line 593, in <listcomp>
    albums = [self._get_album_info(x)
  File "/home/jojo/git/beets-beatport4/beetsplug/beatport4.py", line 600, in _get_album_info
    va = len(release.artists) > 3
AttributeError: 'NoneType' object has no attribute 'artists'

Does that help already? I can try tagging the same file and adding -vv if you want. HTH

Samik081 commented 1 year ago

@JOJ0 thank you for the stack trace, it was all I needed. :) Seems like Beatport API returns 403 for some releases, even though they present them in the /catalog/search result. This issue should be fixed by https://github.com/Samik081/beets-beatport4/commit/76458c95096eb7532162568f7a038933f19050b3, already in v0.2.10

JOJ0 commented 1 year ago

Awesome! That was quick! Thanks!

mybuntu-git2 commented 1 year ago

Thanks! really sorry for not providing the information myself, I lost track of this issue. I confirm that after updating best port with pip, the same files get correctly processed.