Last active
August 14, 2022 03:23
-
-
Save greencoder/c7730a4bd91f899054c7661eaa1956f8 to your computer and use it in GitHub Desktop.
Download MP3 Files From a Podcast Feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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