Auto processing and webif settings

This commit is contained in:
Bob Buxton 2020-04-19 12:56:42 +01:00
parent 51594b77cd
commit 2ccc44cdf9
12 changed files with 164 additions and 34 deletions

View File

@ -4,7 +4,7 @@ Section: misc
Version: 0.1.0-0
Architecture: mipsel
Maintainer: mymsman
Depends: webif(>=1.4.8-1),
Depends: webif(>=1.4.8-2)
Description: Check scheduled recordings against EPG and reschedule, if possible, entries that don't match the EPG
or cause conflicts

4
CONTROL/postinst Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
#!/bin/sh
ln -f /mod/webif/plugin/schedchk/schedchk.jim /mod/bin/schedchk
ln -f /mod/webif/plugin/schedchk/fmtrsv.jim /mod/bin/fmtrsv

3
CONTROL/prerm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
rm /mod/bin/schedchk
rm /mod/bin/fmtrsv

View File

@ -0,0 +1,19 @@
proc ::schedchk::ts {ts} {
set file [$ts get file]
}
proc ::schedchk::directory {dir} {
#::auto::direntries $dir ::schedchk::ts
}
proc ::schedchk::run {} {
#::auto::autoflagscan $::auto::root schedchk ::schedchk::directory
set sc_noauto [$::auto::settings _nval_setting "schedchk_noauto"]
if {!sc_noauto} {
exec /mod/webif/plugin/schedchk/schedchk.jim -rsv >@$::auto::logfd
}
}
::auto::register schedchk 300

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -0,0 +1,12 @@
#!/mod/bin/jimsh
# optlist - load list of command options from file into array
set optlist_file "[file dirname [info script]]/schedchk.optlist"
set hand [open $optlist_file]
set data [read -nonewline $hand]
set optarray [split $data \n]
close $hand
# foreach optl $optarray {
# lassign $optl desc key default helptxt
# }

22
webif/plugin/schedchk/save.jim Executable file
View File

@ -0,0 +1,22 @@
#!/mod/bin/jimsh
# mymsman
package require cgi
source /mod/webif/lib/setup
require settings.class
httpheader
set settings [settings]
# Read List of options with default values
source "/mod/webif/plugin/schedchk/optlist.jim"
# Update settings if value changed
foreach optl $optarray {
lassign $optl desc key defval helptxt
set curval [$settings _nval_setting "schedchk_$key"]
set newval [cgi_get schedchk_$key]
if {$newval != $curval} {
[settings new] _nval_setting "schedchk_$key" $newval
puts "<br>Updated -$key default"
}
}

View File

@ -10,7 +10,7 @@ proc log {msg {level 1}} {
if {$level > $::loglevel} return
puts $::logfd "[\
clock format [clock seconds] -format "%d/%m/%Y %H:%M:%S"\
] SC([pid])- $msg"
] - SC $msg"
flush $::logfd
}
@ -21,6 +21,7 @@ rsv method set {ivName val} {
# Parse command options and apply defaults
proc checkopts {argv} {
global optarray
set settings [settings]
set parmerror 0
@ -30,23 +31,15 @@ proc checkopts {argv} {
set logfd ::auto::logfd
}
# List of options with default values
set optarray {
thresh 0
d 0
debug 0
alert 0
test 0
noconflict 0
nomissepg 0
noepgchg 0
noinplace 0
}
# Read List of options with default values
source "/mod/webif/plugin/schedchk/optlist.jim"
# Override default from settings DB
foreach {key defvalue} [array get optarray] {
foreach optl $optarray {
lassign $optl desc key defval helptxt
if {$defval eq "n"} {set defval 0}
if {$defval eq "y"} {set defval 1}
set ::opts($key) [$settings _nval_setting "schedchk_$key"]
if {$::opts($key)==0} {set ::opts($key) $defvalue}
if {$::opts($key)==0} {set ::opts($key) $defval}
}
# Handle text setting for oher options
@ -63,7 +56,7 @@ proc checkopts {argv} {
#check if option in optarray list
if {[string range $arg 0 0] == "-"} {
set argx [string tolower [string range $arg 1 end]]
if {[dict exists $optarray $argx]} {
if {[dict exists $::opts $argx]} {
incr ix
set val [lindex $argl $ix]
set nval $val
@ -125,9 +118,8 @@ proc checkopts {argv} {
}
}
if {$::opts(debug) || $::opts(d)} {
if {$::opts(d)} {
set ll $::loglevel
if {$::opts(debug) > $ll} {set ll $::opts(debug)}
if {$::opts(d) > $ll} {set ll $::opts(d)}
set ::debug 1
set ::loglevel $ll
@ -231,8 +223,17 @@ proc rsvscan {} {
}
if {$start < $now} {
log "Already started? - $deps" 1
# need to check whether it has actually started and schedule alternate if not tracking
#
# Should be recording now, check if it is
#
log "Already started? Status = [$resv status ] - $deps" 1
# need to check whether it has actually started and schedule alternate if not recording
if {[$resv status]=="recording"} {
# Recording but is it actually growing
# How to associate recording with slot?
puts [system nugget recordings]
}
continue
}
@ -308,14 +309,15 @@ proc rsvscan {} {
set reason "Duration Mismatch: $dur != [$record get duration]"
log "+++ $reason +++ $deps" 1
}
if {$dur != [$record get duration]} {
set evt_crid [string toupper [$record get event_crid]]
if {$epgcrid != $evt_crid} {
set ok 0
set reason "Duration Mismatch: $dur != [$record get duration]"
set reason "Crid Mismatch: $epgcrid != $evt_crid"
log "+++ $reason +++ $deps" 1
}
if {!$ok && !$::opts(noepgchg)} {
if {!$::opts(noinplace)} {
update_event $resv $record $epsd "$deps--->$dother" $reason
update_event $resv $record $epsd "$deps" $reason
} else {
refresh $resv $deps $reason
}
@ -371,7 +373,7 @@ proc rsvscan {} {
if {[llength $conflicts] > 1} {
log "++++ [llength $conflicts] Unresolved conflicts remain +++" 0
}
log "===============================================" 1
log "===============================================" 2
epg cleanup
}
# Scan others for a suitable alternate episode
@ -605,6 +607,7 @@ proc update_event {resv other origaul desc {reason ""}} {
set ::optlist ""
set ::opt "-h"
set ::debug 0
global optarray
set logfd stdout
if {[info exists ::auto::logfd]} {
@ -620,6 +623,7 @@ if {$::opts(thresh)} {
} else {
set thresh $($now + (9*24*60*60))
}
log "Threshold $::opts(thresh) = $thresh [clock format $thresh -format {%d/%m/%Y %H:%M:%S}]" 2
# process command
switch -- $opt {
@ -635,14 +639,11 @@ switch -- $opt {
puts "schedchk -rsv = scan the recording schedule"
puts ""
puts "Option Default (unless changed in Settings) "
puts "-thresh 0 = don't check problems more than x hrs away start (0 no thresh) "
puts "-d 0 = produce detailed debug (0, 1, 2) "
puts "-test n = don't make updates "
puts "-noconflict n = don't check for confilcts"
puts "-nomissepg n = don't resolve missing epg entries"
puts "-noepgchg n = don't resolve epg time changes"
puts "-noinplace n = upate problems inplace rather than by skipping"
puts "Options Default (unless changed in Settings) "
foreach optl $optarray {
lassign $optl desc key default helptxt
puts [format "-%-11s %-4s = %s" $key $default $helptxt]
}
}
}

View File

@ -0,0 +1,8 @@
{Threshold} {thresh} 0 {Don't check for problems more than x hrs away from start (0 no thresh)}
{Debug} {d} 0 {Produce more detailed output}
{Test mode} {test} n {Don't make updates}
{No automatic} {noauto} n {Don't run regularly as part of Auto-Processing}
{No Conflicta} {noconflict} n {Don't check for confilcts}
{No miss epg} {nomissepg} n {Don't resolve missing epg entries}
{No epg change} {noepgchg} n {Don't resolve epg time/ duration/ event crid changes}
{No inplace} {noinplace} n {Update reservation by skipping & 1-off rather than inplace}

View File

@ -0,0 +1,61 @@
# schedchk settings - mymsman
#source /mod/webif/lib/setup
#require settings.class
#set settings [settings]
puts "
<fieldset style=\"display: inline\">
<legend>
<a href=\"http://wiki.hummy.tv/wiki/schedchk#schedchk_settings\" target=\"_blank\"><img src=\"/plugin/schedchk/img/schedchk32.png\" alt=\"schedchk icon\"/> schedchk (Check and fix recording schedule) settings</a>
</legend>
<p>See <b><a href=\"http://wiki.hummy.tv/wiki/schedchk#schedchk_settings\" target=\"_blank\">schedchk user guide</a></b> for help</p>
<form class=auto id=schedchk method=get
action=/plugin/schedchk/save.jim>
<table>"
# Read List of options with default values
source "/mod/webif/plugin/schedchk/optlist.jim"
# Override default from settings DB
foreach optl $optarray {
lassign $optl desc key defval helptxt
set chkbox 0
if {[string is alpha $defval]} {set chkbox 1}
if {$defval eq "n"} {set defval 0}
if {$defval eq "y"} {set defval 1}
set ::opts($key) [$settings _nval_setting "schedchk_$key"]
if {$::opts($key)==0} {set ::opts($key) $defval}
if {$chkbox} {
puts "
<tr>
<th class=key>$desc (-$key)
</th>
<td><input id=schedchk_$key name=schedchk_$key
type=checkbox value=1"
if {$::opts($key)} { puts -nonewline " checked" }
puts ">
</td>
<td>$helptxt</td>
</tr>"
} else {
puts "
<tr>
<th class=key>$desc (-$key)
</th>
<td><input id=schedchk_$key name=schedchk_$key
type=number size=5 value=$::opts($key)>
</td>
<td>$helptxt</td>
</tr>"
}
}
puts "
<tr>
<td colspan=2><input type=submit value=\"Update settings\">
<div id=schedchk_output></div>
</td>
</tr>
</table>
</form>
</fieldset>
"