misc changes
This commit is contained in:
parent
2ccc44cdf9
commit
93ecb00259
|
@ -11,7 +11,7 @@ proc ::schedchk::directory {dir} {
|
|||
proc ::schedchk::run {} {
|
||||
#::auto::autoflagscan $::auto::root schedchk ::schedchk::directory
|
||||
set sc_noauto [$::auto::settings _nval_setting "schedchk_noauto"]
|
||||
if {!sc_noauto} {
|
||||
if {!$sc_noauto} {
|
||||
exec /mod/webif/plugin/schedchk/schedchk.jim -rsv >@$::auto::logfd
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,25 +87,25 @@ proc checkopts {argv} {
|
|||
-slot {
|
||||
incr ix
|
||||
set find [lindex $argl $ix]
|
||||
append ::select "ulslot = $find "
|
||||
append ::select "and ulslot = $find "
|
||||
}
|
||||
-l -
|
||||
-lcn {
|
||||
incr ix
|
||||
set find [lindex $argl $ix]
|
||||
append ::select "usLcn = $find "
|
||||
append ::select "and usLcn = $find "
|
||||
}
|
||||
-n -
|
||||
-name {
|
||||
incr ix
|
||||
set find [lindex $argl $ix]
|
||||
append ::select "szevtname like '%$find%' "
|
||||
append ::select "and szevtname like '%%$find%%' "
|
||||
}
|
||||
-c -
|
||||
-cname {
|
||||
incr ix
|
||||
set find [lindex $argl $ix]
|
||||
append ::select "szSvcName like '%$find%' "
|
||||
append ::select "and szSvcName like '%%$find%%' "
|
||||
}
|
||||
default {
|
||||
log "Unrecognized option: $arg" 0
|
||||
|
@ -133,43 +133,8 @@ proc checkopts {argv} {
|
|||
|
||||
}
|
||||
|
||||
|
||||
proc svcmap {} {
|
||||
# establish rsv <-> epg service_id mapping
|
||||
global svcmap svcdef
|
||||
set svcmap {}
|
||||
set svcdef {}
|
||||
set svcdef(0) 0
|
||||
lmap i \
|
||||
[$::channeldb query {select hSvc, usSvcid, eVideoType from TBL_SVC}] \
|
||||
{
|
||||
set svcmap([lindex $i 1]) [lindex $i 3]
|
||||
set svcdef([lindex $i 1]) [lindex $i 5]
|
||||
}
|
||||
set svckeys [array names svcmap]
|
||||
}
|
||||
|
||||
proc conflict-list {} {
|
||||
global conflicts
|
||||
if {$::opts(noconflict)} {
|
||||
log "-noconflict Bypassing automatic conflict resolution"
|
||||
set conflicts {}
|
||||
return
|
||||
}
|
||||
|
||||
set conflicts [rsv newconflicts [system tuners] "xlist"]
|
||||
if {[llength $conflicts] > 1} {
|
||||
log "++++ [llength $conflicts] Conflicts exist +++" 1
|
||||
log "$conflicts" 2
|
||||
}
|
||||
}
|
||||
|
||||
proc rsvscan {} {
|
||||
global svcmap conflicts svcdef
|
||||
#svcmap
|
||||
#conflict-list
|
||||
|
||||
if {$::select != ""} {set ::select "where $::select"}
|
||||
set resvs [rsv list TBL_RESERVATION $::select]
|
||||
|
||||
# for each reservation
|
||||
|
@ -266,7 +231,7 @@ proc rsvscan {} {
|
|||
$ecrid"
|
||||
}
|
||||
puts "========================================================"
|
||||
|
||||
puts ""
|
||||
|
||||
}
|
||||
|
||||
|
@ -282,7 +247,7 @@ set ::debug 0
|
|||
set logfd stdout
|
||||
set ::loglevel 0
|
||||
set ::opts {}
|
||||
set ::select ""
|
||||
set ::select "where 1 "
|
||||
|
||||
# validate parameters
|
||||
checkopts $argv
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
#!/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
|
||||
set optarray {
|
||||
{{Threshold} {thresh} 36 {Don't check for problems more than x hrs away from start}}
|
||||
{{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 alert} {noAlert} n {Don't generate webif alert messages for changes made}}
|
||||
{{No Conflicts} {noConflict} n {Don't check for conflicts}}
|
||||
{{No Unscheduled} {noUnsched} n {Don't check for episodes missing from schedule}}
|
||||
{{No sCRID change} {noSCRID} n {Don't check for series CRID changes}}
|
||||
{{No one off} {no1off} n {Don't check for episodes scheduled as one off programmes}}
|
||||
{{No not recorded} {noNotRec} n {Don't check for failures to record}}
|
||||
{{No missing epg} {noMissEPG} n {Don't resolve missing epg entries}}
|
||||
{{No epg changes} {noEPGchg} n {Don't resolve epg time/ duration/ event crid changes}}
|
||||
{{No split checks} {noSplit} n {Don't resolve repeated split recordings}}
|
||||
{{No inplace} {noInplace} n {Update reservation by skipping & 1-off rather than inplace}}
|
||||
}
|
||||
|
||||
# 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 {
|
||||
|
|
|
@ -12,6 +12,10 @@ proc log {msg {level 1}} {
|
|||
clock format [clock seconds] -format "%d/%m/%Y %H:%M:%S"\
|
||||
] - SC $msg"
|
||||
flush $::logfd
|
||||
# Generate webif alerts for changes/errors
|
||||
if {!$::opts(noalert) && $level == 0} {
|
||||
system notify "SchedChk: $msg"
|
||||
}
|
||||
}
|
||||
|
||||
# let's mess with the internals - needs to be moved to rsv.class
|
||||
|
@ -36,6 +40,7 @@ proc checkopts {argv} {
|
|||
# Override default from settings DB
|
||||
foreach optl $optarray {
|
||||
lassign $optl desc key defval helptxt
|
||||
set key [string tolower $key]
|
||||
if {$defval eq "n"} {set defval 0}
|
||||
if {$defval eq "y"} {set defval 1}
|
||||
set ::opts($key) [$settings _nval_setting "schedchk_$key"]
|
||||
|
@ -131,6 +136,11 @@ proc checkopts {argv} {
|
|||
exit
|
||||
}
|
||||
|
||||
log "Current options" 1
|
||||
foreach optl $optarray {
|
||||
lassign $optl desc key default helptxt
|
||||
log "[format "-%-11s %-4s" $key $::opts([string tolower $key])]" 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,7 +162,7 @@ proc svcmap {} {
|
|||
proc conflict-list {} {
|
||||
global conflicts
|
||||
if {$::opts(noconflict)} {
|
||||
log "-noconflict Bypassing automatic conflict resolution"
|
||||
log "-noconflict Bypassing automatic conflict resolution" 2
|
||||
set conflicts {}
|
||||
return
|
||||
}
|
||||
|
@ -165,7 +175,7 @@ proc conflict-list {} {
|
|||
}
|
||||
|
||||
proc rsvscan {} {
|
||||
global svcmap conflicts svcdef now thresh
|
||||
global svcmap conflicts svcdef now thresh slot name def
|
||||
svcmap
|
||||
conflict-list
|
||||
|
||||
|
@ -175,6 +185,9 @@ proc rsvscan {} {
|
|||
# for each reservation
|
||||
#
|
||||
foreach resv $resvs {
|
||||
# Ignore manual recordings & reminders
|
||||
if {[$resv get ersvtype] != 3} { continue}
|
||||
|
||||
set name [$resv name]
|
||||
set def $svcdef([$resv get hsvc])
|
||||
set s [$resv start]
|
||||
|
@ -182,11 +195,19 @@ proc rsvscan {} {
|
|||
set d [$resv get nduration]
|
||||
set e $($s + $d)
|
||||
set slot [$resv get ulslot]
|
||||
set lasttime $now
|
||||
set dresv "$ds [clock format $d -format {%H:%M}] === slot $slot === $name === [$resv channel_name]"
|
||||
|
||||
# add any missing episodes
|
||||
if {[$resv isseries]} {
|
||||
miss_epsd $resv $dresv
|
||||
set s [$resv start]
|
||||
set d [$resv get nduration]
|
||||
set e $($s + $d)
|
||||
}
|
||||
|
||||
lassign [$resv padded 1] sp ep
|
||||
|
||||
# Ignore manual recordings & reminders
|
||||
if {[$resv get ersvtype] != 3} { continue}
|
||||
# Has event passed
|
||||
if {$now > $e + $ep} {
|
||||
set ended 1
|
||||
|
@ -195,7 +216,7 @@ proc rsvscan {} {
|
|||
set ended 0
|
||||
}
|
||||
|
||||
set dresv "$ds [clock format $d -format {%H:%M}] === slot $slot === $name === [$resv channel_name]"
|
||||
|
||||
|
||||
if {!$ended} {
|
||||
log "Reservation - $dresv" 2
|
||||
|
@ -205,6 +226,26 @@ proc rsvscan {} {
|
|||
set ecrid [$resv get szCRID]
|
||||
|
||||
if {[llength $elist] > 0} {
|
||||
lassign [lindex $elist 0] service_id start end event_id
|
||||
|
||||
# Check 1st aul entry matchs current resv details, should always match?
|
||||
if {$service_id != [$resv get hsvc]} {
|
||||
log "Service id Mismatch $service_id != [$resv get hsvc] = $dresv" 1
|
||||
# what to do?
|
||||
}
|
||||
if {$start != $s} {
|
||||
log "Start time id Mismatch $start != $s = $dresv" 1
|
||||
# what to do?
|
||||
}
|
||||
if {$end != $e} {
|
||||
log "End time Mismatch $end != $e = $dresv" 1
|
||||
# what to do?
|
||||
}
|
||||
if {$event_id != [$resv get usevtid]} {
|
||||
log "Event_id Mismatch $event_id != [$resv get usevtid] = $dresv" 1
|
||||
# what to do?
|
||||
}
|
||||
|
||||
#
|
||||
# check each episode scheduled
|
||||
#
|
||||
|
@ -213,169 +254,217 @@ proc rsvscan {} {
|
|||
incr enum
|
||||
set ecrid [lindex $ecrids $enum]
|
||||
set epgcrid [string range $ecrid [string first "/" $ecrid] end]
|
||||
set ecrid [string range $ecrid 1 end]
|
||||
# set ecrid [string range $ecrid 1 end]
|
||||
set dur $($end-$start)
|
||||
set lasttime $end
|
||||
set deps "[clock format $start -format {%d/%m/%y %H:%M}] [clock format $dur -format {%H:%M}] === slot $slot === $name === [$resv channel_name]"
|
||||
|
||||
if {$start > $thresh} {
|
||||
log "Start > Threshold - $deps" 2
|
||||
break
|
||||
}
|
||||
|
||||
if {$start < $now} {
|
||||
#
|
||||
# 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
|
||||
}
|
||||
|
||||
set svc $svcmap($service_id)
|
||||
# Retrieve epg record for the episode
|
||||
set record [lindex [\
|
||||
epg dbfetch dump -service $svc -event $event_id -sort ""] 0]
|
||||
log "$service_id $start $end $svc $event_id $record $ecrid $epgcrid" 3
|
||||
|
||||
if {$record==""} {
|
||||
#
|
||||
# No epg rcord found for the episode - find alternate showing
|
||||
#
|
||||
log "+++ No matching epg entry ++++ $deps" 0
|
||||
if {$::opts(nomissepg)} {
|
||||
log "-nomissepg - Not checking for alternate" 1
|
||||
continue
|
||||
}
|
||||
# look for an alternate showing
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start" ]
|
||||
#param "collate nocase"
|
||||
log "$ecrid $epgcrid $ecrids $others" 32
|
||||
set other [findAlternate $resv $others $start $def 1]
|
||||
if {$other != ""} {
|
||||
set ostart [$other get start]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
# attempt to schedule the alternate (inplace)
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $other $epsd "$deps--->$dother" "Event Changed"
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
# attempt to schedule the alternate (new even+skip)
|
||||
if {[schedule $other $dother "Event Changed"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
cancel $resv $deps "Event Changed"
|
||||
} else {
|
||||
# move crid from scheduled to recorded
|
||||
replaceskip $resv $ecrid $deps "Event Changed"
|
||||
#refresh $resv $deps
|
||||
}
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
#
|
||||
# Epg entry for the episode found
|
||||
#
|
||||
|
||||
# Check that details match
|
||||
|
||||
set epgname [$record get name]
|
||||
set def $svcdef([$record get channel_hsvc])
|
||||
set deps "[clock format $start -format {%d/%m/%y %H:%M}] [clock format $dur -format {%H:%M}] === slot $slot === $epgname === [$record get channel_name]"
|
||||
|
||||
log "Episode $deps" 2
|
||||
set ok 1
|
||||
set reason "no reason"
|
||||
if {$start != [$record get start]} {
|
||||
set ok 0
|
||||
set reason "Start Mismatch: $start != [$record get start"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
if {$dur != [$record get duration]} {
|
||||
set ok 0
|
||||
set reason "Duration Mismatch: $dur != [$record get duration]"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
set evt_crid [string toupper [$record get event_crid]]
|
||||
if {$epgcrid != $evt_crid} {
|
||||
set ok 0
|
||||
set reason "Crid Mismatch: $epgcrid != $evt_crid"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
if {!$ok && !$::opts(noepgchg)} {
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $record $epsd "$deps" $reason
|
||||
} else {
|
||||
refresh $resv $deps $reason
|
||||
}
|
||||
conflict-list
|
||||
}
|
||||
|
||||
# Check for conflicts
|
||||
|
||||
if {"$slot$end" in $conflicts} {
|
||||
set ok 0
|
||||
log "+++ Confict exists +++ $deps" 1
|
||||
#set others [$record othertimes]
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start" debug 1]
|
||||
set other [findAlternate $resv $others $start $def 0]
|
||||
if {$other != ""} {
|
||||
set ostart [$other get start]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
|
||||
# attempt to schedule the alternate
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $other $epsd "$deps--->$dother" "Confict resolution"
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
if {[schedule $other $dother "Confict resolution"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
cancel $resv $deps "Conflict resolution"
|
||||
} else {
|
||||
# skip conflicted epidode
|
||||
skip $resv $svc $event_id $deps "Conflict resolution"
|
||||
}
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
chkEpisode $resv $epsd $ecrid
|
||||
if {$start < $now} { break }
|
||||
}
|
||||
|
||||
} else {
|
||||
log "+++ No episodes scheduled +++ $dresv" 1
|
||||
log "+++ No episodes scheduled in aulEventToRecordInfo +++ $dresv" 1
|
||||
# use the event info in the main part of the reservation
|
||||
if {![$resv isseries]} {
|
||||
chkEpisode $resv [list [$resv get hsvc] $s $e [$resv get usevtid]] [$resv get szCRID]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log "Completed - $dresv" 2
|
||||
# check for new series in same time slot
|
||||
log "Completed - $dresv" 2
|
||||
}
|
||||
|
||||
# check for new series in same time slot
|
||||
if {[$resv isseries]} {
|
||||
scrid_chg $resv $dresv $lasttime
|
||||
}
|
||||
}
|
||||
if {[llength $conflicts] > 1} {
|
||||
log "++++ [llength $conflicts] Unresolved conflicts remain +++" 0
|
||||
log "++++ [llength $conflicts] Unresolved conflicts remain +++" 1
|
||||
}
|
||||
log "===============================================" 2
|
||||
epg cleanup
|
||||
}
|
||||
|
||||
#
|
||||
# check each episode for changes and conflicts
|
||||
#
|
||||
proc chkEpisode {resv epsd ecrid} {
|
||||
global svcmap conflicts svcdef now thresh slot name def
|
||||
lassign $epsd service_id start end event_id
|
||||
set epgcrid [string range $ecrid [string first "/" $ecrid] end]
|
||||
set ecrid [string range $ecrid 1 end]
|
||||
set dur $($end-$start)
|
||||
set deps "[clock format $start -format {%d/%m/%y %H:%M}] [clock format $dur -format {%H:%M}] === slot $slot === $name === [$resv channel_name]"
|
||||
|
||||
|
||||
if {$start < $now} {
|
||||
#
|
||||
# Should be recording now, check if it is
|
||||
#
|
||||
log "Already started? Status = [$resv status ] - $deps" 1
|
||||
if {$::opts(nonotrec)} {
|
||||
log "-noNotRec - Not checking for failed recording" 2
|
||||
return
|
||||
}
|
||||
# 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?22
|
||||
puts [system nugget recordings]
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
set svc $svcmap($service_id)
|
||||
# Retrieve epg record for the episode
|
||||
set record [lindex [\
|
||||
epg dbfetch dump -service $svc -event $event_id -sort ""] 0]
|
||||
log "$service_id $start $end $svc $event_id $record $ecrid $epgcrid" 3
|
||||
|
||||
if {$record==""} {
|
||||
#
|
||||
# No epg rcord found for the episode - find alternate showing
|
||||
#
|
||||
log "+++ No matching epg entry ++++ $deps" 1
|
||||
if {$::opts(nomissepg)} {
|
||||
log "-noMissEPG - Not checking for alternate" 2
|
||||
return
|
||||
}
|
||||
|
||||
# look for an alternate showing
|
||||
set others [epg dbfetch dump -crid $epgcrid -sort "start" ]
|
||||
if {$others == {}} {
|
||||
# No luck by crid, try for same name/time/channel
|
||||
set others [epg dbfetch dump -term $name -service $svc -time "$(($start+$end)/2)" -sort "start" -debug 1 ]
|
||||
}
|
||||
#puts $others
|
||||
set other [findAlternate $resv $others $start $def 1]
|
||||
if {$other != ""} {
|
||||
set ostart [$other get start]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
# attempt to schedule the alternate (inplace)
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $other $epsd "$deps--->$dother" "Event Changed"
|
||||
conflict-list
|
||||
return
|
||||
}
|
||||
# attempt to schedule the alternate (new even+skip)
|
||||
if {[schedule $other $dother "Event Changed"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
cancel $resv $deps "Event Changed"
|
||||
} else {
|
||||
# move crid from scheduled to recorded
|
||||
replaceskip $resv $ecrid $deps "Event Changed"
|
||||
#refresh $resv $deps
|
||||
}
|
||||
conflict-list
|
||||
return
|
||||
}
|
||||
} else {
|
||||
# is it a duplicate entry for the sametime and channel?
|
||||
foreach aul [$resv aul] {
|
||||
if {$epsd == $aul} {continue}
|
||||
lassign $aul aservice_id astart aend aevent_id
|
||||
if {$service_id == $aservice_id
|
||||
&& $start == $aevent_id} {
|
||||
update_event $resv 0 $epsd "$deps" "Duplicate Event"
|
||||
conflict-list
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
#
|
||||
# Epg entry for the episode found
|
||||
#
|
||||
|
||||
# Check that details match
|
||||
|
||||
set epgname [$record get name]
|
||||
set def $svcdef([$record get channel_hsvc])
|
||||
set deps "[clock format $start -format {%d/%m/%y %H:%M}] [clock format $dur -format {%H:%M}] === slot $slot === $epgname === [$record get channel_name]"
|
||||
|
||||
log "Episode $deps" 2
|
||||
set ok 1
|
||||
set reason "no reason"
|
||||
if {$start != [$record get start]} {
|
||||
set ok 0
|
||||
set reason "Start Mismatch: $start != [$record get start"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
if {$dur != [$record get duration]} {
|
||||
set ok 0
|
||||
set reason "Duration Mismatch: $dur != [$record get duration]"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
set evt_crid [string toupper [$record get event_crid]]
|
||||
if {$epgcrid != $evt_crid
|
||||
&& $epgcrid != ""} {
|
||||
set ok 0
|
||||
set reason "Crid Mismatch: $epgcrid != $evt_crid"
|
||||
log "+++ $reason +++ $deps" 1
|
||||
}
|
||||
if {!$ok && !$::opts(noepgchg)} {
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $record $epsd "$deps" $reason
|
||||
} else {
|
||||
refresh $resv $deps $reason
|
||||
}
|
||||
conflict-list
|
||||
}
|
||||
|
||||
# Check for conflicts ($condlicts is null if checking supressed)
|
||||
|
||||
if {"$slot$end" in $conflicts} {
|
||||
set ok 0
|
||||
log "+++ Confict exists +++ $deps" 1
|
||||
#set others [$record othertimes]
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start"]
|
||||
set other [findAlternate $resv $others $start $def 0]
|
||||
if {$other != ""} {
|
||||
set ostart [$other get start]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
|
||||
# attempt to schedule the alternate
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $other $epsd "$deps--->$dother" "Confict resolution"
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
if {[schedule $other $dother "Confict resolution"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
cancel $resv $deps "Conflict resolution"
|
||||
} else {
|
||||
# skip conflicted epidode
|
||||
skip $resv $svc $event_id $deps "Conflict resolution"
|
||||
}
|
||||
conflict-list
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Scan others for a suitable alternate episode
|
||||
proc findAlternate {resv others start definition sametime} {
|
||||
# look for alternate with same definition HD/SD/radio
|
||||
|
@ -421,9 +510,154 @@ proc scanAlternates {resv others start definition sametime samedef} {
|
|||
return ""
|
||||
}
|
||||
|
||||
# Check for prossible changes to series CRID
|
||||
# Unscheduled series at same time/channel as an existing ulSeries
|
||||
# Also one-off programmes matching series name
|
||||
proc scrid_chg {resv desc lasttime} {
|
||||
global thresh svcmap now
|
||||
set name [$resv name]
|
||||
set fudge 60
|
||||
if {$::opts(noscrid)
|
||||
&& $::opts(no1off) } {
|
||||
log "-noSCRID/-no1off - Not checking for SCRID change/ one-off recordings" 2
|
||||
return
|
||||
}
|
||||
set scrid [$resv get szCRID]
|
||||
set svc $svcmap([$resv get hsvc])
|
||||
set start [$resv start]
|
||||
set timeslot [clock format $start -format "%H:%M"]
|
||||
|
||||
set others [epg dbfetch dump -service $svc -term $name -after $lasttime -before $thresh -sort "start"]
|
||||
foreach other $others {
|
||||
|
||||
set ostart [$other get start]
|
||||
set ostarttime [clock format $ostart -format "%H:%M"]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set oscrid [$other get series_crid]
|
||||
set oecrid [$other get event_crid]
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
|
||||
if {$oscrid !=""} {
|
||||
# Event is part of a series, check start time matches
|
||||
if {$ostarttime == $timeslot} {
|
||||
if {$::opts(noscrid)} {
|
||||
log "-noSCRID - Not applying SCRID change" 2
|
||||
continue
|
||||
}
|
||||
if {[string first [string toupper $oscrid] $scrid] >= 0} {
|
||||
# found episode of current series - shouldn't happen
|
||||
continue
|
||||
}
|
||||
if {[$other scheduled]} {
|
||||
continue
|
||||
}
|
||||
set oconflicts [rsv checkconflict \
|
||||
$ostart $odur \
|
||||
[system tuners]]
|
||||
set cl [llength $oconflicts]
|
||||
if {$cl >= [system tuners]} {
|
||||
log "Alternate conflicts $oconflicts" 2
|
||||
continue
|
||||
}
|
||||
log "Found new series matching $name - $dother - $oscrid" 1
|
||||
|
||||
# szCrid not currently updated by rsvsync so cant update inplace
|
||||
if {false && !$::opts(noinplace)} {
|
||||
$resv set szCRID [string toupper "[$other get channel_crid]$oscrid"]
|
||||
puts [$resv get szCRID]
|
||||
set aul1 [lindex [$resv aul] 0]
|
||||
# only remove 1st AUL entry if it is for an expired event
|
||||
lassign $aul1 service_id start end event_id
|
||||
if {$end > $now} {set aul1 {}}
|
||||
update_event $resv $other $aul1 "$desc-->$dother" "sCRID changed"
|
||||
} else {
|
||||
schedule $other "$dother" "sCRID changed" 2
|
||||
# only schedule 1st episode, allow humax to add others
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Single event, but matches series name
|
||||
if {$::opts(no1off) } {
|
||||
log "-no1off - Not scheduling one-off recordings" 2
|
||||
continue
|
||||
}
|
||||
if {[$other scheduled]} {
|
||||
continue
|
||||
}
|
||||
|
||||
set oconflicts [rsv checkconflict \
|
||||
$ostart $odur \
|
||||
[system tuners]]
|
||||
set cl [llength $oconflicts]
|
||||
if {$cl >= [system tuners]} {
|
||||
log "Alternate conflicts $oconflicts" 2
|
||||
continue
|
||||
}
|
||||
log "Found 1-off matching $name - $dother" 1
|
||||
|
||||
if {!$::opts(noinplace)} {
|
||||
update_event $resv $other {} "$desc-->$dother" "1-off recording"
|
||||
} else {
|
||||
schedule $other "$desc-->$dother" "1-off recording" 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check for missing episoder of a series CRID
|
||||
proc miss_epsd {resv desc} {
|
||||
if {$::opts(nounsched) } {
|
||||
log "-noUnsched - Not checking for missing episodes" 2
|
||||
return
|
||||
}
|
||||
global thresh svcmap now
|
||||
set name [$resv name]
|
||||
|
||||
set svc $svcmap([$resv get hsvc])
|
||||
set start [$resv start]
|
||||
set timeslot [clock format $start -format "%H:%M"]
|
||||
set ecrid [$resv get szCRID]
|
||||
set scrid [string range $ecrid [string first "/" $ecrid] end]
|
||||
|
||||
set others [epg dbfetch dump -after $now -before $thresh -scrid $scrid -nocase 1 -sort "start"]
|
||||
foreach other $others {
|
||||
set ostart [$other get start]
|
||||
set odur [$other get duration]
|
||||
set oend $($ostart+$odur)
|
||||
set oname [$other get name]
|
||||
set ocname [$other get channel_name]
|
||||
set ocrid [string toupper [$other get event_crid]]
|
||||
|
||||
set dother "[clock format $ostart -format {%d/%m/%y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
|
||||
if {[string first $ocrid [$resv get szEventToRecord]] >= 0} {
|
||||
log "Already scheduled episode $desc-->$dother" 2
|
||||
continue
|
||||
}
|
||||
if {[string first $ocrid [$resv get szRecordedProgCrid]] >= 0} {
|
||||
log "Already recorded/skipped episode $desc-->$dother" 2
|
||||
continue
|
||||
}
|
||||
set skiplist [$resv skiplist]
|
||||
set ohsvc [$other get channel_hsvc]
|
||||
set oevtid [$other get event_id]
|
||||
log "svc $ohsvc evt $oevtid crid $ocrid Skiplist $skiplist" 3
|
||||
if {[string first "$ohsvc:$oevtid" $skiplist] >= 0} {
|
||||
log "Already skipped episode $desc-->$dother" 2
|
||||
continue
|
||||
}
|
||||
log "Found Unscheduled episode $ocrid $desc-->$dother" 1
|
||||
update_event $resv $other {} "$desc-->$dother" "Unscheduled episode"
|
||||
}
|
||||
}
|
||||
|
||||
# Create a new reservation
|
||||
proc schedule {resv desc {reason ""} {type 1} } {
|
||||
if {[$resv scheduled]} {
|
||||
proc schedule {event desc {reason ""} {type 1} } {
|
||||
if {[$event scheduled]} {
|
||||
log "*** Already scheduled *** $desc === $reason" 0
|
||||
return 1
|
||||
}
|
||||
|
@ -431,8 +665,7 @@ proc schedule {resv desc {reason ""} {type 1} } {
|
|||
log "*** Test mode =scheduled *** $desc === $reason" 0
|
||||
return 1
|
||||
}
|
||||
set type 1
|
||||
set r [rsv construct $resv $type]
|
||||
set r [rsv construct $event $type]
|
||||
if {[catch {$r insert pending} msg]} {
|
||||
log "+++ Error while scheduling: $msg ++++ $desc === $reason" 0
|
||||
return 0
|
||||
|
@ -536,16 +769,21 @@ proc update_event {resv other origaul desc {reason ""}} {
|
|||
}
|
||||
set curauls [$resv aul]
|
||||
set ecrids [split [$resv get szEventToRecord] "|"]
|
||||
set hsvc [$other get channel_hsvc]
|
||||
set start [$other get start]
|
||||
set end [$other end]
|
||||
set evtid [$other get event_id]
|
||||
set othaul [list $hsvc $start $end $evtid]
|
||||
set othcrid [string toupper "1[$other get channel_crid][$other get event_crid]"]
|
||||
set othaul {}
|
||||
set insert 1
|
||||
set start 0
|
||||
if {$other != 0 && $other !={}} {
|
||||
set hsvc [$other get channel_hsvc]
|
||||
set start [$other get start]
|
||||
set end [$other end]
|
||||
set evtid [$other get event_id]
|
||||
set othaul [list $hsvc $start $end $evtid]
|
||||
set othcrid [string toupper "1[$other get channel_crid][$other get event_crid]"]
|
||||
set insert 0
|
||||
}
|
||||
set newaul {}
|
||||
set newevnts ""
|
||||
log "$origaul-- $othaul -- $curauls $ecrids " 3
|
||||
set insert 0
|
||||
|
||||
# rebuild aul and events list with new event in correct order
|
||||
lmap aul $curauls ecrid $ecrids {
|
||||
|
@ -644,6 +882,7 @@ switch -- $opt {
|
|||
lassign $optl desc key default helptxt
|
||||
puts [format "-%-11s %-4s = %s" $key $default $helptxt]
|
||||
}
|
||||
puts "/nNote: Options are not case sensitive"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue