Request params encoded using system encoding
See original GitHub issuePerhaps I’m misunderstanding how this is supposed to work, but it looks like all request parameters are encoded using the system locale encoding. (https://github.com/wagnerrp/pytmdb3/blob/master/tmdb3/request.py#L70) This causes problems when the system locale cannot encode all the charaters in the parameters, plus, I have no idea how tmdb is expected to know what encoding you have used to encode the parameters, I suspect it should be using a constant encoding defined by the tmdb api. Portion of a relevant traceback:
File "/usr/local/lib/python2.7/dist-packages/flexget/plugins/api_tmdb.py", line 293, in lookup
result = _first_result(tmdb3.tmdb_api.searchMovie(title.lower(), adult=True, year=year))
File "/usr/local/lib/python2.7/dist-packages/tmdb3/tmdb_api.py", line 128, in searchMovie
return MovieSearchResult(Request('search/movie', **kwargs), locale=locale)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/request.py", line 71, in __init__
kwargs[k] = locale.encode(v)
File "/usr/local/lib/python2.7/dist-packages/tmdb3/locales.py", line 110, in encode
return dat.encode(self.encoding)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-13: ordinal not in range(256)
Downstream ticket: http://flexget.com/ticket/2392
Issue Analytics
- State:
- Created 10 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Java URL encoding of query string parameters - Stack Overflow
URLEncoder is the way to go. You only need to keep in mind to encode only the individual query string parameter name and/or...
Read more >Javascript | Encode URL Query Parameter | by Sonika - Medium
My Use case: Need to accept query string parameters in order to make GET requests. When to use encodeURIcomponent() and encodeURI() ? encodeURIComponent...
Read more >Guide to Java URL Encoding/Decoding - Baeldung
Simply put, URL encoding translates special characters from the URL to a representation that adheres to the spec and can be correctly ...
Read more >Encoding String Parameters in the URL Request
All string parameters in the URL request must be UTF-8 encoded. String parameters containing non-ASCII characters must be URL-encoded.
Read more >encodeURIComponent() - JavaScript - MDN Web Docs
The encodeURIComponent() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Did a bit of testing, looks like tmdb is expecting utf-8 encoding. Did a bit of a hack to get things working again:
tmdb3.locales.syslocale.encoding = 'utf-8'
fixed alsoTMDbError Internal error - Something went wrong. Contact TMDb.
ontmdb3.MovieSearch('some string with äüö')
Thanks @gazpachoking !