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

28 lines
716 B
Python

'''
usage: show_tracks.py path_of_ids
given a list of track IDs show the artist and track name
'''
from spotipy.oauth2 import SpotifyOAuth
import spotipy
import argparse
def get_args():
parser = argparse.ArgumentParser(description='Print artist and track name given a list of track IDs')
parser.add_argument('-u', '--uris', nargs='+',
required=True, help='Track ids')
return parser.parse_args()
def main():
args = get_args()
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
track_list = sp.tracks(args.uris)
for track in track_list['tracks']:
print(track['name'] + ' - ' + track['artists'][0]['name'])
if __name__ == '__main__':
main()