remove unneccesary whitespaces, shorten some lines, and add name to contibutors

This commit is contained in:
Harrison 2019-08-12 18:27:10 -05:00 committed by Stephane Bruckert
parent 43a4de0314
commit d8d9f290fb
8 changed files with 48 additions and 44 deletions

View File

@ -5,7 +5,7 @@ Welcome to Spotipy!
===================================
*Spotipy* is a lightweight Python library for the `Spotify Web API
<https://developer.spotify.com/web-api/>`_. With *Spotipy*
you get full access to all of the music data provided by the Spotify platform.
you get full access to all of the music data provided by the Spotify platform.
Here's a quick example of using *Spotipy* to list the names of all the albums
released by the artist 'Birdy'::
@ -106,17 +106,17 @@ Even if your script does not have an accessible URL you need to specify one
when registering your application where the spotify authentication API will
redirect to after successful login. The URL doesn't need to work or be
accessible, you can specify "http://localhost/", after successful login you
just need to copy the "http://localhost/?code=..." URL from your browser
just need to copy the "http://localhost/?code=..." URL from your browser
and paste it to the console where your script is running.
Register your app at
Register your app at
`My Applications
<https://developer.spotify.com/my-applications/#!/applications>`_.
*spotipy* supports two authorization flows:
- The **Authorization Code flow** This method is suitable for long-running applications
- The **Authorization Code flow** This method is suitable for long-running applications
which the user logs into once. It provides an access token that can be refreshed.
- The **Client Credentials flow** The method makes it possible
@ -132,14 +132,14 @@ user. You can pass your app credentials directly into the method as arguments::
util.prompt_for_user_token(username,scope,client_id='your-spotify-client-id',client_secret='your-spotify-client-secret',redirect_uri='your-app-redirect-url')
or if you are reluctant to immortalize your app credentials in your source code,
or if you are reluctant to immortalize your app credentials in your source code,
you can set environment variables like so::
export SPOTIPY_CLIENT_ID='your-spotify-client-id'
export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
export SPOTIPY_REDIRECT_URI='your-app-redirect-url'
Call ``util.prompt_for_user_token`` method with the username and the
Call ``util.prompt_for_user_token`` method with the username and the
desired scope (see `Using
Scopes <https://developer.spotify.com/web-api/using-scopes/>`_ for information
about scopes) and credentials. This will coordinate the user authorization via
@ -195,8 +195,8 @@ class SpotifyClientCredentials that can be used to authenticate requests like so
playlists = None
Client credentials flow is appropriate for requests that do not require access to a
user's private data. Even if you are only making calls that do not require
authorization, using this flow yields the benefit of a higher rate limit
user's private data. Even if you are only making calls that do not require
authorization, using this flow yields the benefit of a higher rate limit
IDs URIs and URLs
=======================
@ -260,7 +260,7 @@ Shows the contents of every playlist owned by a user::
def show_tracks(tracks):
for i, item in enumerate(tracks['items']):
track = item['track']
print(" %d %32.32s %s" % (i, track['artists'][0]['name'],
print(" %d %32.32s %s" % (i, track['artists'][0]['name'],
track['name']))
@ -282,7 +282,7 @@ Shows the contents of every playlist owned by a user::
print()
print(playlist['name'])
print (' total tracks', playlist['tracks']['total'])
results = sp.user_playlist(username, playlist['id'],
results = sp.user_playlist(username, playlist['id'],
fields="tracks,next")
tracks = results['tracks']
show_tracks(tracks)
@ -298,7 +298,7 @@ More Examples
There are many more examples of how to use *Spotipy* in the `Examples
Directory <https://github.com/plamere/spotipy/tree/master/examples>`_ on Github
API Reference
API Reference
==============
:mod:`client` Module
@ -336,7 +336,7 @@ You can ask questions about Spotipy on Stack Overflow. Dont forget to add t
http://stackoverflow.com/questions/ask
If you think you've found a bug, let us know at
If you think you've found a bug, let us know at
`Spotify Issues <https://github.com/plamere/spotipy/issues>`_
@ -344,24 +344,25 @@ Contribute
==========
Spotipy authored by Paul Lamere (plamere) with contributions by:
- Daniel Beaudry // danbeaudry
- Faruk Emre Sahin // fsahin
- George // rogueleaderr
- Henry Greville // sethaurus
- Hugo // hugovk
- José Manuel Pérez // JMPerez
- Lucas Nunno // lnunno
- Lynn Root // econchick
- Matt Dennewitz // mattdennewitz
- Matthew Duck // mattduck
- Michael Thelin // thelinmichael
- Ryan Choi // ryankicks
- Simon Metson // drsm79
- Daniel Beaudry // danbeaudry
- Faruk Emre Sahin // fsahin
- George // rogueleaderr
- Henry Greville // sethaurus
- Hugo // hugovk
- José Manuel Pérez // JMPerez
- Lucas Nunno // lnunno
- Lynn Root // econchick
- Matt Dennewitz // mattdennewitz
- Matthew Duck // mattduck
- Michael Thelin // thelinmichael
- Ryan Choi // ryankicks
- Simon Metson // drsm79
- Steve Winton // swinton
- Tim Balzer // timbalzer
- corycorycory // corycorycory
- Tim Balzer // timbalzer
- corycorycory // corycorycory
- Nathan Coleman // nathancoleman
- Michael Birtwell // mbirtwell
- Harrison Hayes // Harrison97
License
=======

View File

@ -35,7 +35,7 @@ def show_artist_albums(id):
unique = set() # skip duplicate albums
for album in albums:
name = album['name'].lower()
if not name in unique:
if not name in unique:
print(name)
unique.add(name)
show_album_tracks(album)

View File

@ -10,7 +10,7 @@ if len(sys.argv) > 2:
username = sys.argv[1]
tids = sys.argv[2:]
else:
print("Usage: %s username track-id ..." % (sys.argv[0],))
print("Usage: %s username track-id ..." % (sys.argv[0],))
sys.exit()
token = util.prompt_for_user_token(username, scope)

View File

@ -26,6 +26,6 @@ if token:
for i, item in enumerate(results['items']):
print (i, item['name'], '//', item['artists'][0]['name'])
print ()
else:
print("Can't get token for", username)

View File

@ -60,4 +60,4 @@ if __name__ == '__main__':
import sys
title = ' '.join(sys.argv[1:])
make_chain(sys.argv[1].lower())

View File

@ -1,6 +1,6 @@
# Gets all the public playlists for the given
# user. Uses Client Credentials flow
#
#
import sys
import spotipy

View File

@ -389,7 +389,7 @@ class Spotify(object):
def playlist(self, playlist_id, fields=None, market=None):
""" Gets playlist by id
Parameters:
- playlist - the id of the playlist
- fields - which fields to return
@ -400,7 +400,7 @@ class Spotify(object):
return self._get("playlists/%s" % (plid), fields=fields)
def user_playlist_tracks(self, user, playlist_id=None, fields=None,
limit=100, offset=0, market=None):
""" Get full details of the tracks of a playlist owned by a user.
@ -546,9 +546,11 @@ class Spotify(object):
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- tracks - an array of objects containing Spotify URIs of the tracks to remove with their current positions in the playlist. For example:
[ { "uri":"4iV5W9uYEdYUVa79Axb7Rh", "positions":[2] },
{ "uri":"1301WleyT98MSxVHPZCA6M", "positions":[7] } ]
- tracks - an array of objects containing Spotify URIs of the
tracks to remove with their current positions in the
playlist. For example:
[ { "uri":"4iV5W9uYEdYUVa79Axb7Rh", "positions":[2] },
{ "uri":"1301WleyT98MSxVHPZCA6M", "positions":[7] } ]
- snapshot_id - optional id of the playlist snapshot
"""
@ -583,7 +585,8 @@ class Spotify(object):
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
- user_ids - the ids of the users that you want to check to see if they follow the playlist. Maximum: 5 ids.
- user_ids - the ids of the users that you want to check to see
if they follow the playlist. Maximum: 5 ids.
"""
return self._get("users/{}/playlists/{}/followers/contains?ids={}".format(playlist_owner_id, playlist_id, ','.join(user_ids)))
@ -705,7 +708,7 @@ class Spotify(object):
Parameters:
- limit - the number of entities to return
'''
'''
return self._get('me/player/recently-played', limit=limit)
def current_user_saved_albums_delete(self, albums=[]):
@ -760,7 +763,7 @@ class Spotify(object):
- ids - a list of artist IDs
'''
return self._delete('me/following?type=artist&ids=' + ','.join(ids))
def user_unfollow_users(self, ids=[]):
''' Unfollow one or more users
Parameters:

View File

@ -25,7 +25,7 @@ CLIENT_CREDS_ENV_VARS = {
def prompt_for_user_token(username, scope=None, client_id = None,
client_secret = None, redirect_uri = None, cache_path = None):
''' prompts the user to login if necessary and returns
the user token suitable for use with the spotipy.Spotify
the user token suitable for use with the spotipy.Spotify
constructor
Parameters:
@ -57,13 +57,13 @@ def prompt_for_user_token(username, scope=None, client_id = None,
export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
export SPOTIPY_REDIRECT_URI='your-app-redirect-url'
Get your credentials at
Get your credentials at
https://developer.spotify.com/my-applications
''')
raise spotipy.SpotifyException(550, -1, 'no credentials set')
cache_path = cache_path or ".cache-" + username
sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri,
sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri,
scope=scope, cache_path=cache_path)
# try to get a valid token for this user, from the cache,
@ -98,7 +98,7 @@ def prompt_for_user_token(username, scope=None, client_id = None,
response = input("Enter the URL you were redirected to: ")
print()
print()
print()
code = sp_oauth.parse_response_code(response)
token_info = sp_oauth.get_access_token(code)