mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-10-10 11:38:36 +00:00
Initial run of 2to3
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
VERSION='2.0.1'
|
||||
from client import Spotify, SpotifyException
|
||||
from .client import Spotify, SpotifyException
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# coding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import sys
|
||||
import base64
|
||||
@@ -18,7 +18,7 @@ class SpotifyException(Exception):
|
||||
self.msg = msg
|
||||
|
||||
def __str__(self):
|
||||
return u'http status: {0}, code:{1} - {2}'.format(
|
||||
return 'http status: {0}, code:{1} - {2}'.format(
|
||||
self.http_status, self.code, self.msg)
|
||||
|
||||
class Spotify(object):
|
||||
@@ -101,7 +101,7 @@ class Spotify(object):
|
||||
r.raise_for_status()
|
||||
except:
|
||||
raise SpotifyException(r.status_code,
|
||||
-1, u'%s:\n %s' % (r.url, r.json()['error']['message']))
|
||||
-1, '%s:\n %s' % (r.url, r.json()['error']['message']))
|
||||
if len(r.text) > 0:
|
||||
results = r.json()
|
||||
if self.trace: # pragma: no cover
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import requests
|
||||
import os
|
||||
import json
|
||||
@@ -154,7 +154,7 @@ class SpotifyOAuth(object):
|
||||
if self.state:
|
||||
payload['state'] = self.state
|
||||
|
||||
urlparams = urllib.urlencode(payload)
|
||||
urlparams = urllib.parse.urlencode(payload)
|
||||
|
||||
return "%s?%s" % (self.OAUTH_AUTHORIZE_URL, urlparams)
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import oauth2
|
||||
from . import oauth2
|
||||
import spotipy
|
||||
|
||||
def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
@@ -32,7 +32,7 @@ def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
redirect_uri = os.getenv('SPOTIPY_REDIRECT_URI')
|
||||
|
||||
if not client_id:
|
||||
print '''
|
||||
print('''
|
||||
You need to set your Spotify API credentials. You can do this by
|
||||
setting environment variables like so:
|
||||
|
||||
@@ -42,7 +42,7 @@ def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
|
||||
Get your credentials at
|
||||
https://developer.spotify.com/my-applications
|
||||
'''
|
||||
''')
|
||||
raise spotipy.SpotifyException(550, -1, 'no credentials set')
|
||||
|
||||
sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri,
|
||||
@@ -55,7 +55,7 @@ def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
token_info = sp_oauth.get_cached_token()
|
||||
|
||||
if not token_info:
|
||||
print '''
|
||||
print('''
|
||||
|
||||
User authentication requires interaction with your
|
||||
web browser. Once you enter your credentials and
|
||||
@@ -63,19 +63,19 @@ def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
a url. Paste that url you were directed to to
|
||||
complete the authorization.
|
||||
|
||||
'''
|
||||
''')
|
||||
auth_url = sp_oauth.get_authorize_url()
|
||||
try:
|
||||
subprocess.call(["open", auth_url])
|
||||
print "Opening %s in your browser" % auth_url
|
||||
print("Opening %s in your browser" % auth_url)
|
||||
except:
|
||||
print "Please navigate here: %s" % auth_url
|
||||
print("Please navigate here: %s" % auth_url)
|
||||
|
||||
print
|
||||
print
|
||||
response = raw_input("Enter the URL you were redirected to: ")
|
||||
print
|
||||
print
|
||||
print()
|
||||
print()
|
||||
response = input("Enter the URL you were redirected to: ")
|
||||
print()
|
||||
print()
|
||||
|
||||
code = sp_oauth.parse_response_code(response)
|
||||
token_info = sp_oauth.get_access_token(code)
|
||||
|
Reference in New Issue
Block a user