This project contains python code to generate xml files for private podcast feeds and audiobooks.
I am a huge fan of Dan Carlin's Hardcore History podcast. Up until a few months ago, I've been listening to the podcast through the public RSS feed. This only provides access to the most recent episodes (which are free). The older episodes can be bought on Dan's website as mp3 files. The podcast app that I'm using does not work well with manually downloaded mp3 files so I decided to host a private RSS feed on my home network.
A quick google search brought me to a reddit post of another Hardcore History fan who had the same problem and had already created a solution for it. That post linked to a repository that contains a perl script and a list of episodes with a limited amount of metadata. I forked that repo, converted the code to python and made it a bit more reusable.
I bought some audiobooks in mp3 format but never got around to listening to them because it's quite the hassle to listen to them on your phone: yuou have to copy the files to your phone, get your podcast player to import them in the right order, ... So I added support for audiobooks in this project. Now I can download the audiobooks in my podcast player and never listen to them, in style.
- Python3
- The requirements listed in
requirements.txt
- The mp3 files for the podcast you want to host
I will explain how it works for podcasts, as it's basically the same for audiobooks.
The metadata for the show in general can be found in resources/podcasts/hardcore-history/metadata.json
.
The metadata for each episode can be found in resources/podcasts/hardcore-history/episode-list.json
.
Each episode has 4 attributes, as shown in the example below.
[{
"pub-date": "26/07/2006",
"episode": "01",
"title": "Alexander versus Hitler",
"description": "Dan compares the way the modern world sees Adolf Hitler with the way history views Alexander the Great and wonders if the two men weren’t more alike than different."
}, ... ]
In order to run the script you will need to put the audio files in the correct location with the correct filenames. The src/podcast/podcasts.py
file contains the location of the resource files for each podcast. (Currently there is only one podcast: Hardcore History)
The filenames of the audio files are based on the metadata given in the episode-list.json
file:
{{episode}}-{{title}}
where each space in the title is replaced by an underscore in the filename. E.g.
01-Alexander_versus_Hitler.mp3
To generate the xml, run the following command:
python src/podcasts/generate-feed.py
--show_name HARDCORE_HISTORY
--root_url http://podcast.example.com
The output of this command can be found in example/HARDCORE_HISTORY_feed.xml
.
The --root_url parameter is the locations of the resources on your server. For example, using http://podcast.example.com
will result in this url for the first episode: http://podcast.example.com/resources/podcasts/hardcore-history/mp3s/01-Alexander_versus_Hitler.mp3
.
I'm using an AWS S3 bucket to host the podcast.
Export the following variables to use the deploy scripts:
- for podcasts
export PODCAST_BUCKET_NAME=hardcore-history.podcast.example.com
- for audiobooks
export DOMAIN_NAME=audiobook.example.com
You will also need the aws-cli to run the deploy scripts.