Skip to content

Instantly share code, notes, and snippets.

@greencoder
Last active August 14, 2022 03:23
Show Gist options
  • Save greencoder/c7730a4bd91f899054c7661eaa1956f8 to your computer and use it in GitHub Desktop.
Save greencoder/c7730a4bd91f899054c7661eaa1956f8 to your computer and use it in GitHub Desktop.
Download MP3 Files From a Podcast Feed
import feedparser
import pathlib
import posixpath
import requests
import tqdm
import urllib
feed = feedparser.parse('https://feeds.buzzsprout.com/981391.rss')
urls = []
for entry in feed.entries:
for link in entry.get('links', []):
url = link.get('href')
filename = posixpath.basename(urllib.parse.urlparse(url).path)
urls.append((url, filename))
for url, filename in tqdm.tqdm(urls):
fp = pathlib.Path(filename)
if not fp.exists():
response = requests.get(url, stream=True)
fp.write_bytes(response.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment