initial commit of bin scripts into git
This commit is contained in:
86
gfc-date.tcl
Executable file
86
gfc-date.tcl
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
###
|
||||
#
|
||||
# if we need a new year of data
|
||||
# lynx --dump --width 300 'http://finalsiren.com/Fixture.asp?TeamID=4&SeasonID=2014' > 2014.txt
|
||||
#
|
||||
#
|
||||
###
|
||||
|
||||
proc ReturnDate {f year round out} {
|
||||
regexp {([A-Z][a-z][a-z]) (\d+) \(.*\)$} $out m mm dd
|
||||
puts "$dd $mm $year"
|
||||
return
|
||||
}
|
||||
|
||||
proc UpdateVid {year round out h hs a as} {
|
||||
set hs [regsub -all {\s+} $hs { }]
|
||||
set as [regsub -all {\s+} $as { }]
|
||||
set plot "$out\n\n$h $hs\n$a $as"
|
||||
catch {exec echo "select intid from videometadata where filename like 'Football/$year/%$round%'\;" | mysql --batch -h 192.168.0.2 --user=mythtv --password=mythtv mythconverg | tail -n1 2>/dev/null} intid
|
||||
puts "fixing missing data (y:$year/r:$round) with : {exec echo \"update videometadata set plot='$plot' where intid=$intid\;\" | mysql --batch -h 192.168.0.2 --user=mythtv --password=mythtv mythconverg}"
|
||||
catch {exec echo "update videometadata set plot='$plot' where intid=$intid\;" | mysql --batch -h 192.168.0.2 --user=mythtv --password=mythtv mythconverg}
|
||||
}
|
||||
|
||||
|
||||
set year [lindex $argv 0]
|
||||
set round [lindex $argv 1]
|
||||
|
||||
#process file of years results
|
||||
if { [catch {open "/home/ddp/bin/$year.txt" r} f] } {
|
||||
exec lynx --dump --width 300 "http://finalsiren.com/Fixture.asp?TeamID=4&SeasonID=$year" > /home/ddp/bin/$year.txt
|
||||
if { [catch {open "/home/ddp/bin/$year.txt" r} f] } {
|
||||
puts stderr "Failed to get / load year of data see comment a top of file and do it by hand"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
while { [gets $f line] >= 0 } {
|
||||
if { [regexp {R(\d+)} $line m tmp_round] } {
|
||||
regsub -all {\[\d+\]} $line {} result
|
||||
set DATA($tmp_round) "$result"
|
||||
}
|
||||
if { [regexp {(.F)} $line m tmp_round] } {
|
||||
regsub -all {\[\d+\]} $line {} result
|
||||
set DATA($tmp_round) "$result"
|
||||
}
|
||||
}
|
||||
close $f
|
||||
|
||||
if { ! [info exists DATA($round)] } {
|
||||
puts "No data for $year - $round - was it a bye?"
|
||||
exit 2
|
||||
}
|
||||
|
||||
# if the cats lost...
|
||||
if { [regexp {\s+(\w+)\s+(.+)\s+dftd\s+(\w+)\s+(.+\))\s+(.+)} $DATA($round) m h hs a as out] } {
|
||||
|
||||
# see if score doesn't start with a spc, if so this is a two word team name
|
||||
if { [regexp {^\d} $as m] == 0 } {
|
||||
if { [regexp {(\w+)\s+(.+)} $as m _a _as] } {
|
||||
set a "$a $_a"
|
||||
set as $_as
|
||||
}
|
||||
}
|
||||
ReturnDate $f $year $round $out
|
||||
if { [lindex $argv 2] == "-update" } {
|
||||
UpdateVid $year $round $out $h $hs $a $as
|
||||
}
|
||||
# if the cats won...
|
||||
} elseif { [regexp {\s+(\w+)\s+(.+)\s+lost to\s+(\w+)\s+(.+\))\s+(.+)} $DATA($round) m h hs a as out] } {
|
||||
# see if score doesn't start with a spc, if so this is a two word team name
|
||||
if { [regexp {^\d} $hs m] == 0 } {
|
||||
if { [regexp {(\w+)\s+(.+)} $hs m _h _hs] } {
|
||||
set h "$h $_h"
|
||||
set hs $_hs
|
||||
}
|
||||
}
|
||||
ReturnDate $f $year $round $out
|
||||
if { [lindex $argv 2] == "-update" } {
|
||||
UpdateVid $year $round $out $h $hs $a $as
|
||||
}
|
||||
} else {
|
||||
puts "Could not parse '$DATA($round)' !!!"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user