Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

fix fetching genre of a single-genre anime + UnicodeEncodeError #11

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

shravanasati
Copy link

The module failed to fetch genres for an anime with only a single genre listed on MAL, like Lycoris Recoil.

This was because the singular noun "Genre" was used instead of "Genres".

The addition of an or condition fixed it.

Thanks for your fantastic work.

@shravanasati shravanasati changed the title fix fetching genre of an anime with a single genre fix fetching genre of a single-genre anime + UnicodeEncodeError Mar 21, 2023
@shravanasati
Copy link
Author

For anime like Saiki Kusuo no Ψ-nan, the myanimelist URL contained non-ASCII characters in the request path which raised a UnicodeEncodeError when using urllib.request.urlopen.

The solution was to quote the path part of requests to percent-escape those non-ASCII characters.

Example: https://myanimelist.net/anime/33255/Saiki_Kusuo_no_Ψ-nan to https://myanimelist.net/anime/33255/Saiki_Kusuo_no_%CE%A8-nan

Although this solution works for now, I'd suggest using the requests library which supports this out-of-the-box.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant