mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
modified docstring for playlist_add_items to no longer accept IDs
This commit is contained in:
parent
edd3f29a2c
commit
922d51df02
@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
// Add new changes below this line
|
// Add new changes below this line
|
||||||
|
- Modified docstring for playlist_add_items() to accept "only URIs or URLs",
|
||||||
|
with intended deprecation for IDs in v3
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|||||||
@ -11,14 +11,15 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import sys, os
|
import spotipy
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#sys.path.insert(0, os.path.abspath('.'))
|
#sys.path.insert(0, os.path.abspath('.'))
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
sys.path.insert(0, os.path.abspath('.'))
|
||||||
import spotipy
|
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ scope = 'playlist-modify-public'
|
|||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser(description='Adds track to user playlist')
|
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')
|
required=True, help='Track ids')
|
||||||
parser.add_argument('-p', '--playlist', required=True,
|
parser.add_argument('-p', '--playlist', required=True,
|
||||||
help='Playlist to add track to')
|
help='Playlist to add track to')
|
||||||
@ -22,7 +22,7 @@ def main():
|
|||||||
args = get_args()
|
args = get_args()
|
||||||
|
|
||||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -60,6 +60,7 @@ def show_artist(artist):
|
|||||||
if len(artist['genres']) > 0:
|
if len(artist['genres']) > 0:
|
||||||
logger.info('Genres: %s', ','.join(artist['genres']))
|
logger.info('Genres: %s', ','.join(artist['genres']))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = get_args()
|
args = get_args()
|
||||||
artist = get_artist(args.artist)
|
artist = get_artist(args.artist)
|
||||||
|
|||||||
@ -3,21 +3,25 @@ import argparse
|
|||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
from spotipy.oauth2 import SpotifyOAuth
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser(description='Follows a playlist based on playlist ID')
|
parser = argparse.ArgumentParser(description='Follows a playlist based on playlist ID')
|
||||||
parser.add_argument('-p', '--playlist', required=True, help='Playlist ID')
|
parser.add_argument('-p', '--playlist', required=True, help='Playlist ID')
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = get_args()
|
args = get_args()
|
||||||
|
|
||||||
if args.playlist is None:
|
if args.playlist is None:
|
||||||
# Uses the Spotify Global Top 50 playlist
|
# Uses the Spotify Global Top 50 playlist
|
||||||
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist('37i9dQZEVXbMDoHDwVN2tF')
|
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist(
|
||||||
|
'37i9dQZEVXbMDoHDwVN2tF')
|
||||||
|
|
||||||
else:
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@ -10,4 +10,3 @@ sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="YOUR_APP_CLIENT_ID",
|
|||||||
))
|
))
|
||||||
|
|
||||||
sp.playlist_add_items('playlist_id', ['list_of_items'])
|
sp.playlist_add_items('playlist_id', ['list_of_items'])
|
||||||
|
|
||||||
|
|||||||
@ -846,8 +846,27 @@ class Spotify(object):
|
|||||||
- tracks - a list of track URIs, URLs or IDs
|
- tracks - a list of track URIs, URLs or IDs
|
||||||
- position - the position to add the tracks
|
- position - the position to add the tracks
|
||||||
"""
|
"""
|
||||||
|
tracks = [self._get_uri("track", tid) for tid in tracks]
|
||||||
return self.playlist_add_items(playlist_id, tracks, position)
|
return self.playlist_add_items(playlist_id, tracks, position)
|
||||||
|
|
||||||
|
def user_playlist_add_episodes(
|
||||||
|
self, user, playlist_id, episodes, position=None
|
||||||
|
):
|
||||||
|
warnings.warn(
|
||||||
|
"You should use `playlist_add_items(playlist_id, episodes)` instead",
|
||||||
|
DeprecationWarning,
|
||||||
|
)
|
||||||
|
""" Adds episodes to a playlist
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- user - the id of the user
|
||||||
|
- playlist_id - the id of the playlist
|
||||||
|
- episodes - a list of track URIs, URLs or IDs
|
||||||
|
- position - the position to add the episodes
|
||||||
|
"""
|
||||||
|
episodes = [self._get_uri("episode", tid) for tid in episodes]
|
||||||
|
return self.playlist_add_items(playlist_id, episodes, position)
|
||||||
|
|
||||||
def user_playlist_replace_tracks(self, user, playlist_id, tracks):
|
def user_playlist_replace_tracks(self, user, playlist_id, tracks):
|
||||||
""" Replace all tracks in a playlist for a user
|
""" Replace all tracks in a playlist for a user
|
||||||
|
|
||||||
@ -1032,7 +1051,7 @@ class Spotify(object):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- playlist_id - the id of the playlist
|
- playlist_id - the id of the playlist
|
||||||
- items - a list of track/episode URIs, URLs or IDs
|
- items - a list of track/episode URIs or URLs
|
||||||
- position - the position to add the tracks
|
- position - the position to add the tracks
|
||||||
"""
|
"""
|
||||||
plid = self._get_id("playlist", playlist_id)
|
plid = self._get_id("playlist", playlist_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user