From 1d0e0e54f663920a0992f1af5bd7d0b37eee537a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 4 Jun 2024 15:40:40 +0200 Subject: e --- "skripti/\305\276" | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "skripti/\305\276" (limited to 'skripti/ž') diff --git "a/skripti/\305\276" "b/skripti/\305\276" new file mode 100644 index 0000000..d18de36 --- /dev/null +++ "b/skripti/\305\276" @@ -0,0 +1,36 @@ +#!/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. +host=$1 +port=$2 +endpoint=$3 +kon=$4 +mistakes=0 +set -xeuo pipefail +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 -- cgit v1.2.3