Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rdio-simple python fails with unicode strings #23

Closed
simao opened this issue May 4, 2014 · 1 comment · Fixed by #24
Closed

rdio-simple python fails with unicode strings #23

simao opened this issue May 4, 2014 · 1 comment · Fixed by #24
Assignees

Comments

@simao
Copy link

simao commented May 4, 2014

Hello,

I am trying to call the api with a string containing unicde, but I always get an error, doesn't matter if I encode it with encode or not.

The following code can be used to reproduce the issue:

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import sys,os.path
import json
import time
import traceback

from rdio import Rdio

try:
    from urllib.error import HTTPError
except ImportError:
    from urllib2 import HTTPError

rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), AUTH_TOKEN)

name = "Röyksopp"

search = rdio.call('search', {'query': name, 'types': 'Album'})

print search

This throws:

Traceback (most recent call last):
  File "issue.py", line 26, in <module>
    search = rdio.call('search', {'query': name, 'types': 'Album'})
  File "/home/simao/spotify-export/rdio.py", line 77, in call
    return json.loads(self.__signed_post('http://api.rdio.com/1/', params))
  File "/home/simao/spotify-export/rdio.py", line 45, in __signed_post
    req = Request(url, urlencode(params).encode('utf-8'),
  File "/usr/lib/python2.7/urllib.py", line 1332, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)
@dasevilla
Copy link
Contributor

I can confirm this issue and I'm looking into a fix.

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

Successfully merging a pull request may close this issue.

2 participants