mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 16:45:50 +03:00
[GH-ISSUE #139] [BUG] base62.encode() not working as intended on byte strings #18
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Yetangitu on GitHub (Jun 30, 2022).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/139
While refactoring spodcast to use librespot-python-provided interfaces instead of doing raw API access I hit upon a snag in the base62 encoder: it does not seem to be able to encode byte strings while it is fed such through the various
XxxId.to_spotify_uri()methods (inlibrespot.metadata) by means ofutil.hex_to_bytes():PlayableId.base62.encode(util.hex_to_bytes(self.__hex_id)))Here's what happens (text between brackets - () - is produced by instrumentation, as is the actual line on which the fault occurs (which otherwise would have occurred on line 67:
translation[i] = dictionary[int.from_bytes(indices[i].encode(),"big")]):This code seems to be transpiled from the java version in https://github.com/librespot-org/librespot-java/blob/dev/lib/src/main/java/xyz/gianlu/librespot/common/Base62.java - has the result been tested to be functional?
I'd suggest ditching this piece of code and using one of the existing base62 libraries (pybase62 seems to work, I'm using it in spodcast to circumvent these problems), either inlined or as an import.
@kokarare1212 commented on GitHub (Jul 11, 2022):
Thank you for your patience.
It seems that the encoding and decoding of strings (especially the conversion of str and bytes) was not working properly.
@tacohitbox commented on GitHub (Feb 2, 2023):
Any progress on this?
@kokarare1212 commented on GitHub (Feb 2, 2023):
I believe this was fixed in v0.0.7.
@tacohitbox commented on GitHub (Feb 3, 2023):
Ah, might be a different issue for me. I'll open it in a bit.