mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
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:
parent
5175f19851
commit
13593c54cb
23
examples/follow_playlist.py
Normal file
23
examples/follow_playlist.py
Normal 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()
|
||||
Loading…
Reference in New Issue
Block a user