# -*- mode: org -*-
#+title: Sharing a creative commons series over Freenet / Hyphanet
#+subtitle: With the example of BloodSpell: the groundbreaking Machinima animated feature film
#+LANGUAGE: en
#+options: toc:nil ^:nil
How to create a simple streaming media site for a sequential series,
optimized for insertion into Freenet / Hyphanet to be independent of
big hosters.
This guide and implementation shows how to share a series, in contrast
to the older [[https://github.com/hyphanet/generate-media-site/][generate-media-site]] is a tool to provide something akin
to radio: shuffled media from a collection of files.
As example it uses the awesome Bloodspell series, licensed under
[[https://creativecommons.org/licenses/by-nc-sa/2.5/][creative commons by-nc-sa 2.5]] (so, yes, you’re allowed to share this,
but no, you may not earn money from that — and we don’t: we just enjoy
kicking big corporate media by moving as far away from their model of
[[https://pluralistic.net/2023/01/21/potemkin-ai/#hey-guys][enshittification]] and [[https://ar.al/notes/we-didnt-lose-control-it-was-stolen/][people farming]] as possible[fn:1]).
#+toc: headlines 2
* Tutorial
#+begin_kasten
This tutorial assumes that you’re running desktop GNU/Linux. Most
steps should still work on a BSD. Your viewers can access the site
using Windows, Linux, macos, or Android by opening the site via a
locally running [[https://freenetproject.org][Freenet / Hyphanet]] node or via an inproxy that runs
[[https://github.com/hyphanet/SCGIPublisher][SCGIPublisher]]. iPhones or iPads only support the inproxy-method, sorry
for that: they don’t want us.
#+end_kasten
As first step, clone this repository with [[https://www.mercurial-scm.org][Mercurial]]:
#+begin_src bash
# from the internet
hg clone https://hg.sr.ht/~arnebab/hypha-series
# or from the gms.bundle shipped with this tutorial
hg clone gms.bundle hypha-series
#+end_src
Then adjust [[file:site/template.html]] and [[file:site/style.css]] to match
the series' style. The part ={{{STREAMS}}}= is replaced by a video
element using the template [[file:site/video.html]].
I edit the files by opening them in Icecat or Firefox and in [[https://gnu.org/s/emacs][Emacs]],
commenting-in the skewer-script-tag (adjusting the port as needed),
and then running =M-x run-skewer= to get interactive CSS development
with [[https://www.draketo.de/software/emacs-javascript.html#skewer][skewer-mode]] (activate =skewer-css-mode=), but you can use any
webdev tool you like — it’s just HTML and CSS.
To prepare the media, copy all the series’ files into the folder
=media/= and ensure that the names match the order. Make sure if you
have more than 9 episodes, to prefix the numbers with =0=. In Emacs
dired you can use =C-x C-q= for mass editing. I now have this:
#+begin_example
media/BloodSpell_Episode_01_Large.avi
media/BloodSpell_Episode_02_Large.avi
media/BloodSpell_Episode_03_Large.avi
media/BloodSpell_Episode_04_Large.avi
media/BloodSpell_Episode_05_Large.avi
media/BloodSpell_Episode_06_Large.avi
media/BloodSpell_Episode_07_Large.avi
media/BloodSpell_Episode_08_Large.avi
media/BloodSpell_Episode_09_Large.avi
media/BloodSpell_Episode_10_Large.avi
media/BloodSpell_Episode_11_Large.avi
media/BloodSpell_Episode_12_Large.avi
media/BloodSpell_Episode_13_Large.avi
media/BloodSpell_Episode_14_Large.avi
#+end_example
If you want to show specific information for the different episodes,
create files named =FILENAME.info=. The content of these files will be
inserted below the video, raw HTML tags and all. For example I create
the file =media/BloodSpell_Episode_01_Large.avi.info= and write the
information:
#+begin_src html
One young Monk-in-training, Jered, leads the Monks to stop a human
sacrifice. But both the Monks and the Blooded have secrets he does not
know, and the outcome of his first mission will be very different to
his expectations...
#+end_src
To share the episodes you’ll run [[file:site/gms.scm]] to get and
transcode the files one by one. See the comments at the top of that
file for additional information.
Now you’re all set up to start streaming into Freenet / Hyphanet.
Follow the steps in the next section to provide your site.
* Usage
:PROPERTIES:
:CUSTOM_ID: usage
:END:
Setup as shown above. Then run on debian (as an example):
#+begin_example
sudo apt install mercurial ffmpeg mplayer grep sed wget guile-3.0
(cd site && chmod +x ./gms.scm && ./gms.scm --sorted)
#+end_example
Then use [[https://github.com/Bombe/jSite][jSite]] or =freesitemgr= from
[[https://github.com/freenet/pyFreenet][pyFreenet]] to upload the site/
folder into Freenet.
Insert on debian (example):
#+begin_example
sudo apt install git python3 autoconf automake openjdk-17-jdk wget grep sed gnupg curl firefox-esr
pip3 install --user pyFreenet3
git clone https://github.com/freenet/browser
(cd browser && ./bootstrap.sh --prefix=$HOME/.local && make install)
# install Freenet if needed
~/.local/bin/freenetbrowser --install
# add hypha-series/site: enter the values as requested
~/.local/bin/freesitemgr add
# get your site public key (the website address to give others)
~/.local/bin/freesitemgr list YOUR_SITENAME
#+end_example
It looks like this for me:
#+begin_example
$ freesitemgr add
Add new site
Name of freesite, or empty line to cancel: bloodspell
Directory where freesite's files reside: /home/user/websites/bloodspell/site
Site private URI (if any - press ENTER for new
:
Added new freesite: 'bloodspell' => /home/userwebsites/bloodspell/site
insert:bloodspell: site insert has completed
insert:bloodspell: checking if a new insert is needed
insert:bloodspell: Changes detected - updating...
$ freesitemgr list bloodspell
bloodspell:
state: updating
dir: /home/user/websites/bloodspell/site
uri: USK@JzzvVJt-47Hby7c6i21I1HJjmUQT3EfkViJcXtH0jHk,Vtfn5lZf5lihVC6S-ymJHF69Z2qG8zHfcKNMGxrTcjQ,AQACAAE/bloodspell/0
privkey: USK@REDACTED,REDACTED,AQECAAE/bloodspell/0
#+end_example
The uri is the key you can give other people so they can watch your series in Freenet / Hyphanet.
Now that you have the URI, update the newbookmark-link in [[file:site/template.html]].
** Automate with a cronjob
To automate weekly updates after setting up the site and tooling as above, you can use a cronjob like the following:
#+begin_src crontab
# cron-format: minute hour day-of-month month day-of-week
# initial insert
30 5 * * 1 su - user timeout 7200 bash -c 'cd /home/user/websites/bloodspell/site && nice timeout 7200 ./gms.scm --sorted && rm -f sitemap.html && echo yes | timeout 360 freesitemgr cancel bloodspell && timeout 1800 freesitemgr --max-manifest-size=1400 update bloodspell'
# fixup so the previous episode does not lack the first one or two segments
30 8 * * 1 su - user timeout 7200 bash -c 'echo yes | timeout 360 freesitemgr cancel bloodspell && timeout 1800 freesitemgr --max-manifest-size=1400 update bloodspell'
#+end_src
(use =crontab -e= as root to edit systemwide cronjobs, you may want to
do a user-cronjob instead, then you can skip =su - user timeout 7200 bash -c '= and the ='= at the end)
* Develop
:PROPERTIES:
:CUSTOM_ID: develop
:END:
Make sure you set up a username:
#+begin_example
hg config -el # set [ui]\nusername = 'someone <somewhere@else>'
#+end_example
Release your changes for use in Freenet:
#+begin_example
hg archive site/gms.zip
hg bundle --all site/gms.bundle
~/.local/bin/freesitemgr update YOUR_SITENAME
#+end_example
* Footnotes
[fn:1] Different from self-hosting a media-site, this site does not
get slower the more people use it. The more people view your
series, the faster it gets, while fully preserving your viewers
privacy.