Skip to content

Instantly share code, notes, and snippets.

@eliask
Last active May 29, 2018 19:44
Show Gist options
  • Save eliask/96c0ad3a7e217b50024febce8f533b90 to your computer and use it in GitHub Desktop.
Save eliask/96c0ad3a7e217b50024febce8f533b90 to your computer and use it in GitHub Desktop.
Create a (podcast) RSS feed from given audio files (using Python, feedgen)
#! /usr/bin/env python
'''Create a simple RSS feed for a podcast
Usage: python create_feed.py *.m4a
Assumes .m4a audio files. Edit MIME type if needed.
Depends on feedgen: pip install feedgen
'''
import sys
from feedgen.feed import FeedGenerator
BASE='https://example.com'
fg = FeedGenerator()
fg.load_extension('podcast')
fg.podcast.itunes_category('Podcasting')
fg.id(BASE)
fg.link(href=f'{BASE}/podcast.xml', rel='self')
fg.language('en')
fg.title('asd')
fg.description('asd')
for f in sys.argv[1:]:
url = f'{BASE}/{f}'
fe = fg.add_entry()
fe.id(url)
fe.title(f)
fe.link(href=f, rel='alternate')
# NB: iOS Podcast app starts crashing if there are more than ~80k characters for the description.
fe.description('')
fe.enclosure(url, 0, 'audio/x-m4a')
fg.rss_str(pretty=True)
fg.rss_file('podcast.xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment