Skip to content

Commit

Permalink
Update client.py
Browse files Browse the repository at this point in the history
Added warnings in docstrings for functions that have been replaced and call other new functions.
  • Loading branch information
bparrott3 authored Dec 12, 2023
1 parent 1416d47 commit 5499292
Showing 1 changed file with 61 additions and 34 deletions.
95 changes: 61 additions & 34 deletions spotipy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,10 @@ def user_playlist_change_details(
collaborative=None,
description=None,
):
warnings.warn(
"You should use `playlist_change_details(playlist_id, ...)` instead",
DeprecationWarning,
)
""" Changes a playlist's name and/or public/private state
"""
This function is no longer in use, please use the recommended function in the warning!
Changes a playlist's name and/or public/private state
Parameters:
- user - the id of the user
Expand All @@ -840,12 +839,19 @@ def user_playlist_change_details(
- collaborative - optional is the playlist collaborative
- description - optional description of the playlist
"""
warnings.warn(
"You should use `playlist_change_details(playlist_id, ...)` instead",
DeprecationWarning,
)

return self.playlist_change_details(playlist_id, name, public,
collaborative, description)

def user_playlist_unfollow(self, user, playlist_id):
""" Unfollows (deletes) a playlist for a user
"""
This function is no longer in use, please use the recommended function in the warning!
Unfollows (deletes) a playlist for a user
Parameters:
- user - the id of the user
Expand All @@ -860,41 +866,52 @@ def user_playlist_unfollow(self, user, playlist_id):
def user_playlist_add_tracks(
self, user, playlist_id, tracks, position=None
):
warnings.warn(
"You should use `playlist_add_items(playlist_id, tracks)` instead",
DeprecationWarning,
)
""" Adds tracks to a playlist
"""
This function is no longer in use, please use the recommended function in the warning!
Adds tracks to a playlist
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- tracks - a list of track URIs, URLs or IDs
- position - the position to add the tracks
"""
warnings.warn(
"You should use `playlist_add_items(playlist_id, tracks)` instead",
DeprecationWarning,
)

tracks = [self._get_uri("track", tid) for tid in tracks]
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
"""
This function is no longer in use, please use the recommended function in the warning!
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
"""
warnings.warn(
"You should use `playlist_add_items(playlist_id, episodes)` instead",
DeprecationWarning,
)

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):
""" Replace all tracks in a playlist for a user
"""
This function is no longer in use, please use the recommended function in the warning!
Replace all tracks in a playlist for a user
Parameters:
- user - the id of the user
Expand All @@ -916,7 +933,10 @@ def user_playlist_reorder_tracks(
range_length=1,
snapshot_id=None,
):
""" Reorder tracks in a playlist from a user
"""
This function is no longer in use, please use the recommended function in the warning!
Reorder tracks in a playlist from a user
Parameters:
- user - the id of the user
Expand All @@ -939,14 +959,16 @@ def user_playlist_reorder_tracks(
def user_playlist_remove_all_occurrences_of_tracks(
self, user, playlist_id, tracks, snapshot_id=None
):
""" Removes all occurrences of the given tracks from the given playlist
"""
This function is no longer in use, please use the recommended function in the warning!
Removes all occurrences of the given tracks from the given playlist
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- tracks - the list of track ids to remove from the playlist
- snapshot_id - optional id of the playlist snapshot
"""
warnings.warn(
"You should use `playlist_remove_all_occurrences_of_items"
Expand All @@ -960,7 +982,10 @@ def user_playlist_remove_all_occurrences_of_tracks(
def user_playlist_remove_specific_occurrences_of_tracks(
self, user, playlist_id, tracks, snapshot_id=None
):
""" Removes all occurrences of the given tracks from the given playlist
"""
This function is no longer in use, please use the recommended function in the warning!
Removes all occurrences of the given tracks from the given playlist
Parameters:
- user - the id of the user
Expand Down Expand Up @@ -995,12 +1020,13 @@ def user_playlist_remove_specific_occurrences_of_tracks(

def user_playlist_follow_playlist(self, playlist_owner_id, playlist_id):
"""
Add the current authenticated user as a follower of a playlist.
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
This function is no longer in use, please use the recommended function in the warning!
Add the current authenticated user as a follower of a playlist.
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
"""
warnings.warn(
"You should use `current_user_follow_playlist(playlist_id)` instead",
Expand All @@ -1012,14 +1038,15 @@ def user_playlist_is_following(
self, playlist_owner_id, playlist_id, user_ids
):
"""
Check to see if the given users are following the given playlist
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.
This function is no longer in use, please use the recommended function in the warning!
Check to see if the given users are following the given playlist
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.
"""
warnings.warn(
"You should use `playlist_is_following(playlist_id, user_ids)` instead",
Expand Down

0 comments on commit 5499292

Please sign in to comment.