spotipy/examples/follow_playlist.py
jonathan-huston ba01a6aee5
Examples directory updates (#1055)
* Fixed scripts in examples directory that didn't work, deleted any redundant examples.

* Added examples for methods related to audiobooks, shows and episodes

* Updated changelog

---------

Co-authored-by: Stéphane Bruckert <stephane.bruckert@gmail.com>
2025-01-12 14:47:10 +00:00

22 lines
619 B
Python

# Follow a playlist
import argparse
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = 'playlist-modify-public'
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
def get_args():
parser = argparse.ArgumentParser(description='Follows a playlist based on playlist ID')
# Default to Top 50 Global if no playlist is provided
parser.add_argument('-p', '--playlist', help='Playlist ID', nargs='?', default='37i9dQZEVXbMDoHDwVN2tF')
return parser.parse_args()
def main():
args = get_args()
sp.current_user_follow_playlist(args.playlist)
if __name__ == '__main__':
main()