aboutsummaryrefslogtreecommitdiff
path: root/home/dot_local/share/bin/executable_podcast2m3u
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2026-08-02 14:48:29 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2026-08-02 14:48:29 +0200
commite43eb1177872f52e949fb5f0f93396ed94b0d093 (patch)
tree78b73af6a989fa2996d71b112e161b70d35081ef /home/dot_local/share/bin/executable_podcast2m3u
parent2f14a896e4b897bd747c24d7ad8e9e7bb3237d03 (diff)
move to chezmoi
Diffstat (limited to 'home/dot_local/share/bin/executable_podcast2m3u')
-rw-r--r--home/dot_local/share/bin/executable_podcast2m3u33
1 files changed, 33 insertions, 0 deletions
diff --git a/home/dot_local/share/bin/executable_podcast2m3u b/home/dot_local/share/bin/executable_podcast2m3u
new file mode 100644
index 0000000..c3b692e
--- /dev/null
+++ b/home/dot_local/share/bin/executable_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)
+}
+'
+