diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-06-08 14:53:59 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-06-08 14:53:59 +0200 |
commit | b815858d23f9710557f497a430cfd0cadb1ac82f (patch) | |
tree | a8fba9b1867881c50a8c522db7bed097deffd770 | |
parent | e (diff) | |
download | r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar.gz r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar.bz2 r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar.lz r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar.xz r-b815858d23f9710557f497a430cfd0cadb1ac82f.tar.zst r-b815858d23f9710557f497a430cfd0cadb1ac82f.zip |
Diffstat (limited to '')
-rwxr-xr-x | skripti/365_prenesi_omejene_vsebine.sh | 35 | ||||
-rwxr-xr-x | skripti/earhorn_m3u.sh | 17 |
2 files changed, 44 insertions, 8 deletions
diff --git a/skripti/365_prenesi_omejene_vsebine.sh b/skripti/365_prenesi_omejene_vsebine.sh index 510b0c1..16f527d 100755 --- a/skripti/365_prenesi_omejene_vsebine.sh +++ b/skripti/365_prenesi_omejene_vsebine.sh @@ -7,7 +7,26 @@ set -euo pipefail page=`curl --fail-with-body https://365.rtvslo.si/oddaja/dnevnik/92` # outputa preveč shita za set -x set -x -find . -size -12M -type f -name '*.mp4' | while read file +if mkdir lock +then + echo $$ > lock/pid +else + if [ -d /proc/`cat lock/pid` ] + then + echo ANOTHER INSTANCE IS ALREADY RUNNING + echo if you are sure that this is not the case: + echo rm -r `pwd`/lock + exit 1 + fi +fi +echo $$ > lock/pid +p=`rev <<<$0 | cut -d/ -f1 | rev` +t=`mktemp -p "" $p.XXX` +trap "rm $t; rm -r lock" EXIT +dnevnik_id=`grep href=./arhiv/dnevnik <<<"$page" | cut -d\" -f2 | cut -d/ -f4 | head -n1` +client_id=`grep 'client-id="' <<<"$page" | head -n1 | sed -E 's/^.*client-id="([^"]*)".*$/\1/'` +find . -size -12M -type f -name '*.mp4' > $t +while read file do # grep for specific audio codec ... if sample rate is 44100 and (tv broadcast is at 48000) and smaller than 12M, it's most likely the dummy/pravicepotekle video samplerate=`ffprobe "$file" 2>&1 | grep 0x6134706D | grep -Eo '[0-9]+ Hz' | cut -d\ -f1` id=`grep -Eo "\[[0-9]+\]\.mp" <<<"$file" | grep -o '[0-9]*'` @@ -15,16 +34,24 @@ do # grep for specific audio codec ... if sample rate is 44100 and (tv broadcast then continue fi + api_response=`curl --fail-with-body https://api.rtvslo.si/ava/getRecordingDrm/$id?client_id=$client_id` + if [ "`jq --raw-output .response.expirationDate <<<$api_response | head -c1`" = "3" ] || [ $((`date +%s`-86400*3-`date --date "$(jq --raw-output .response.expirationDate <<<$api_response)" +%s`)) -gt 0 ] + then + rm "$file" # sike, zgleda ne poteče! oziroma sike, je že potekel + continue + fi if [ $samplerate -eq 44100 ] then yt-dlp --no-continue http://365.rtvslo.si/arhiv/oddaja/$id # retry fu*ked up downloads + if [ `ls *\[$id\].mp4 | wc -l` -gt 1 ] + then + rm "$file" # kdaj se zgodi, da RTV spremeni ime oddaje, tedaj imam staro ime, ki ima shranjen dummy posnetek 7,6 MiB, ki neprestano triggera reload ... + fi continue fi echo -e "Subject: unknown samplerate in 365.sh\n\nVideo file: $file\nsamplerate: $samplerate\n" | sendmail root -done +done < $t rm -f Error\ \[*\].mp4 -dnevnik_id=`grep href=./arhiv/dnevnik <<<"$page" | cut -d\" -f2 | cut -d/ -f4 | head -n1` -client_id=`grep 'client-id="' <<<"$page" | head -n1 | sed -E 's/^.*client-id="([^"]*)".*$/\1/'` if [ ! -f zadnji ] then echo $dnevnik_id > zadnji diff --git a/skripti/earhorn_m3u.sh b/skripti/earhorn_m3u.sh index 4dae851..efffa1b 100755 --- a/skripti/earhorn_m3u.sh +++ b/skripti/earhorn_m3u.sh @@ -27,8 +27,17 @@ do then # tu smatram, da vsaka datoteka zavzema 3 vrstice head -n-3 $2 | grep -B2 ^$1$file$ && continue fi # prvič v head ko rečem -n-3 in drugič v grep, ko rečem -B2 - dol=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file | cut -d. -f1` - echo "#EXTINF:$dol,Radijski arhiv" - echo "#EXT-X-PROGRAM-DATE-TIME:${date}T$h:$m:${s}Z" - echo $1$file + set +e + dol=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file` + koda=$? + set -e + if [ $koda -eq 0 ] + then + echo "#EXTINF:$dol,Radijski arhiv" + echo "#EXT-X-PROGRAM-DATE-TIME:${date}T$h:$m:${s}Z" + echo $1$file + else + echo "# NAPAKA $file ffprobe vrnil $koda" + echo "NAPAKA $file ffprobe vrnil $koda" >&2 + fi done |