potcasse: add Gemini protocol support + update documentation

This commit is contained in:
Vincent Finance 2021-08-08 20:26:31 +02:00
parent f5a3671282
commit c97f6641aa
3 changed files with 65 additions and 12 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2021 Rapenne Solène Copyright (c) 2021 Rapenne Solène and Vincent Finance
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@ -6,13 +6,13 @@ potcasse, pronounced "pot kas" is meant to help people to publish and self host
* rsync (could use cp but avoid recopying audio files locally). * rsync (could use cp but avoid recopying audio files locally).
* a posix compatible OS (Linux, *BSD, Solaris). * a posix compatible OS (Linux, *BSD, Solaris).
* some webserver to host the files. * some webserver and/or some gemini server to host the files.
# How to use # How to use
The idea is to regroup audio files with their metadata in a directory and generate the structure that you will publish on a web server. The idea is to regroup audio files with their metadata in a directory and generate the structure that you will publish on a web server and/or on a Gemini server.
A simple `index.html` file is also generated in the process to give an easy list without using the RSS file. A simple `index.html` file and a simple `index.gmi` file are also generated in the process to give an easy list without using the RSS file.
## First time ## First time
@ -27,11 +27,13 @@ It has the following variables:
+ `TITLE`: this is the podcast title. + `TITLE`: this is the podcast title.
+ `AUTHOR`: this is the podcast author (doesn't support multiples authors yet). + `AUTHOR`: this is the podcast author (doesn't support multiples authors yet).
+ `SITE`: base HTTP URL where your podcast will be available (for example `https://tilde.example/myname/podcast/`. + `SITE`: base HTTP URL where your podcast will be available (for example `https://tilde.example/myname/podcast/`.
+ `CAPSULE`: base Gemini URL where your podcast will be available (for example `gemini://tilde.example/myname/podcast/`.
+ `DESCRIPTION`: description of the podcast.
+ `RSSLINK`: name of the RSS feed. + `RSSLINK`: name of the RSS feed.
+ `IMAGE`: if value is not empty, potcasse will use the file `logo.png`. + `IMAGE`: if value is not empty, potcasse will use the file `logo.png` (only used on the web version)
+ `LANGUAGE`: language code (such as `fr` or `en-us`) that can be potentially used by some players. + `LANGUAGE`: language code (such as `fr` or `en-us`) that can be potentially used by some players.
You will share the link `$SITE/index.html` or `$SITE/$RSSLINK` to your listeners. You will share the link `$SITE/index.html`, `$SITE/index.gmi` or `$SITE/$RSSLINK` to your listeners.
## New episode ## New episode
@ -53,9 +55,9 @@ potcasse episode "Episode XX: trying something weird" /path/to/audio/file this_i
potcasse gen potcasse gen
``` ```
this will create or update the `output_html` directory with your audio files, the RSS file, an index.html file listing all the episodes and the logo file if any. This will create or update the `output_html` directory with your audio files, the RSS file, an index.html file listing all the episodes and the logo file if any. It will also create or update the `output_gmi` directory according to the same scheme, in order to create a Gemini compatible version of the listing (it will not use the logo file though).
# Real world example # Real world example (from *solene*)
My podcast feed is available at `https://perso.pw/lambda/feed.xml` which is on server `perso.pw` in `/var/www/htdocs/lambda/`. My podcast feed is available at `https://perso.pw/lambda/feed.xml` which is on server `perso.pw` in `/var/www/htdocs/lambda/`.

View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
## potcasse - Based on solene's potcasse (https://tildegit.org/solene/potcasse)
exitp() { exitp() {
echo "$1" echo "$1"
@ -26,9 +27,14 @@ init() {
TITLE= TITLE=
# base URL of your website # base URL of your website
# must end with a /
SITE= SITE=
# base URL of your gemini capsule
CAPSULE=
# description of the podcast
DESCRIPTION=
# filename of the RSS file # filename of the RSS file
RSSLINK=feed.xml RSSLINK=feed.xml
@ -69,9 +75,12 @@ EOF
gen() { gen() {
test -d episodes || exitp "You need to import episodes before generation" test -d episodes || exitp "You need to import episodes before generation"
TMPRSS=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX) TMPRSS=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
TMPGEMRSS=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
TMPHTML=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX) TMPHTML=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
TMPGMI=$(mktemp /tmp/potcasse.XXXXXXXXXXXXXXXXXXXXX)
. ./metadata.sh . ./metadata.sh
mkdir -p output_html/episodes mkdir -p output_html/episodes
mkdir -p output_gmi/episodes
if [ -n "$IMAGE" ] if [ -n "$IMAGE" ]
then then
@ -85,7 +94,7 @@ gen() {
<channel> <channel>
<title>${TITLE}</title> <title>${TITLE}</title>
<description>${DESCRIPTION}</description> <description>${DESCRIPTION}</description>
<atom:link href="${SITE}${RSSLINK}" rel="self" type="application/rss+xml" /> <atom:link href="${SITE}/${RSSLINK}" rel="self" type="application/rss+xml" />
<link>${SITE}</link> <link>${SITE}</link>
<image> <image>
<url>${SITE}/logo.png</url> <url>${SITE}/logo.png</url>
@ -95,6 +104,17 @@ gen() {
<language>${LANGUAGE}</language> <language>${LANGUAGE}</language>
EOF EOF
cat <<EOF >> $TMPGEMRSS
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>${TITLE}</title>
<description>${DESCRIPTION}</description>
<atom:link href="${CAPSULE}/${RSSLINK}" rel="self" type="application/rss+xml" />
<link>${CAPSULE}</link>
<language>${LANGUAGE}</language>
EOF
cat <<EOF >> $TMPHTML cat <<EOF >> $TMPHTML
<!DOCTYPE html> <!DOCTYPE html>
<html lang="${LANGUAGE}"> <html lang="${LANGUAGE}">
@ -103,14 +123,24 @@ EOF
<meta charset="utf-8" /> <meta charset="utf-8" />
</head> </head>
<body> <body>
<h1>Podcast episodes- ${TITLE}</h1> <h1>Podcast episodes - ${TITLE}</h1>
<div> <div>
<img src="logo.png" width=200 height=200 alt="logo" /> <img src="logo.png" width=200 height=200 alt="logo" />
<p>${DESCRIPTION}</p>
</div> </div>
<ul> <ul>
<li><a href="${RSSLINK}">RSS feed</a> (for podcast players).</li> <li><a href="${RSSLINK}">RSS feed</a> (for podcast players).</li>
</ul> </ul>
<ul> <ul>
EOF
cat <<EOF >> $TMPGMI
# Podcast episodes - ${TITLE}
${DESCRIPTION}
=> ${RSSLINK} RSS feed (for podcast players)
EOF EOF
for episode in episodes/* for episode in episodes/*
@ -120,6 +150,7 @@ EOF
SIZE=$(stat -f "%z" "${episode}/${AUDIOFILE}") SIZE=$(stat -f "%z" "${episode}/${AUDIOFILE}")
EXT=${AUDIOFILE##*.} EXT=${AUDIOFILE##*.}
rsync -a "${episode}/${AUDIOFILE}" output_html/episodes/ rsync -a "${episode}/${AUDIOFILE}" output_html/episodes/
rsync -a "${episode}/${AUDIOFILE}" output_gmi/episodes/
cat <<EOF >> $TMPRSS cat <<EOF >> $TMPRSS
<item> <item>
<title>$TITLE</title> <title>$TITLE</title>
@ -128,15 +159,33 @@ EOF
<guid>${SITE}/episodes/${AUDIOFILE}</guid> <guid>${SITE}/episodes/${AUDIOFILE}</guid>
<enclosure url="${SITE}/episodes/${AUDIOFILE}" length="${SIZE}" type="audio/${EXT}" /> <enclosure url="${SITE}/episodes/${AUDIOFILE}" length="${SIZE}" type="audio/${EXT}" />
</item> </item>
EOF
cat <<EOF >> $TMPGEMRSS
<item>
<title>$TITLE</title>
<description></description>
<pubDate>${PUBDATE}</pubDate>
<guid>${CAPSULE}/episodes/${AUDIOFILE}</guid>
<enclosure url="${CAPSULE}/episodes/${AUDIOFILE}" length="${SIZE}" type="audio/${EXT}" />
</item>
EOF EOF
cat <<EOF >> $TMPHTML cat <<EOF >> $TMPHTML
<li>${PUBDATE} - <a href="episodes/${AUDIOFILE}">${TITLE}</a></li> <li>${PUBDATE} - <a href="episodes/${AUDIOFILE}">${TITLE}</a></li>
EOF
cat <<EOF >> $TMPGMI
=> episodes/${AUDIOFILE} ${PUBDATE} - ${TITLE}
EOF EOF
done done
cat <<EOF >> $TMPRSS cat <<EOF >> $TMPRSS
</channel> </channel>
</rss> </rss>
EOF
cat <<EOF >> $TMPGEMRSS
</channel>
</rss>
EOF EOF
cat <<EOF >> $TMPHTML cat <<EOF >> $TMPHTML
@ -146,8 +195,10 @@ EOF
EOF EOF
install -m 644 "$TMPRSS" output_html/${RSSLINK} install -m 644 "$TMPRSS" output_html/${RSSLINK}
install -m 644 "$TMPGEMRSS" output_gmi/${RSSLINK}
install -m 644 "$TMPHTML" output_html/index.html install -m 644 "$TMPHTML" output_html/index.html
rm "$TMPRSS" "$TMPHTML" install -m 644 "$TMPGMI" output_gmi/index.gmi
rm "$TMPRSS" "$TMPHTML" "$TMPGMI" "$TMPGEMRSS"
} }