show current channel, retain more backups

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@927 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-04-18 20:26:34 +00:00
parent 6ab9318fa9
commit a5c65505e4
6 changed files with 103 additions and 37 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.9.5-2
Version: 0.9.5-3
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons,mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.1)

View File

@ -19,7 +19,7 @@ set file [file tail [cgi_get file \
if {[string match {auto-*} $file]} {
# Delete any automatic backups over 7 days old.
set mt $(7 * 86400)
set mt $(15 * 86400)
foreach af [glob -nocomplain "$dir/auto-*"] {
set aft [file mtime $af]
set diff $($now - $aft)

View File

@ -1,49 +1,95 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require system.class findhsvc epg.class
puts "Content-Type: text/html"
puts ""
if {[catch {set pid [exec pgrep humaxtv]}]} { exit }
if {[catch {set data [exec lsof -p $pid | grep Video | fgrep .ts]} ]} {
exit
if {[catch {set pid [exec pgrep humaxtv]}]} {
puts "Cannot find humaxtv process."
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
}
proc get_data {} {
global pid
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"
set ret {}
if {[catch {set data \
[exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts]} ]} {
set ret {}
} else {
set mode "Watching"
set icon "745_1_10_Video_2Live.png"
foreach line [split $data "\n"] {
regsub -all -- {[[:space:]]+} $line " " line
set name [file rootname [file tail $line]]
set size [lindex [split $line " "] 6]
set ret($name) $size
}
}
return $ret
}
incr seen($name)
set play 0
set rec 0
set seen {}
lappend output "<img class=va src=/images/$icon><span class=va>
$mode&nbsp;$name</span><br>"
set data [get_data]
if {[llength $data]} {
sleep 2
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 }
if {$ndata($name) > $data($name) && $seen($name) < 1} {
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"
}
incr seen($name)
lappend output "<img class=va src=/images/$icon><span class=va>
$mode&nbsp;$name</span>"
}
}
if {![system instandby] && $play < 1} {
set hsvc [system param CUR_SVC Value USERCONFIG]
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]%\]"
}
lappend output "[epg channelicon $name 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]
<span class=va> Watching $lcn: $name $prog</span>"
}
}
if {[llength $output]} {
puts [join $output " "]
puts [join $output "<br>"]
}

View File

@ -34,5 +34,21 @@ if {![exists -proc get_channel_attr]} {
}
return 0
}
proc get_channel_attr_byhsvc {hsvc {field usLcn}} {
global rsvdb
set ff [$rsvdb query "
select $field
from channel.TBL_SVC
where hSvc = $hsvc
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return 0
}
}

View File

@ -74,7 +74,7 @@ settings method smtp_server {{server ""}} {
}
settings method _nval_setting {name {val -1}} {
global settingsdb;
global settingsdb
if {$val == -1} {
# Get

View File

@ -119,14 +119,14 @@ proc {system restartpending} {} {
close [open /tmp/.restartpending w]
}
proc {system param} {param {type Value}} {
proc {system param} {param {type Value} {tbl MENUCONFIG}} {
if {[catch {set db [sqlite3.open /var/lib/humaxtv/setup.db]} msg]} {
return 0
}
set val 0
set ret [$db query "
select item$type
from TBL_MENUCONFIG
from TBL_$tbl
where itemName = '$param'
"]
if {[llength $ret] == 1} {
@ -143,6 +143,10 @@ proc {system padding} {} {
]
}
proc {system instandby} {} {
return [system param LAST_STANDBY Value USERCONFIG]
}
proc {system mkdir_p} {dir} {
exec /mod/bin/busybox/mkdir -p $dir
}