summaryrefslogtreecommitdiffstats
path: root/skripti/stream_archive.sh
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-06-04 15:40:40 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-06-04 15:40:40 +0200
commit1d0e0e54f663920a0992f1af5bd7d0b37eee537a (patch)
tree240a15da83a020bbd8b0ba294db20f45308a52c0 /skripti/stream_archive.sh
parentMerge branch 'master' of ssh://ni.4a.si/var/lib/git/sijanec/r (diff)
downloadr-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.gz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.bz2
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.lz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.xz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.zst
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.zip
Diffstat (limited to '')
-rwxr-xr-xskripti/stream_archive.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/skripti/stream_archive.sh b/skripti/stream_archive.sh
new file mode 100755
index 0000000..b218246
--- /dev/null
+++ b/skripti/stream_archive.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# $1 naj bo icecast host kruljo.radiostudent.si
+# $2 naj bo icecast http port 8000
+# $3 naj bo icecast endpoint /ehiq
+# $4 naj bo končnica datotek .mp3
+# v CWD delam imenike in datoteke in sem glede tega kompatibilen z earhornom:
+# Posnetek 2024/06/03/202136.mp3 se začne 2024-06-03T20:21:36 vedno UTC.
+# Posnetkov ne splittam na uro. Posnetek se splitta le takrat, ko se zgodi napaka (stream crkne) -- takrat začnem pisati v novo datoteko
+# požvižgam se na vsebino datotek. zame so to le bajti. v tem nisem earhornski.
+# earhornski nisem tudi zato, ker se zadnja datoteka stalno veča, kar se ne dogaja pri earhornu. na to bodite pozorni. k sreči earhorn_m3u.sh ve za to obnašanje
+set -xeuo pipefail
+host=$1
+port=$2
+endpoint=$3
+kon=$4
+mistakes=0
+while :
+do
+ filename=`date --utc +%Y/%m/%d/%H%m%S$kon`
+ mkdir -p `cut -d/ -f1-3 <<<$filename`
+ start=$SECONDS
+ set +e
+ nc $host $port <<<"GET $endpoint HTTP/1.0"$'\r\n\r' > $filename
+ koda=$?
+ set -e
+ echo TCP PREKINJEN! ZAČENJAM NOV POSNETEK! IZHODNA KODA nc je $koda, datum je `date`
+ if [ $(($SECONDS-$start)) -lt 300 ]
+ then
+ mistakes=$(($mistakes+1))
+ if [ $mistakes -gt 3 ]
+ then
+ sleep $((2**($mistakes-3)))
+ fi
+ else
+ mistakes=0
+ fi
+done