aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-content.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-12-23 01:55:47 -0300
committerEuAndreh <eu@euandre.org>2020-12-23 02:26:29 -0300
commit6a19c27e388f6606edb59751ac29e6b5ac80026c (patch)
tree847ba8d7f1780d4e9dade682965a8c92a48bde8e /scripts/assert-content.sh
parent_layouts/podcast.html: Remove placeholder alternative tag, point to flac file (diff)
downloadeuandre.org-6a19c27e388f6606edb59751ac29e6b5ac80026c.tar.gz
euandre.org-6a19c27e388f6606edb59751ac29e6b5ac80026c.tar.xz
Generate torrent files from ogg files
Diffstat (limited to 'scripts/assert-content.sh')
-rwxr-xr-xscripts/assert-content.sh39
1 files changed, 37 insertions, 2 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh
index cdd2a01..558e424 100755
--- a/scripts/assert-content.sh
+++ b/scripts/assert-content.sh
@@ -3,7 +3,10 @@ set -Eeuo pipefail
end="\033[0m"
red="\033[0;31m"
-red() { echo -e "${red}${1}${end}"; }
+yellow="\033[0;33m"
+red() { echo -e "${red}${1}${end}"; }
+yellow() { echo -e "${yellow}${1}${end}"; }
+
## Constant definitions
@@ -98,16 +101,48 @@ assert-frontmatter() {
if [[ "$PREFIX" = '_podcasts/' ]]; then
AUDIO="$(get-x audio "$F")"
+ SLUG="$(get-x slug "$F")"
+
[[ -z "$AUDIO" ]] && fail-attr 'audio' "${URL}"
+ [[ -z "$SLUG" ]] && fail-attr 'slug' "${URL}"
+
+ TITLE_SLUG="$(slugify "$TITLE")"
+ if [[ "$SLUG" != "$TITLE_SLUG" ]]; then
+ red "slug and title don't match."
+ red "slug: '$SLUG'"
+ red "title slug: '$TITLE_SLUG'"
+ exit 1
+ fi
+
for audiofmt in flac ogg; do
DATE="$(get-date "$F")"
URL_BASENAME="$(basename "$(get-url "$F")")"
- AUDIO="resources/podcasts/$LLANG/${DATE}-${REF}.$audiofmt"
+ AUDIO="resources/podcasts/${DATE}-${SLUG}.$audiofmt"
if [[ ! -f "$AUDIO" ]]; then
red "Missing audio file '$AUDIO'."
exit 1
fi
done
+
+ TRACKERS='-a udp://tracker.coppersurfer.tk:6969/announce -a udp://tracker.ccc.de:80/announce -a udp://tracker.publicbt.com:80 -a udp://tracker.istole.it:80 -a http://tracker.openbittorrent.com:80/announce -a http://tracker.ipv6tracker.org:80/announce'
+
+ for audiofmt in ogg; do
+ OGG="resources/podcasts/$DATE-$SLUG.ogg"
+ TORRENT="$OGG.torrent"
+ WEBSEED="https://euandre.org/$OGG"
+ if [ ! -f "$TORRENT" ]; then
+ yellow "Missing torrent $TORRENT, generating..."
+ mktorrent $TRACKERS \
+ -f \
+ -v \
+ -d \
+ -c "$(cat _podcasts/$DATE-$SLUG.md)" \
+ -n "$TITLE.ogg" \
+ -w "$WEBSEED" \
+ -o "$TORRENT" \
+ "$OGG"
+ fi
+ done
fi
if [[ "$DESIRED_LAYOUT" != 'page' ]]; then