Added a new example: follow_playlist.py (#804)

* Create playlist_all_local_tracks.py

* Delete playlist_all_local_tracks.py

* Create follow_playlist.py
This commit is contained in:
Logan O'Connell authored and GitHub committed 2022-06-18 23:19:27 +01:00
1 parent 5175f19851
commit 13593c54cb
1 file changed
+23
+23
View File
@@ -0,0 +1,23 @@
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')
else:
spotipy.Spotify(auth_manager=SpotifyOAuth()).current_user_follow_playlist(args.playlist)
if __name__ == '__main__':
main()