-
Notifications
You must be signed in to change notification settings - Fork 954
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding example for unfollowing/deleting a playlist (#746)
* Adding example for deleting a playlist * Renaming to unfollow_playlist
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import argparse | ||
import logging | ||
|
||
import spotipy | ||
from spotipy.oauth2 import SpotifyOAuth | ||
|
||
logger = logging.getLogger('examples.unfollow_playlist') | ||
logging.basicConfig(level='DEBUG') | ||
|
||
''' | ||
Spotify doesn't have a dedicated endpoint for deleting a playlist. However, | ||
unfollowing a playlist has the effect of deleting it from the user's account. | ||
When a playlist is removed from the user's account, the system unfollows it, | ||
and then no longer shows it in playlist list.''' | ||
|
||
|
||
def get_args(): | ||
parser = argparse.ArgumentParser(description='Unfollows a playlist') | ||
parser.add_argument('-p', '--playlist', required=True, | ||
help='Playlist id') | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
args = get_args() | ||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth()) | ||
sp.current_user_unfollow_playlist(args.playlist) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |