Compare commits

...

20 Commits

Author SHA1 Message Date
df
31140a2747 Remove typo (excess $) 2021-01-03 19:40:24 +00:00
df
c7c16af68d Deal with weirdo setup where TSR not enabled ... 2020-11-22 22:45:18 +00:00
df
8382022122 Add check for DLNA streaming vs playing 2020-11-14 13:24:04 +00:00
df
a14057341f Add system::tsr, system::tsrdir 2020-11-14 13:24:04 +00:00
df
84b17dd739 Add test for time-shifted playing
Per https://hummy.tv/forum/threads/detecting-time-shift-usage.9569/
2020-11-14 13:24:04 +00:00
df
b3d9759878 Add check for DLNA streaming vs playing
Count localhost:9000->host:n and subtract from  count of played items
2020-11-14 13:24:04 +00:00
df
7bf6aaa237 Detect playing a show with DLNA
Remove `-X` of lsof  and look for localhost:n->host:9000 "filename".
Remove some unnecessary `\`s
2020-11-14 13:24:04 +00:00
df
5f02feddfb Fix indentation for data case n 2020-11-14 13:24:03 +00:00
df
352c54a471 Add "Copying" status
Copying: same file name+ext open twice(+) and access mode r.
2020-11-14 13:24:03 +00:00
HummyPkg
d7c15163e1 Update release version 2020-10-16 14:28:17 +01:00
879c458256 Merge pull request 'df-auto-deq-patch' (#14) from df/webif:df-auto-deq-patch into master
Reviewed-on: hummypkg/webif#14
2020-10-16 13:27:15 +00:00
df
1a25e2a3f1 Fix potential format error with queue item containing %
If an item is in the queue whose file name contains a %, the following error occurs, causing the item never to be dequeued:
```in procedure '::auto::dumpq' called at file "/mod/webif/lib/auto/deq", line 167
at file "/mod/webif/lib/auto/deq", line 118
/mod/webif/lib/auto/deq:118: Error: not enough arguments for all format specifiers```
The file name needs to be passed to `format` as a parameter with format `%s` rather than embedding it in the format string, or else ```log "[format ...][$q get file]"```
2020-10-16 14:26:30 +01:00
006a04683a Merge pull request 'df-autolast-future-patch' (#13) from df/webif:df-autolast-future-patch into master
Reviewed-on: hummypkg/webif#13
2020-10-16 13:25:41 +00:00
df
3623a26a08 Correct autolast in the future
Fixing issue in <https://hummy.tv/forum/threads/recursive-auto-shrink-auto-decrypt-no-longer-working.9399/post-134718>.
2020-10-16 14:25:15 +01:00
c428a367a1 Merge pull request 'Use service ids to map to mux names' (#12) from prpr/webif:master into master
Reviewed-on: hummypkg/webif#12
2020-10-16 13:18:00 +00:00
480108f3a2 Merge pull request 'Schedule all epsiodes of series' (#11) from MymsMan/webif:SeriesSched into master
Reviewed-on: hummypkg/webif#11
2020-10-16 13:16:25 +00:00
2884a82dbf Schedule all epsiodes of series 2020-10-16 14:16:15 +01:00
ac4b392db8 Merge pull request 'Rotate auto.log to auto_<timestamp>.log when it excedes settings logsize' (#16) from MymsMan/webif:Rotate_auto.log into master
Reviewed-on: hummypkg/webif#16
2020-10-16 13:14:11 +00:00
c3d360fa63 Rotate auto.log to auto_<timestamp>.log when it excedes settings logsize 2020-10-16 14:13:16 +01:00
3f199f32ab Update 'webif/html/diag/mux.jim' 2020-07-14 00:29:02 +00:00
8 changed files with 162 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 1.4.8-9
Version: 1.4.8-10
Architecture: mipsel
Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.27),lighttpd(>=1.4.39-1),jim(>=0.79),jim-pack(>=0.79),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-2),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.13),webif-charts(>=1.2-1),stripts(>=1.4.2),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.98),sqlite3(>=3.15.1),jim-xconv,zip(>=3.0-1),wget

View File

@@ -15,8 +15,7 @@ switch $runmode {
}
cli {
set type "full"
if {"-X" in $argv} { set schedtime 7200 }
if {"-x" in $argv} { set schedtime 7200 }
if {[lsearch -nocase $argv "-x"] >= 0} { set schedtime 7200 }
}
}
@@ -61,11 +60,11 @@ proc register_statusop {op name icon} {
eval_plugins status 1
proc get_data {} {
global pid exts
global pid exts stream tsr tsrcnt
set ret {}
if {[catch {set data \
[exec /mod/webif/lib/bin/lsof -X -Fns -p $pid]} msg]} {
[exec /mod/webif/lib/bin/lsof -Fnsa -p $pid]} msg]} {
debug "Error: $msg"
set ret {}
} else {
@@ -73,47 +72,68 @@ proc get_data {} {
foreach line [split $data "\n"] {
set typ [string index $line 0]
switch $typ {
s {
a {
set access [string index $line 1]
}
s {
set size [string range $line 1 end]
}
n {
if {[string first Video/ $line] == -1 && \
[string first /media/ $line] == -1} {
continue
}
regsub -- { \([^\)]+\)$} $line "" line
set ext [file extension $line]
if {$ext ni $exts} continue
set file [subst -nocommands -novariables \
[string range $line 1 end]]
# Skip HD-Fox TSR buffer
if {$file eq "/media/drive1/.tsr/0.ts"} {
continue
}
# Handle chase play (same file open twice
# and recently written)
if {[dict exists $ret $file] && \
$ext eq ".ts"} {
set age [expr [clock seconds] - \
[file mtime $file]]
if {$age < 60} {
set ret($file) -1
# strip initial n and trailing " (...)" if present
regsub -all -- {(^n)|( \([^\)]+\)$)} $line "" line
set file [subst -nocommands -novariables $line]
set ext [file extension $line]
# Note but skip TSR buffers
if {[file rootname $file] eq $tsr} {
if {$ext eq ".nts"} {
incr tsrcnt
}
continue
}
if {[string first Video/ $line] >= 0 ||
[string first /media/ $line] >= 0} {
if {$ext ni $exts} {
continue
}
} elseif {[string first $line /] >= 0} {
# fast skip other files
continue
} elseif {[regexp -- {[A-Za-z0-9._-]+:([0-9]+)->([A-Za-z0-9._-]+):([0-9]+)} $line _ sprt host dprt]} {
if {$sprt == 9000} {
incr stream
continue
} elseif {$dprt == 9000} {
set file [format "DLNA from %s" $host]
set size 0
set ext ""
} else {
continue
}
} else {
continue
}
# Handle chase play (same file open twice
# and recently written)
if {[dict exists $ret $file] &&
$ext eq ".ts"} {
set age [expr [clock seconds] - [file mtime $file]]
if {$age < 60} {
set access [lindex [dict get $ret $file] 1]
set ret($file) [list -1 $access]
}
} else {
debug "$file = $size,$access"
set ret($file) [list $size $access]
}
} else {
debug "$file = $size"
set ret($file) $size
}
}
}
}
}
foreach file [dict keys $::ops] {
if {![dict exists $ret $file]} {
if {[file exists $file]} {
set ret($file) [file size $file]
} else {
set ret($file) 0
}
set ret($file) \
[list [expr {[file exists $file]? [file size $file]: 0}] u]
}
}
return $ret
@@ -139,9 +159,12 @@ proc add_output {icon mode name} {
set play 0
set rec 0
set stream 0
set output {}
set ops {}
set model [system model]
set tsr [file rootname [system tsr]]
set tsrcnt 0
foreach opfile [glob -nocomplain -directory /tmp -tails -- ".bgop.*"] {
set op [string range $opfile 6 end]
@@ -179,8 +202,11 @@ if {[llength $data]} {
debug " NDATA: ($ndata)"
set rr 0
}
set bnames [lsort [lmap x [array names data] {
file tail $x
}]]
foreach file [array names data] {
set bname [file rootname [file tail $file]]
set bname [file tail $file]
set name [string map {
"/mnt/hd2/My Video/" ""
@@ -189,17 +215,20 @@ if {[llength $data]} {
".ts" ""
} $file]
if {$data($file) == -1} {
if {[lindex $data($file) 0] == -1} {
set mode chase
} elseif {$rr} {
if {$file in $recs} {
set mode rec
} elseif {[llength [lsearch -all $bnames $bname]] == 2} {
# two different files having same file.ext open
set mode copy
} else {
set mode play
}
} else {
if {![dict exists $ndata $file]} continue
if {$ndata($file) > $data($file)} {
if {[lindex $ndata($file) 0] > [lindex $data($file) 0]} {
set mode rec
} else {
set mode play
@@ -231,8 +260,20 @@ if {[llength $data]} {
}
play {
incr play
set mode "Playing"
set icon "745_1_10_Video_2Live.png"
if {$play > $stream} {
set mode "Playing"
set icon "745_1_10_Video_2Live.png"
} else {
set mode "Streaming"
set icon "/img/dlna.png"
}
}
copy {
if {[lindex $data($file) 1] ne "r"} {
continue
}
set mode "Copying"
set icon "/img/dlna.png"
}
default {
if {[dict exists $statusops $mode]} {
@@ -277,18 +318,25 @@ if {![system instandby] && $play < 1} {
append prog ") \[[$epg percent]%\]"
}
if {$runmode eq "cgi"} {
set s "
<span class=\"va stitem\">
[epg channelicon $name 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]
<span>Watching <i>$lcn: $name $prog</i></span>
"
append s "</span>"
lappend output $s
# 0 => no TSR; >=2 => TSR
if {$tsrcnt == 0 || $tsrcnt == 2} {
set s "Watching"
} elseif {$tsrcnt == 3} {
set s "Watching (delayed)"
} else {
set s "Watching $lcn: $name $prog"
lappend output $s
debug "tsrcnt=$tsrcnt"
set s "Not watching"
}
if {$runmode eq "cgi"} {
lappend output [format "
<span class=\"va stitem\">
[epg channelicon %s 30 \
{vertical-align: middle; padding: 0 4px 0 2px}]
<span>%s <i>%s: %s %s</i></span>
</span>
" $name $s $lcn $name $prog]
} else {
lappend output [format "%s %s: %s %s" $s $lcn $name $prog]
}
}
}

View File

@@ -19,6 +19,19 @@ proc f2c {frequency} {
return [expr int($ch)]
}
proc svc2mux {svcid mux} {
return [switch $($svcid / 4096) {
1 { format "PSB1/BBC A" }
2 { format "PSB2/D3&4" }
4 { format "PSB3/BBC B" }
3 { format "COM4/SDN" }
5 { format "COM5/ARQ A" }
6 { format "COM6/ARQ B" }
10 { format "COM7/ARQ C" }
default { format $mux }
}]
}
puts "
<div class=va>
<img class=va src=/img/aerials.png height=50>
@@ -61,7 +74,7 @@ foreach tw [$db query {
puts "<td>[system strip $netName]</td>"
set channels [$db query {
select usLcn, szSvcName, szPrvName, aucDefaultAuthority
select usLcn, szSvcName, usSvcId, szPrvName, aucDefaultAuthority
from TBL_SVC left join TBL_PRV using (prvIdx)
where tsIdx = %s
order by usLcn
@@ -72,14 +85,15 @@ foreach tw [$db query {
} else {
set mux "Unknown"
}
if {[llength $channels] != 0} {
set chan [lindex $channels 0]
lassign $chan x lcn x name x svcid
set mux [svc2mux $svcid $mux]
}
set ehs 0
foreach chan $channels {
lassign $chan x lcn x name
set name [system strip $name]
lassign $chan x lcn
if {$lcn >= 800} { incr ehs }
if {[dict exists $::muxdb $name]} {
set mux $::muxdb($name)
}
}
puts "<td>$mux</td>"
if {$eSystem == 0} {
@@ -106,7 +120,7 @@ foreach tw [$db query {
</tr>"
altrow reset
foreach chan $channels {
lassign $chan x lcn x name x prv x auth
lassign $chan x lcn x name x svcid x prv x auth
set name [system strip $name]
set prv [system strip $prv]
altrow

View File

@@ -115,8 +115,8 @@ proc ::auto::dumpq {qq} {
if {[$q get action] in $::auto::plugins} {
set pri $::auto::plugins([$q get action])
}
log [format " C: %4d %5d %8s - [$q get file]" \
[$q get id] $pri [$q get action]] 2
log [format " C: %4d %5d %8s - %s" \
[$q get id] $pri [$q get action] [$q get file]] 2
}
}

View File

@@ -73,7 +73,10 @@ if {!$::auto::force} {
set timesincelast $(([clock seconds] - [$::auto::settings autolast]) \
/ 60)
if {$timesincelast < $autofreq} {
if {$timesincelast < 0} {
# time machine issue: correct it
$::auto::settings autolast 0
} elseif {$timesincelast < $autofreq} {
::auto::log "Aborting, not yet time to run." 2
::auto::log " elapsed (minutes): $timesincelast (<$autofreq)" 2
exit

View File

@@ -5,12 +5,13 @@ set ::auto::logprefix ""
set ::auto::loglevel 1
proc ::auto::loginit {} {
variable settings
set logsize [$settings logsize]
# Rotate log file if large enough.
if {[file exists $::auto::logfile] &&
[file size $::auto::logfile] > 2097152} {
file copy -force $::auto::logfile "/mod/tmp/auto_old.log"
file delete $::auto::logfile
[file size $::auto::logfile] > $logsize} {
set tstamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
file rename -force $::auto::logfile "/mod/tmp/auto.$tstamp.log"
}
# Open log file

View File

@@ -967,19 +967,29 @@ proc {rsv construct} {event type} {
set args(szFPBRecPath) "$args(szevtname)"
set events {}
set seen {}
set now [clock seconds]
set progs [lmap i [\
epg dbfetch dump -scrid [$event get series_crid] \
-sort start] {
if {[set ecrid [$i get event_crid]] eq ""} continue
if {$ecrid in $seen} continue
lappend seen $ecrid
if {[$i get start] < [$event get start]} {
if {[$i end] < $now} {
set args(usLastRecordedEvtId) [$i get event_id]
continue
}
if {$ecrid in $seen} continue
lappend seen $ecrid
lappend events [rsv mkaul $i]
list "1$::ccrid$ecrid"
}]
# set 1st event to record
binary scan [string range [lindex $events 0] 0 15] \
iiii service_id start end event_id
#puts "$service_id $start [clock format $end] $event_id"
set args(hsvc) $service_id
set args(nsttime) $start
set args(usevtid) $event_id
set args(nduration) $($end-$start)
set args(szEventToRecord) "[join $progs "|"]|"
set args(aulEventToRecordInfo) [join $events ""]
}

View File

@@ -398,6 +398,22 @@ proc {system disktemp} {} {
return $($temp + 0)
}
proc {system tsrdir} {} {
switch [system model] {
HDR {
set tsrdir "/mnt/hd2/Tsr"
}
HD {
set tsrdir "/media/drive1/.tsr"
}
}
return $tsrdir
}
proc {system tsr} {} {
return [file join [system tsrdir] "0.ts"]
}
require pretty_size
proc {system diskspace} {{raw 0}} {
@@ -412,13 +428,12 @@ proc {system diskspace} {{raw 0}} {
set perc $($used * 100 / $size)
set fperc $(100 - $perc)
set tsrdir [system tsrdir]
switch [system model] {
HDR {
set tsrdir "/mnt/hd2/Tsr"
set tsrok [file isdirectory $tsrdir]
}
HD {
set tsrdir "/media/drive1/.tsr"
set tsrok [file exists "$tsrdir/0.ts"]
}
}