Introduction
Introduction Statistics Contact Development Disclaimer Help
first version - potcasse - Podcast publication made easy
git clone git://bitreich.org/potcasse git://hg6vgqziawt5s4dj.onion/potcasse
Log
Files
Refs
Tags
README
LICENSE
---
commit 7d50f07ca06423a5d0c93ce190093920f551c669
Author: Solene Rapenne <[email protected]>
Date: Tue, 20 Jul 2021 22:13:55 +0200
first version
Diffstat:
A potcasse | 116 ++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+), 0 deletions(-)
---
diff --git a/potcasse b/potcasse
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+exitp() {
+ echo "$1"
+ exit 1
+}
+
+usage() {
+ name=$(basename $0)
+ printf '%s\n' \
+ "$name init | gen | episode TITLE FILE [ID]" \
+ "$name init" \
+ ': initialize the potcasse structure' \
+ "$name gen" \
+ ': generate the RSS file' \
+ "$name episode TITLE FILE [ID]" \
+ ': create the structure for a new episode and eventually copy file [FI…
+ exit 0
+}
+
+init() {
+ test -f metadata.sh && exitp "You seem in a directory managed by potcasse"
+ mkdir -p episodes
+ cat << EOF > metadata.sh
+SITE=
+LANG=en-us
+#uncomment to use logo.png as a logo
+#IMAGE=YES
+EOF
+ exit 0
+}
+
+episode() {
+ test -f metadata.sh || exitp "The directory isn't managed by potcasse"
+ TITLE="$1"
+
+ test -f "$2" || exitp "File $2 doesn't exist"
+ AUDIOFILE="$2"
+ EXT=${AUDIOFILE##*.}
+
+ if [ -n "$3" ]
+ then
+ ID="$3"
+ else
+ ID="$(date +%Y%m%d%H)"
+ fi
+
+ DEST="episodes/${ID}"
+ mkdir -p "$DEST"
+ cat << EOF > ${DEST}/metadata.sh
+TITLE="$TITLE"
+PUBDATE="$(date "+%a, %d %b %Y 00:00:00 GMT")"
+AUDIOFILE="${ID}.${EXT}"
+EOF
+ cp "$AUDIOFILE" "${DEST}/${ID}.${EXT}"
+}
+
+gen() {
+ TMPFILE=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
+ . ./metadata.sh
+ mkdir -p output_html/episodes
+
+ if [ -n "$IMAGE" ]
+ then
+ test -f logo.png || exitp "You defined an IMAGE, move it to $PWD/logo.…
+ cp logo.png output_html/logo.png
+ fi
+
+ cat <<EOF >> $TMPFILE
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0">
+ <channel>
+ <title>${TITLE}</title>
+ <description>${DESCRIPTION}</description>
+ <link>${SITE}</link>
+ <image>
+ <url>${SITE}/logo.png</url>
+ <title>Image of ${SITE}</title>
+ <link>${SITE}</link>
+ </image>
+ <language>${LANG}</language>
+EOF
+
+ for episode in episodes/*
+ do
+ echo "Scanning $episode"
+ . ${episode}/metadata.sh
+ SIZE=$(stat -f "%z" "${episode}/${AUDIOFILE}")
+ EXT=${AUDIOFILE##*.}
+ rsync -a "${episode}/${AUDIOFILE}" output_html/episodes/
+ cat <<EOF >> $TMPFILE
+ <item>
+ <title>$TITLE</title>
+ <description></description>
+ <pubDate>${PUBDATE}</pubDate>
+ <enclosure url="${SITE}/episodes/${AUDIOFILE}" length="${SIZE}" ty…
+ </item>
+EOF
+ done
+
+ cat <<EOF >> $TMPFILE
+ </channel>
+</rss>
+EOF
+ install -m 644 "$TMPFILE" output_html/${RSSLINK}
+ rm "$TMPFILE"
+}
+
+
+case "$1" in
+ '') usage;;
+ help) usage;;
+ init) init ;;
+ gen) gen ;;
+ episode) [ -n "$2" ] && episode "$2" "$3" "$4" ;;
+esac
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.