Closed fhchl closed 3 years ago
Thanks for the report. I can confirm this:
>>> from beetsplug import discogs
>>> p = discogs.DiscogsPlugin()
>>> p.get_albums(u'caf\xe9')
[ugly traceback]
Alas, I think this is a bug in discogs-client rather than beets. Investigating.
Bug filed: https://github.com/discogs/discogs_client/issues/40
Unfortunately, I don't think there's much we can do on our end. We can consider isolating the fault so beets at least avoids crashing, though.
i'm reopening this so we can track whether this gets a proper fix, since the discogs client now supports utf-8 queries. maybe we can check the version, so we still convert to ascii if their version is too old
I just ran into this error TypeError: sequence item 0: expected str instance, bytes found
. Previously beets had been working fine.
I changed the code (at https://github.com/beetbox/beets/blob/c4347960eab78be2ad54f4e35b32928c47e287d1/beetsplug/discogs.py#L245-L248) from:
query = re.sub(r'(?u)\W+', ' ', query).encode('ascii', "replace")
query = re.sub(br'(?i)\b(CD|disc)\s*\d+', b'', query)
To:
query = re.sub(r'(?u)\W+', ' ', query)
query = re.sub(r'(?i)\b(CD|disc)\s*\d+', '', query)
And that resolved it.
Not sure why I encountered this again, as all the issues seem to be from years ago, and I have very new versions of everything. Here is the output from pip freeze and I'm running latest git version of beets which I installed with a fresh virtualenv and this update script. My python version is 3.9.2. I'm running arch.
I guess that workaround to encoding to ascii can be removed by now?
Huh; that's odd—from this snippet, I can't yet see any reason why we'd need that encode
; it looks objectively wrong. Thanks for doing the investigation!!
Any chance you would be willing to open a quick PR with this change so we can check it out?
@sampsyo sure! Here you go --> https://github.com/beetbox/beets/pull/3885
Just found this bug: when trying to import with the awesome discogs plugin I get the following error:
My beets options are set like this:
I'm using the most recent version and the asciify_path option has no effect on the error.