From 6bdde7b39ab90dbcdb7de20fcd265d95623f524e Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 2 Sep 2024 22:24:17 -0600 Subject: [PATCH] rss script --- .../2024/09-02-podcast-rss-generator/build.sh | 61 +++++++++++++++++++ .../2024/09-02-podcast-rss-generator/index.md | 23 +++++++ 2 files changed, 84 insertions(+) create mode 100755 content/blog/2024/09-02-podcast-rss-generator/build.sh create mode 100644 content/blog/2024/09-02-podcast-rss-generator/index.md diff --git a/content/blog/2024/09-02-podcast-rss-generator/build.sh b/content/blog/2024/09-02-podcast-rss-generator/build.sh new file mode 100755 index 0000000..feabea8 --- /dev/null +++ b/content/blog/2024/09-02-podcast-rss-generator/build.sh @@ -0,0 +1,61 @@ +#! /bin/sh + +set -e + +cd $(dirname $0) +. config.sh + +out="rss.xml" +exec 1>$out +echo "Writing to $out" 1>&2 + +cat < + + + $title + $url + en + $description + +EOF + +if [ -f cover.jpg ]; then + cat < + $url/cover.jpg + $title + $url + +EOF +fi + +for fn in *.mp3; do + echo "- $fn" 1>&2 + + ffprobe -loglevel quiet -show_entries format -output_format json "$fn" > format.json + title=$(cat format.json | jq -r '.format.tags.title') + duration=$(cat format.json | jq -r '.format.duration | tonumber | ceil') + #bps=$(cat format.json | jq -r '.format.bit_rate') + #kbps=$(($bps / 1000)) + rm format.json + guid=$(sha1sum "$fn" | awk '{print $1}') + size=$(stat -c %s "$fn") + mtime=$(date -R -d @$(stat -c %Y "$fn")) + ufn=$(echo $fn | tr ' ' '+') + + cat < + $title + $mtime + $duration + + $guid + +EOF +done + +cat < + +EOF diff --git a/content/blog/2024/09-02-podcast-rss-generator/index.md b/content/blog/2024/09-02-podcast-rss-generator/index.md new file mode 100644 index 0000000..57950da --- /dev/null +++ b/content/blog/2024/09-02-podcast-rss-generator/index.md @@ -0,0 +1,23 @@ +--- +title: "Podcast RSS Generator" +date: 2024-09-02 +tags: + - computers + - featurephone +--- + +I wanted to play some audiobooks on my light phone, +so I made a bourne shell script to generate an RSS feed. +I was surprised that I couldn't find any prior work to do this. + +Put all your .mp3 files in a directory, +put this script in it, +and make a `config.sh`: + +```sh +title="My Audiobook" +description="An audiobook I like" +url="https://example.com/ebooks/mine" +``` + +The script: [build.sh](build.sh)