My previous post discussed modifying formats and metadata of music files to improve compatibility with Sonos music streamers. This post focuses on podcasts. I liked the idea of having podcasts automatically downloaded and made available for the Sonos, as it feeds into the idea of being a highly-available source of audio.
The actual downloading is handled by castget because it works and is available in the OpenBSD ports collection.
Castget already has options to force the artist and album title. I’m treating all podcasts as being one artist “Podcast”. Each show is an album, and each individual cast is a track. I set each show to download into my music content directory.
Castget downloads to a new Content directory in BunnyMusicFile. I can just process this as any other directory, but there’s a few changes I want to make along the way.
Often each podcast episode will have a common beginning to the tile, e.g. “TRIntro: Introducing mixtape”. This can make it hard to distinguish between episodes when the title is truncated for display. Instead, it’s more useful to have the unique part of the title first, e.g. a date or season/episode ID. This data can often be found in the filename. For example, the BBC podcasts we can extract the date from the filename, such as
The Penny Arcade podcasts don’t actually have a title set in metadata at all. They do have a season and episode number in the filename, and sometimes have an episode title as well, e.g.
dlc-s04e22-attempted-recidivism-tWLE42kB.mp3. So in this case we want to construct the whole title metadata from parts of the filename.
Initially I used a set of rules within the BunnyMusicFile config to update the title metadata. However, as mentioned in my previous evaluation there are times where the config file system gets stretched too far. Instead I wrote a small Perl script called dm-podcast-update to perform the processing.
The script does three things:
- Download podcasts using castget
- Updates metadata as needed
- Calls musview to update the Views
The script will attempt to find a ‘prefix’ for each podcast by searching the metadata/filename for a date or season/episode marker. That prefix is then prepended to the title (or generated title). When a prefix is found the script will attempt to remove surplus information from the title. For example, the Serial podcasts are named in the style of
serial-s01-e01.mp3 so the script can generate a prefix of “S01 E01”. The MP3 title is set with “Episode 1: The Alibi”. Just prepending the prefix gives us “S01 E01: Episode 1: The Alibi” which looks a bit stupid. So here we remove “Episode 1”.
With all the possible naming schemes, and combinations of metadata that are possible this script will have to be regularly updated as I encounter new formats. But it shouldn’t be too much of a burden.
As well as updating the title metadata, the script also adds track numbers to the episodes. The track numbers are assigned by sorting the episodes according to the naming scheme in use (date or season/episode). The script has the option of applying track numbers in reverse order so that newest episode has the lowest number. Reverse sorting is useful as it means the newest episode appears first in the Sonos album view. When reverse sorting the track numbers ‘start’ at 999, so that adding a new episode doesn’t mean that all other episodes are re-numbered, which would require them to be re-transferred.
This is what I end up with: