From a63a08c533c55c541125a94b7f52b7722cc84644 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 24 Nov 2024 13:53:34 +0100 Subject: add podcast2m3u script --- .local/share/bin/podcast2m3u | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 .local/share/bin/podcast2m3u (limited to '.local/share') diff --git a/.local/share/bin/podcast2m3u b/.local/share/bin/podcast2m3u new file mode 100755 index 0000000..c3b692e --- /dev/null +++ b/.local/share/bin/podcast2m3u @@ -0,0 +1,33 @@ +#!/bin/sh +URL="$1" +TAB="$(printf '\t')" +curl -sLo- "$URL" |\ +xmlstarlet select --template \ + --match '/rss/channel/item' \ + --value-of './itunes:duration' \ + --output "$TAB" \ + --value-of './title' \ + --output "$TAB" \ + --value-of './enclosure/@url' \ + --nl |\ +awk -F "$TAB" ' +BEGIN { + printf("#EXTM3U\n") +} +function time2secs(time) { + seconds = 0 + gsub(/,/, ".", time) + els = split(time, el, ":") + if (els == 0) return seconds; + seconds += el[els--] + if (els == 0) return seconds; + seconds += el[els--] * 60 + if (els == 0) return seconds; + seconds += el[els--] * 60 * 60 + return seconds; +} +{ + printf("#EXTINF:%s,%s\n%s\n", time2secs($1), $2, $3) +} +' + -- cgit v1.2.3