spotipy/examples/user_saved_shows.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

29 lines
799 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()