modified docstring for playlist_add_items to no longer accept IDs

This commit is contained in:
oliveraw authored and GitHub committed 2022-12-16 19:17:37 +00:00
1 parent edd3f29a2c
commit 922d51df02
15 files changed
+63 -37

No files matched your search

+2 -2
View File
@@ -11,7 +11,7 @@ scope = 'playlist-modify-public'
def get_args():
parser = argparse.ArgumentParser(description='Adds track to user playlist')
parser.add_argument('-t', '--tids', action='append',
parser.add_argument('-u', '--uris', action='append',
required=True, help='Track ids')
parser.add_argument('-p', '--playlist', required=True,
help='Playlist to add track to')
@@ -22,7 +22,7 @@ def main():
args = get_args()
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
sp.playlist_add_items(args.playlist, args.tids)
sp.playlist_add_items(args.playlist, args.uris)
if __name__ == '__main__':
+1 -1
View File
@@ -13,7 +13,7 @@ Prerequisites
export FLASK_ENV=development
// so that you can invoke the app outside of the file's directory include
export FLASK_APP=/path/to/spotipy/examples/app.py
// on Windows, use `SET` instead of `export`
Run app.py
+3 -2
View File
@@ -1,4 +1,4 @@
#Shows the list of all songs sung by the artist or the band
# Shows the list of all songs sung by the artist or the band
import argparse
import logging
@@ -34,7 +34,7 @@ def show_album_tracks(album):
results = sp.next(results)
tracks.extend(results['items'])
for i, track in enumerate(tracks):
logger.info('%s. %s', i+1, track['name'])
logger.info('%s. %s', i + 1, track['name'])
def show_artist_albums(artist):
@@ -60,6 +60,7 @@ def show_artist(artist):
if len(artist['genres']) > 0:
logger.info('Genres: %s', ','.join(artist['genres']))
def main():
args = get_args()
artist = get_artist(args.artist)
+11 -7
View File
@@ -3,21 +3,25 @@ import argparse
import spotipy
from spotipy.oauth2 import SpotifyOAuth
def get_args():
parser = argparse.ArgumentParser(description='Follows a playlist based on playlist ID')
parser.add_argument('-p', '--playlist', required=True, help='Playlist ID')
return parser.parse_args()
def main():
args = get_args()
if args.playlist is None:
# Uses the Spotify Global Top 50 playlist
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist('37i9dQZEVXbMDoHDwVN2tF')
# Uses the Spotify Global Top 50 playlist
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist(
'37i9dQZEVXbMDoHDwVN2tF')
else:
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist(args.playlist)
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist(args.playlist)
if __name__ == '__main__':
main()
+1 -1
View File
@@ -5,4 +5,4 @@ from spotipy.oauth2 import SpotifyOAuth
# set open_browser=False to prevent Spotipy from attempting to open the default browser
spotify = spotipy.Spotify(auth_manager=SpotifyOAuth(open_browser=False))
print(spotify.me())
print(spotify.me())
+1 -1
View File
@@ -7,4 +7,4 @@ while True:
username = input("Type the Spotify user ID to use: ")
token = util.prompt_for_user_token(username, show_dialog=True)
sp = spotipy.Spotify(token)
pprint(sp.me())
pprint(sp.me())
+1 -1
View File
@@ -8,4 +8,4 @@ sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
results = sp.current_user_playlists(limit=50)
for i, item in enumerate(results['items']):
print("%d %s" % (i, item['name']))
print("%d %s" % (i, item['name']))
+1 -1
View File
@@ -13,4 +13,4 @@ for sp_range in ranges:
results = sp.current_user_top_tracks(time_range=sp_range, limit=50)
for i, item in enumerate(results['items']):
print(i, item['name'], '//', item['artists'][0]['name'])
print()
print()
+1 -2
View File
@@ -7,7 +7,6 @@ sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="YOUR_APP_CLIENT_ID",
client_secret="YOUR_APP_CLIENT_SECRET",
redirect_uri="YOUR_APP_REDIRECT_URI",
scope="playlist-modify-private"
))
))
sp.playlist_add_items('playlist_id', ['list_of_items'])
+3 -3
View File
@@ -12,10 +12,10 @@ while True:
offset=offset,
fields='items.track.id,total',
additional_types=['track'])
if len(response['items']) == 0:
break
pprint(response['items'])
offset = offset + len(response['items'])
print(offset, "/", response['total'])
print(offset, "/", response['total'])
+1 -1
View File
@@ -1,4 +1,4 @@
#Shows the name of the artist/band and their image by giving a link
# Shows the name of the artist/band and their image by giving a link
import sys
from spotipy.oauth2 import SpotifyClientCredentials
+1 -1
View File
@@ -16,4 +16,4 @@ sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
playlists = sp.user_playlists(username)
for playlist in playlists['items']:
print(playlist['name'])
print(playlist['name'])