2011-06-07 13:26:45 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
2011-06-07 14:45:01 +00:00
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
2011-06-09 00:42:26 +00:00
|
|
|
#puts "<img style=\"vertical-align: middle\" src=/images/745_1_11_Video_1REC.png><span style=\"vertical-align: middle\">Recording one thing</span>"
|
|
|
|
#puts "<img style=\"vertical-align: middle\" src=/images/745_1_11_Video_1REC.png><span style=\"vertical-align: middle\">Recording another thing</span>"
|
|
|
|
#puts "<img style=\"vertical-align: middle\" src=/images/745_1_10_Video_2Live.png><span style=\"vertical-align: middle\">Watching something else</span>"
|
|
|
|
|
2011-06-07 14:45:01 +00:00
|
|
|
if {[catch {set pid [exec pgrep humaxtv]}]} { exit }
|
2011-06-07 13:26:45 +00:00
|
|
|
|
|
|
|
if {[catch {set data [exec lsof -p $pid | grep Video | fgrep .ts]} ]} {
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
set lines [split $data "\n"]
|
|
|
|
foreach line $lines {
|
|
|
|
regsub -all -- {[[:space:]]+} $line " " line
|
|
|
|
set fields [split $line " "]
|
|
|
|
set name [lindex [split $line "/"] end]
|
|
|
|
set size($name) [lindex $fields 6]
|
|
|
|
set seen($name) 0
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
set data [exec lsof -p $pid | grep Video | fgrep .ts]
|
|
|
|
regsub -all -- {[[:space:]]+} $line " " line
|
|
|
|
set lines [split $data "\n"]
|
|
|
|
foreach line $lines {
|
|
|
|
regsub -all -- {[[:space:]]+} $line " " line
|
|
|
|
set fields [split $line " "]
|
|
|
|
set name [lindex [split $line "/"] end]
|
|
|
|
set size2 [lindex $fields 6]
|
|
|
|
|
|
|
|
if { $size2 > $size($name) && $seen($name) < 1 } {
|
|
|
|
set mode "Recording"
|
|
|
|
set icon "745_1_11_Video_1REC.png"
|
|
|
|
} else {
|
|
|
|
set mode "Watching"
|
|
|
|
set icon "745_1_10_Video_2Live.png"
|
|
|
|
}
|
|
|
|
|
|
|
|
incr seen($name)
|
|
|
|
|
2011-06-21 22:38:20 +00:00
|
|
|
lappend output "<img class=va src=/images/$icon><span class=va>
|
|
|
|
$mode $name</span><br>"
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if {[llength $output]} {
|
2011-06-09 00:42:26 +00:00
|
|
|
puts [join $output " "]
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|