-
Notifications
You must be signed in to change notification settings - Fork 0
/
webcams.sh
executable file
·61 lines (56 loc) · 1.45 KB
/
webcams.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
log=/home/pi/scripts/webcams/log.txt
currentMin=`date +%M`
configs=`ls /home/pi/scripts/webcams/*.cfg`
if [ $# -gt 0 ]; then
htmlPath=$1
htmlFile=$2
else
htmlPath=""
fi
function log(){
echo "`date`: $1" >> $log
}
for c in $configs; do
while read line; do
filename=""
nowActive=""
url=`echo $line | awk '{print $1}'`
activeMins=`echo $line | awk '{print $2}'`
target=`echo $line | awk '{print $3}'`
for m in `echo $activeMins | sed 's/,/ /g'`; do
if [ $currentMin -eq $m ]; then
nowActive=yes
break
fi
done
if [ "$nowActive" == "yes" ]; then
filename="`basename $target`"
filedate=`date +%y%m%d-%H%M%S`
wget $url -O $target/$filename-$filedate.jpg
log "saving $target/$filename-$filedate.jpg"
else
echo "no time slice for `basename $target`"
fi
done < $c
done
if [ "$htmlPath" != "" ]; then
cd $htmlPath
echo "" > $htmlFile
for d in `find . -mindepth 1 -type d`; do
for i in `ls -1 $d/*timelapse*.mp4`; do
echo "<a href=$i>$i</a><br>" >> $htmlFile
# echo '
# <video width="320" height="240" controls preload=metadata>
# <source src="'$i'" type="video/mp4">
# Your browser does not support the video tag.
# </video><br><br>
# ' >> $htmlFile
done
cd $d
test -L timelapse.mp4 && rm timelapse.mp4
ln -s `ls -1rt *-timelapse*.mp4 | tail -1` timelapse.mp4
cd ..
done
fi
exit