Add source for the new Vore Tournament logo. Uses clip art from http://www.openclipar...
[voretournament/voretournament.git] / misc / tools / demotc-race-record-extractor.sh
1 #!/bin/sh
2
3 case "$2" in
4         old)
5                 PATTERN='all-time fastest lap record with (.*)\n'
6                 ;;
7         new|*)
8                 PATTERN='//RA?CE? RECORD SET (.*)\n'
9                 ;;
10 esac
11
12 d=$1
13 i=0
14 demotc.pl grep "$d" "$PATTERN" | while IFS=" " read -r timecode result; do
15         timecode=${timecode%:}
16         result=${result#\"}
17         result=${result%\"}
18         result=${result%% *}
19
20         echo "Possible record found at $timecode: $result, extracting..."
21
22         minutes=${result%%:*}
23         result=${result#*:}
24         seconds=${result%%.*}
25         result=${result#*.}
26         tenths=$result
27
28         timecode_start=`echo "$timecode - $minutes*60 - $seconds - $tenths*0.1 - 2" | bc -l`
29         timecode_end=`echo "$timecode + 2" | bc -l`
30         i=$(($i + 1))
31         demotc.pl cut "$d" "playback-$i.dem" "$timecode_start" "$timecode_end"
32         demotc.pl cut "$d" "capture-$i.dem" "$timecode_start" "$timecode_end" --capture
33 done