Yetangitu / Spodcast

Spodcast is a caching Spotify podcast to RSS proxy. Using Spodcast you can follow Spotify-hosted netcasts/podcasts using any player which supports RSS, thus enabling the use of older hardware which is not compatible with the Spotify (web) app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

buzzsprout.com requires useragent

markclowes opened this issue · comments

When trying to retrieve a podcast that uses buzzsprout.com, e.g. https://open.spotify.com/episode/0r7ir53f9IEB1w4XTIFddJ we get a 403 error:

INFO:spodcast.podcast:Fetching episode information...

Traceback (most recent call last):
File "/home/pi/spodcast/bin/spodcast", line 8, in
sys.exit(main())
File "/home/pi/spodcast/lib/python3.9/site-packages/spodcast/main.py", line 42, in main
args.func(args)
File "/home/pi/spodcast/lib/python3.9/site-packages/spodcast/app.py", line 24, in client
download_episode(episode_id)
File "/home/pi/spodcast/lib/python3.9/site-packages/spodcast/podcast.py", line 176, in download_episode
path, size, mimetype = download_file(download_url, filepath)
File "/home/pi/spodcast/lib/python3.9/site-packages/spodcast/podcast.py", line 77, in download_file
r.raise_for_status() # Will only raise for 4xx codes, so...
File "/home/pi/spodcast/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.buzzsprout.com/2109129/15240378-charlie-stig-live-q-a-in-person-cbdcs-v-crypto-ai-v-ml-the-future.mp3

It seems as though useragents of "python*" are blocked. requests package will send a 'python-requests' useragent if none is specified, so we can just specify an empty header. We can change the function download_file in podcast.py to include an empty useragent. No 403 and the download completes then:

r = requests.get(url, stream=True, allow_redirects=True, headers={ 'User-Agent': '' })