2011-06-07 13:26:45 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
2012-10-15 21:32:25 +00:00
|
|
|
package require cgi
|
2012-05-21 20:23:41 +00:00
|
|
|
source /mod/webif/lib/setup
|
2012-11-16 21:16:03 +00:00
|
|
|
require system.class findhsvc epg.class rsv.class
|
2012-04-18 20:26:34 +00:00
|
|
|
|
2012-10-15 21:32:25 +00:00
|
|
|
set runmode cli
|
|
|
|
if {[string match {*jim} $argv0]} { set runmode cgi }
|
|
|
|
|
2013-01-01 20:58:42 +00:00
|
|
|
set schedtime 1200
|
2012-11-16 21:16:03 +00:00
|
|
|
case $runmode {
|
|
|
|
cgi {
|
|
|
|
set type [cgi_get type "full"]
|
2013-02-09 22:46:15 +00:00
|
|
|
httpheader
|
2012-11-16 21:16:03 +00:00
|
|
|
}
|
|
|
|
cli {
|
|
|
|
set type "full"
|
|
|
|
if {"-X" in $argv} { set schedtime 7200 }
|
|
|
|
}
|
2012-10-15 21:32:25 +00:00
|
|
|
}
|
2011-06-07 14:45:01 +00:00
|
|
|
|
2013-11-05 17:39:48 +00:00
|
|
|
if {[catch {set pid [exec pgrep -n humaxtv]}]} {
|
2012-04-18 20:26:34 +00:00
|
|
|
puts "Cannot find humaxtv process."
|
|
|
|
exit
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
proc get_data {} {
|
|
|
|
global pid
|
|
|
|
|
|
|
|
set ret {}
|
|
|
|
if {[catch {set data \
|
|
|
|
[exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts]} ]} {
|
|
|
|
set ret {}
|
|
|
|
} else {
|
|
|
|
foreach line [split $data "\n"] {
|
|
|
|
regsub -all -- {[[:space:]]+} $line " " line
|
|
|
|
set name [file rootname [file tail $line]]
|
2012-04-18 22:46:21 +00:00
|
|
|
if {[dict exists $ret $name]} {
|
|
|
|
set ret($name) -1
|
|
|
|
} else {
|
|
|
|
set size [lindex [split $line " "] 6]
|
|
|
|
set ret($name) $size
|
|
|
|
}
|
2012-04-18 20:26:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $ret
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
set play 0
|
|
|
|
set rec 0
|
|
|
|
set seen {}
|
2012-04-22 20:54:29 +00:00
|
|
|
set output {}
|
2011-06-07 13:26:45 +00:00
|
|
|
|
2012-10-15 21:32:25 +00:00
|
|
|
if {$type eq "full"} {
|
|
|
|
set data [get_data]
|
|
|
|
} else {
|
|
|
|
set data {}
|
|
|
|
}
|
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
if {[llength $data]} {
|
2012-07-16 20:29:59 +00:00
|
|
|
sleep 3
|
2012-04-18 20:26:34 +00:00
|
|
|
set ndata [get_data]
|
|
|
|
foreach name [array names ndata] {
|
|
|
|
if {![dict exists $seen $name]} { set seen($name) 0 }
|
|
|
|
if {![dict exists $data $name]} { set data($name) 0 }
|
2013-03-05 00:10:38 +00:00
|
|
|
if {[file exists "/mod/tmp/webif_auto/decrypting.$name.ts"]} {
|
|
|
|
set mode "Decrypting"
|
|
|
|
set icon "178_1_00_Icon_Lock.png style=\"padding: 0 0.2em 0 0.5em\""
|
|
|
|
} elseif {$ndata($name) == -1} {
|
2012-04-18 22:46:21 +00:00
|
|
|
incr rec
|
|
|
|
incr play
|
|
|
|
set mode "Chase Playing"
|
|
|
|
set icon "745_1_11_Video_3REC_Live.png"
|
|
|
|
} elseif {$ndata($name) > $data($name) && $seen($name) < 1} {
|
2012-04-18 20:26:34 +00:00
|
|
|
incr rec
|
|
|
|
set mode "Recording"
|
|
|
|
set icon "745_1_11_Video_1REC.png"
|
|
|
|
} else {
|
|
|
|
incr play
|
|
|
|
set mode "Playing"
|
|
|
|
set icon "745_1_10_Video_2Live.png"
|
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
incr seen($name)
|
|
|
|
|
2012-10-15 21:32:25 +00:00
|
|
|
if {$runmode eq "cgi"} {
|
2012-10-23 22:51:54 +00:00
|
|
|
lappend output [concat \
|
|
|
|
"<span class=\"va stitem\">\n" \
|
|
|
|
" <img class=va src=/images/$icon>\n" \
|
|
|
|
" <span>$mode <i>$name</i></span>\n" \
|
|
|
|
"</span>\n" \
|
|
|
|
]
|
2012-10-15 21:32:25 +00:00
|
|
|
} else {
|
|
|
|
lappend output "$mode $name"
|
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
2012-04-18 20:26:34 +00:00
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
if {![system instandby] && $play < 1} {
|
|
|
|
set hsvc [system param CUR_SVC Value USERCONFIG]
|
2011-06-07 13:26:45 +00:00
|
|
|
|
2012-04-18 20:26:34 +00:00
|
|
|
set ff [$rsvdb query "
|
|
|
|
select usSvcid as svcid, usLcn as lcn,
|
|
|
|
substr(szSvcName, 2) as name
|
|
|
|
from channel.TBL_SVC
|
|
|
|
where hSvc = $hsvc
|
|
|
|
limit 1
|
|
|
|
"]
|
|
|
|
|
|
|
|
if {[llength $ff] == 1} {
|
|
|
|
lassign [lindex $ff 0] x svcid x lcn x name
|
|
|
|
set epgs [epg dbfetch get \
|
|
|
|
-service $svcid \
|
|
|
|
-time [clock seconds]\
|
|
|
|
]
|
|
|
|
set prog ""
|
|
|
|
if {[llength $epgs] == 1} {
|
|
|
|
lassign $epgs epg
|
|
|
|
set prog "- [$epg get name] ("
|
|
|
|
append prog "[clock format [$epg get start] -format %H:%M] - "
|
|
|
|
append prog "[clock format $([$epg get start] + [$epg get duration]) -format %H:%M]"
|
|
|
|
append prog ") \[[$epg percent]%\]"
|
|
|
|
}
|
2012-10-15 21:32:25 +00:00
|
|
|
|
|
|
|
if {$runmode eq "cgi"} {
|
2012-10-23 22:51:54 +00:00
|
|
|
lappend output [concat \
|
|
|
|
"<span class=\"va stitem\">\n" \
|
|
|
|
" [epg channelicon $name 30 \
|
|
|
|
{vertical-align: middle; padding: 0 4px 0 2px}]\n" \
|
|
|
|
" <span>Watching <i>$lcn: $name $prog</i></span>\n" \
|
|
|
|
"</span>\n" \
|
|
|
|
]
|
2012-10-15 21:32:25 +00:00
|
|
|
} else {
|
|
|
|
lappend output "Watching $lcn: $name $prog"
|
|
|
|
}
|
2012-04-18 20:26:34 +00:00
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 22:46:21 +00:00
|
|
|
if {[system instandby]} {
|
2012-10-15 21:32:25 +00:00
|
|
|
if {$runmode eq "cgi"} {
|
2012-10-23 22:51:54 +00:00
|
|
|
lappend output [concat \
|
2012-10-30 18:58:54 +00:00
|
|
|
"<span class=\"va stitem\">\n" \
|
2012-10-23 22:51:54 +00:00
|
|
|
" <img class=va width=28 style=\"padding: 0 4px\"" \
|
|
|
|
"src=/img/standby.png>\n" \
|
|
|
|
" <span>System is in standby.</span>\n" \
|
|
|
|
"</span>" \
|
|
|
|
]
|
2012-10-15 21:32:25 +00:00
|
|
|
} else {
|
|
|
|
lappend output "System is in standby."
|
|
|
|
}
|
2012-04-18 22:46:21 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:16:03 +00:00
|
|
|
set events [rsv list tbl_reservation \
|
|
|
|
" where ersvtype = 3 and nsttime - [clock seconds] < $schedtime
|
|
|
|
and nsttime > [clock seconds] "]
|
|
|
|
foreach event $events {
|
|
|
|
if {$runmode eq "cgi"} {
|
|
|
|
set icon "175_1_11_Reservation_Record.png"
|
|
|
|
lappend output [concat \
|
|
|
|
"<span class=\"va stitem\">\n" \
|
|
|
|
" <img class=va src=/images/$icon width=20>\n" \
|
|
|
|
" <span>Will record <i>[$event name]</i>" \
|
|
|
|
" on [$event channel_name] at"\
|
|
|
|
" [clock format [$event get nsttime] -format {%H:%M}]" \
|
|
|
|
" </span>\n" \
|
|
|
|
"</span>\n" \
|
|
|
|
} else {
|
|
|
|
lappend output [concat \
|
|
|
|
"Will record '[$event name]' " \
|
|
|
|
"on [$event channel_name] at " \
|
|
|
|
"[clock format [$event get nsttime] -format {%H:%M}]" \
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-07 13:26:45 +00:00
|
|
|
if {[llength $output]} {
|
2012-10-15 21:32:25 +00:00
|
|
|
if {$runmode eq "cgi"} {
|
2012-10-23 22:51:54 +00:00
|
|
|
puts [join $output "\n<br>\n"]
|
2012-10-15 21:32:25 +00:00
|
|
|
} else {
|
|
|
|
puts [join $output "\n"]
|
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|