animec icon indicating copy to clipboard operation
animec copied to clipboard

fix fetching genre of a single-genre anime + UnicodeEncodeError

Open shravanasati opened this issue 1 year ago • 1 comments

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 avatar Mar 20 '23 17:03 shravanasati

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.

shravanasati avatar Mar 21 '23 14:03 shravanasati