2023-07-03 From mp3s to podcasts

Many years ago I used to listen to podcasts a lot. I had my two favorite ones, and they provided me with more than 90 minutes of interesting material to listen every week (and that is not counting several hundred archive episodes!). Recently, I decided to start listening again to interesting people while I commute.

This time, though, I want to listen to webinars instead, and I have them in the form of mp3 files. Thing is, how do I get them on my smartphone? Copying files from a computer to a smartphone is notoriosly finicky, especially on GNU/Linux (which I’m sad to admit). I thought, however, that I could just put them somewhere on the internet, generate an RSS XML file, point my podcast app to it and download them that way. I searched the internet for a few minutes and found a simple tool, called dir2cast, which does exactly that – accepts a directory with a bunch of mp3 files and serves an RSS XML file.

My first thought was to install it on a VPS I rent and set thins up so that I have some secret URL for my RSS feed. It dawned on me, however, that I can do something much simpler instead. Why use a VPS when I can do everything within my LAN? You can always use the python http.server module to serve contents of some local directory on the local network. And instead of dir2cast – which requires PHP – I found this Python podcast script. It is even better, since it only does one thing (and it looks like it does it well!) – takes a directory of mp3 files and generates an rss.xml file from them. The only thing it needs to do its work is pip install rfeed. I then use this little script I got from a friend and expanded a bit myself:

OUT=$(ip -f inet addr show | ag -o 'inet \K[\d.]+' | ag 192 | sed "s/$/:$PORT/" | sed "s/^/http:\/\//")
echo $OUT
qr $OUT &
python -m http.server $PORT

and get a QR code I can scan on my phone to get an RSS URL for my “podcast”. The only thing that remains to do is to put it into my podcast app and I have my mp3s there. Even better, I don’t even need to scan the QR code the next time I want to download an mp3 file – since the app remembers the podcast’s URL, I just put the new file in the same directory, run the serving script again, tell the app to check for new episodes and that’s it. Ta-da!

CategoryEnglish, CategoryBlog