deepa vijay
deepa vijay

Reputation: 1

how to retrieve spotify podcasts using spotipy library?

Can we access podcasts from Spotify using Python spotipy library? If yes, Please explain.

I've the following code:

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import os

proxy = 'http:...'

os.environ['http_proxy'] = proxy 
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_PROXY'] = proxy

client_id = ""
client_secret = ""



birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
results = spotify.artist_albums(birdy_uri, album_type='album')
albums = results['items']
while results['next']:
    results = spotify.next(results)
    albums.extend(results['items'])

for album in albums:
    print(album['name'])

This code gives me only the albums list of the artist, but I need podcasts of it?

Upvotes: 0

Views: 1791

Answers (2)

Sergio Lucero
Sergio Lucero

Reputation: 896

The show method is currently available (as of March 2024) and can be used like so:

show = spotify.show(podcast_id)
pods = show['episodes']['items']

You will have the following info available for each episode:

['audio_preview_url', 'description', 'duration_ms', 'explicit',
 'external_urls', 'href', 'html_description', 'id', 'images',
 'is_externally_hosted', 'is_playable', 'language', 'languages', 'name',
 'release_date', 'release_date_precision', 'type', 'uri']

Upvotes: 0

XPhyro
XPhyro

Reputation: 528

It does what you say. If you want podcasts, you should use spotify.show(...) instead of spotify.artist_albums(...). Beware that spotify.show is currently not in the release version of spotipy, so you have to install the library from GitHub, see this to do so.

Upvotes: 0

Related Questions