mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
Urllib compatibility fix to support both python 2 & 3
This commit is contained in:
parent
d08f7a82dc
commit
d6a14bc83d
@ -1,13 +1,20 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import base64
|
import base64
|
||||||
import urllib.request, urllib.parse, urllib.error
|
|
||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# Workaround to support both python 2 & 3
|
||||||
|
try:
|
||||||
|
import urllib.request, urllib.error
|
||||||
|
import urllib.parse as urllibparse
|
||||||
|
except ImportError:
|
||||||
|
import urllib as urllibparse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SpotifyOauthError(Exception):
|
class SpotifyOauthError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -155,7 +162,7 @@ class SpotifyOAuth(object):
|
|||||||
if self.state:
|
if self.state:
|
||||||
payload['state'] = self.state
|
payload['state'] = self.state
|
||||||
|
|
||||||
urlparams = urllib.parse.urlencode(payload)
|
urlparams = urllibparse.urlencode(payload)
|
||||||
|
|
||||||
return "%s?%s" % (self.OAUTH_AUTHORIZE_URL, urlparams)
|
return "%s?%s" % (self.OAUTH_AUTHORIZE_URL, urlparams)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user