blob: efffa1bfb03d7dedca78c0483cd42202348f28fd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/bash
set -eo pipefail
# $1 je prefix
# $2 je prejšnji file (za caching dolžin)
# $3=1 forsira cache kljub version failu
# zadnjega vnosa iz cache m3uja nikdar ne bom upošteval, ker je lahko nedokončan file (no, v earhornu ne, ampak v stream_archive.sh)
echo "#EXTM3U"
ver="#earhorn_m3u.sh različica 0"
echo $ver
cache=0
if [ ! x$3 = x ] || [ ! x$2 = x ] && [ -f $2 ]
then
if [ x"`head -n2 $2 | tail -n1`" = x"$ver" ]
then
cache=1
fi
fi
find 2* -type f | while read file
do
date=`cut -d/ -f1,2,3 <<<$file | sed s,/,-,g`
time=`cut -d/ -f4 <<<$file | cut -d. -f1`
h=${time:0:2}
m=${time:2:2}
s=${time:4:2}
dol=""
if [ $cache -eq 1 ]
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
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
|