Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buzzsprout.com requires useragent #45

Open
markclowes opened this issue Jun 15, 2024 · 0 comments
Open

buzzsprout.com requires useragent #45

markclowes opened this issue Jun 15, 2024 · 0 comments

Comments

@markclowes
Copy link

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': '' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant