spotipy/examples/user_saved_shows.py
2025-01-18 15:21:51 +00:00

30 lines
800 B
Python

"""
List current user's saved shows
Usage: user_saved_shows -l <num> -o <num>
"""
import argparse
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = 'user-library-read'
def get_args():
parser = argparse.ArgumentParser(description='Show user\'s saved shows')
parser.add_argument('-l', '--limit', default=20, help='Num of shows to return')
parser.add_argument('-o', '--offset', default=0, help='Index of first show to return')
return parser.parse_args()
def main():
args = get_args()
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
results = sp.current_user_saved_shows(limit=args.limit, offset=args.offset)
# Print episode names
for item in results['items']:
print(item['show']['name'])
if __name__ == '__main__':
main()