aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--TODOs.org21
-rw-r--r--_layouts/podcast.html10
-rw-r--r--default.nix12
-rwxr-xr-xscripts/assert-content.sh39
-rw-r--r--site.json4
5 files changed, 79 insertions, 7 deletions
diff --git a/TODOs.org b/TODOs.org
new file mode 100644
index 0000000..a359825
--- /dev/null
+++ b/TODOs.org
@@ -0,0 +1,21 @@
+* Tasks
+** TODO Move =assert-content.sh= to Ruby
+:PROPERTIES:
+:CUSTOM_ID: a7b6b371-100c-48f4-a448-bfa39f88efce
+:END:
+- State "TODO" from [2020-12-23 mer. 01:30]
+
+Asserts will be faster since things will be already in memory.
+
+Should the generator for the torrents put the torrent files in the source tree?
+Are torrents source files or build artifacts?
+** TODO Add page to listen an watch files with WebTorrent
+:PROPERTIES:
+:CUSTOM_ID: e5d2be9d-6471-40ba-a2d3-c7bc482bfaba
+:END:
+- State "TODO" from [2020-12-23 mer. 02:25]
+** TODO Add "web" Git Annex remote support
+:PROPERTIES:
+:CUSTOM_ID: c41d11b0-4235-4e8c-8e2b-bbbec7ee5c0b
+:END:
+- State "TODO" from [2020-12-23 mer. 02:26]
diff --git a/_layouts/podcast.html b/_layouts/podcast.html
index ea03187..982fbc6 100644
--- a/_layouts/podcast.html
+++ b/_layouts/podcast.html
@@ -3,8 +3,14 @@ layout: post
---
<audio controls>
- <source src="{% link /resources/podcasts/{{ page.lang }}/{{ page.date | date: "%Y-%m-%d" }}-{{ page.ref }}.ogg %}" type="audio/ogg">
- <source src="{% link /resources/podcasts/{{ page.lang }}/{{ page.date | date: "%Y-%m-%d" }}-{{ page.ref }}.flac %}" type="audio/flac">
+ <source src="{% link /resources/podcasts/{{ page.date | date: "%Y-%m-%d" }}-{{ page.slug }}.ogg %}" type="audio/ogg">
+ <source src="{% link /resources/podcasts/{{ page.date | date: "%Y-%m-%d" }}-{{ page.slug }}.flac %}" type="audio/flac">
</audio>
+<div class="torrent-link">
+ <a href="/resources/podcasts/{{ page.date | date: "%Y-%m-%d" }}-{{ page.slug }}.ogg.torrent">
+ torrent
+ </a>
+</div>
+
{{ content }}
diff --git a/default.nix b/default.nix
index bb83afc..801c50d 100644
--- a/default.nix
+++ b/default.nix
@@ -12,9 +12,19 @@ let
gemset = ./nix/gemset.nix;
};
+ mktorrent-newer = pkgs.mktorrent.overrideAttrs(oldAttrs: {
+ src = pkgs.fetchFromGitHub {
+ owner = "Rudde";
+ repo = "mktorrent";
+ rev = "ea1fbf29d19f34a93f7d984c1ac29d6d08f1f508";
+ sha256 = "1cjq96qridpvqhphj3ljnhysnqkdck415wxaqy768r0rvzqq1ja4";
+ };
+ });
+
projectBuildInputs = with pkgs; [
jekyllEnv
pkgs-next.mdpo
+ mktorrent-newer
perl
graphviz
@@ -39,7 +49,7 @@ in rec {
test = pkgs.stdenv.mkDerivation {
inherit src;
name = "website-test";
- phases = [ "unpackPhase" "buildPhase" ];
+ phases = projectBuildInputs;
buildInputs = projectBuildInputs;
buildPhase = ''
patchShebangs .
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
diff --git a/site.json b/site.json
index 14adec7..66dac32 100644
--- a/site.json
+++ b/site.json
@@ -112,9 +112,9 @@
"ref": "{{ podcast.ref }}",
"layout": "{{ podcast.layout }}",
"content": {{ podcast.content | strip_html | jsonify }},
- "audio": "{{ podcast.audio }}"
+ "audio": "{{ podcast.audio }}",
+ "slug": "{{ podcast.slug }}"
}{% unless forloop.last %},{% endunless %}
{% endfor %}
-
]
}