mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-04 23:17:48 +00:00
Repackaged for saner imports
This commit is contained in:
parent
a48feaab66
commit
8dcaf7dba6
@ -16,10 +16,6 @@ the library simply by downloading the distribution, unpack it and install in the
|
|||||||
|
|
||||||
- [Requests](https://github.com/kennethreitz/requests) - spotipy requires the requests package to be installed
|
- [Requests](https://github.com/kennethreitz/requests) - spotipy requires the requests package to be installed
|
||||||
|
|
||||||
## Limitations
|
|
||||||
This version of the library does not support user authentication
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
To get started:
|
To get started:
|
||||||
@ -51,6 +47,7 @@ A full set of examples can be found in the [Spotipy examples directory](https://
|
|||||||
- artist_top_tracks - gets info about an artist's top tracks
|
- artist_top_tracks - gets info about an artist's top tracks
|
||||||
- user - gets profile info for a user
|
- user - gets profile info for a user
|
||||||
- search - searches for artists, albums or tracks
|
- search - searches for artists, albums or tracks
|
||||||
|
- simple oauth flow
|
||||||
|
|
||||||
Refer to the [Spotify API documentation](https://developer.spotify.com/spotify-web-api/) for details on the methods and parameters.
|
Refer to the [Spotify API documentation](https://developer.spotify.com/spotify-web-api/) for details on the methods and parameters.
|
||||||
|
|
||||||
@ -61,7 +58,6 @@ Methods that take item IDs (such as the track, album and artist methods) accept
|
|||||||
- 3HfB5hBU0dmBt8T0iCmH42
|
- 3HfB5hBU0dmBt8T0iCmH42
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Reporting Issues
|
## Reporting Issues
|
||||||
|
|
||||||
If you have suggestions, bugs or other issues specific to this library, file them [here](https://github.com/plamere/spotipy/issues) or contact me
|
If you have suggestions, bugs or other issues specific to this library, file them [here](https://github.com/plamere/spotipy/issues) or contact me
|
||||||
@ -69,6 +65,7 @@ at [paul@echonest.com](mailto:paul@echonest.com). Or just send me a pull request
|
|||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
|
- 1.1 - 04/05/2014 - Initial release
|
||||||
- 1.0 - 04/05/2014 - Initial release
|
- 1.0 - 04/05/2014 - Initial release
|
||||||
- 1.1 - 05/16/2014 - Adapt to web API changes. Early auth support.
|
- 1.1 - 05/18/2014 - Repackaged for saner imports
|
||||||
|
|
||||||
|
@ -2,22 +2,27 @@
|
|||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
import oauth2
|
import spotipy.oauth2 as oauth2
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
username = sys.argv[1]
|
username = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
print "Whoops, need your username!"
|
print "Whoops, need your username!"
|
||||||
print "usage: python user_playlists.py [username]"
|
print "usage: python user_playlists.py [username]"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# Create these via developer.spotify.com/my-applications
|
# Create these via developer.spotify.com/my-applications
|
||||||
|
|
||||||
client_id = ''
|
client_id = os.getenv('CLIENT_ID')
|
||||||
client_secret = ''
|
client_secret = os.getenv('CLIENT_SECRET')
|
||||||
redirect_uri = ''
|
redirect_uri = os.getenv('REDIRECT_URI')
|
||||||
|
|
||||||
|
print 'client_id', client_id
|
||||||
|
print 'client_secret', client_secret
|
||||||
|
print 'redirect_uri', redirect_uri
|
||||||
|
|
||||||
# Oauth flow
|
# Oauth flow
|
||||||
sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri)
|
sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri)
|
||||||
@ -31,4 +36,4 @@ access_token = sp_oauth.get_access_token(code)
|
|||||||
|
|
||||||
sp = spotipy.Spotify(auth=access_token)
|
sp = spotipy.Spotify(auth=access_token)
|
||||||
playlists = sp.user_playlists(username)
|
playlists = sp.user_playlists(username)
|
||||||
pprint.pprint(playlists)
|
pprint.pprint(playlists)
|
||||||
|
2
setup.py
2
setup.py
@ -9,4 +9,4 @@ setup(
|
|||||||
author_email="paul@echonest.com",
|
author_email="paul@echonest.com",
|
||||||
url='http://github.com/plamere/spotipy',
|
url='http://github.com/plamere/spotipy',
|
||||||
install_requires=['requests>=1.0', ],
|
install_requires=['requests>=1.0', ],
|
||||||
py_modules=['spotipy'],)
|
py_modules=['spotipy', 'spotify_oauth2'],)
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
__all__ = ['oauth2']
|
||||||
|
|
||||||
''' A simple and thin Python library for the Spotify Web API
|
''' A simple and thin Python library for the Spotify Web API
|
||||||
'''
|
'''
|
||||||
|
|
@ -2,6 +2,7 @@ import base64
|
|||||||
import urllib
|
import urllib
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
print ('oauth2 is here')
|
||||||
|
|
||||||
class SpotifyOauthError(Exception):
|
class SpotifyOauthError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -53,4 +54,4 @@ class SpotifyOAuth(object):
|
|||||||
response = requests.post(self.OAUTH_TOKEN_URL, data=payload, headers=headers, verify=True)
|
response = requests.post(self.OAUTH_TOKEN_URL, data=payload, headers=headers, verify=True)
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
raise SpotifyOauthError(response.reason)
|
raise SpotifyOauthError(response.reason)
|
||||||
return response.json()['access_token']
|
return response.json()['access_token']
|
Loading…
Reference in New Issue
Block a user