forked from hummypkg/webif
Add support for persistent episode skips
This commit is contained in:
parent
45d1cdd2d1
commit
f28a048bd9
@ -1,10 +1,10 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 1.4.1-6
|
||||
Version: 1.4.2
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hpkg.tv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.25),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.6),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.10),webif-charts(>=1.2-1),stripts(>=1.2.5-3),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.95),sqlite3(>=3.15.1),jim-xconv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.25),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.6),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.11),webif-charts(>=1.2-1),stripts(>=1.2.5-3),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.95),sqlite3(>=3.15.1),jim-xconv
|
||||
Suggests:
|
||||
Description: An evolving web interface for the Humax.
|
||||
Tags: https://hummy.tv/forum/threads/7712/
|
||||
|
@ -12,34 +12,19 @@ set xevent [cgi_get event 0]
|
||||
|
||||
if {$slots eq "-"} exit
|
||||
|
||||
set done 0
|
||||
foreach slot [split $slots ","] {
|
||||
puts "SLOT: $slot"
|
||||
set event [rsv slot $slot]
|
||||
|
||||
lassign [epg dbfetch dump -service $xservice -event $xevent] epg
|
||||
|
||||
if {$epg eq ""} {
|
||||
puts "!Cannot find event in EPG."
|
||||
if {[catch {
|
||||
$event apply_skip $xservice $xevent
|
||||
} msg]} {
|
||||
puts "!$msg"
|
||||
break
|
||||
}
|
||||
$epg get_channel_info
|
||||
|
||||
# First check to see if there is already a pending skip for this
|
||||
# event and, if so, update that one.
|
||||
set crid "[$epg get channel_crid][$epg get series_crid]"
|
||||
set ev [rsv fetch pending [$event get ersvtype] \
|
||||
[$event get hsvc] 0 [$event get usevtid] $crid]
|
||||
if {$ev eq "0"} {
|
||||
# No pending event
|
||||
puts "No pending event."
|
||||
set ev $event
|
||||
$ev clear_ulslot
|
||||
}
|
||||
|
||||
puts "Set skip $xevent"
|
||||
$ev set_skip $epg
|
||||
$ev insert
|
||||
incr done
|
||||
system restartpending
|
||||
}
|
||||
|
||||
system restartpending
|
||||
if {$done} { rsv commit }
|
||||
|
||||
|
@ -9,6 +9,7 @@ Priorities (* - additional package)
|
||||
Module Scan De-queue
|
||||
------ ---- --------
|
||||
*newk 1000 -
|
||||
skip 990 -
|
||||
expire 900 -
|
||||
dedup 800 -
|
||||
*sweeper 700 -
|
||||
|
9
webif/lib/auto/plugin/skip/auto.hook
Normal file
9
webif/lib/auto/plugin/skip/auto.hook
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
require rsv.class
|
||||
|
||||
proc ::skip::run {args} {
|
||||
rsv reassert_skips
|
||||
}
|
||||
|
||||
::auto::register skip 990
|
||||
|
@ -72,6 +72,27 @@ proc {rsv dbhandle} {args} {
|
||||
$::rsv::db query {attach database '/var/lib/humaxtv/rsvp.db' as pending}
|
||||
# These are required to upgrade old tables.
|
||||
catch { $::rsv::db query { alter table pending add column action int} }
|
||||
# Add the skip table if missing
|
||||
catch { $::rsv::db query {
|
||||
create table if not exists pending.skip
|
||||
(
|
||||
ulslot int,
|
||||
state text,
|
||||
service_id int,
|
||||
event_id int,
|
||||
start int,
|
||||
ucCRIDType int,
|
||||
szCRID text,
|
||||
szSkipCRID text
|
||||
);
|
||||
}}
|
||||
catch { $::rsv::db query {
|
||||
create unique index pending.skipidx
|
||||
on skip(
|
||||
ulslot, state, service_id, event_id,
|
||||
ucCRIDType, szCRID, szSkipCRID
|
||||
);
|
||||
} }
|
||||
|
||||
return $::rsv::db
|
||||
}
|
||||
@ -301,18 +322,35 @@ rsv method set_refresh {} {
|
||||
set aulEventToRecordInfo ""
|
||||
}
|
||||
|
||||
rsv method set_skip {event} {
|
||||
rsv method set_skip {event {persist true}} {
|
||||
set action 5
|
||||
|
||||
$event get_channel_info
|
||||
|
||||
set crid "[$event get channel_crid][$event get event_crid]"
|
||||
set szRecordedProgCrid "1$crid|$szRecordedProgCrid"
|
||||
set szEventToRecord [string map "1$crid| {}" $szEventToRecord]
|
||||
|
||||
set event_hsvc [$event get channel_hsvc]
|
||||
set service_id [$event get service_id]
|
||||
set event_id [$event get event_id]
|
||||
|
||||
set crid [string toupper \
|
||||
"[$event get channel_crid][$event get event_crid]"]
|
||||
|
||||
if {"1$crid" ni [split $szRecordedProgCrid "|"]} {
|
||||
set szRecordedProgCrid "1$crid|$szRecordedProgCrid"
|
||||
}
|
||||
set szEventToRecord [string map "1$crid| {}" $szEventToRecord]
|
||||
if {$persist} {
|
||||
catch {
|
||||
[rsv dbhandle] query {
|
||||
insert or ignore into skip
|
||||
(ulslot, state, ucCRIDType, szCRID, szSkipCRID,
|
||||
service_id, event_id, start)
|
||||
values('%s', 'pending', '%s', '%s', '%s', %s, %s,
|
||||
%s)
|
||||
} -1 $ucCRIDType $szCRID $crid $service_id $event_id [\
|
||||
$event get start]
|
||||
}
|
||||
}
|
||||
|
||||
set newaul ""
|
||||
set next_event -1
|
||||
foreach aul [$self aul] {
|
||||
@ -349,6 +387,32 @@ rsv method set_skip {event} {
|
||||
}
|
||||
}
|
||||
|
||||
rsv method apply_skip {service event {persist true}} {
|
||||
require epg.class
|
||||
lassign [epg dbfetch dump -service $service -event $event] epg
|
||||
|
||||
if {$epg eq ""} {
|
||||
error "Cannot find event in EPG."
|
||||
}
|
||||
$epg get_channel_info
|
||||
|
||||
# First check to see if there is already a pending skip for this
|
||||
# event and, if so, update that one.
|
||||
set crid [string toupper \
|
||||
"[$epg get channel_crid][$epg get series_crid]"]
|
||||
set table pending
|
||||
set ev [rsv fetch $table $ersvtype $hsvc 0 $usevtid $crid]
|
||||
if {$ev == 0} {
|
||||
set table TBL_RESERVATION
|
||||
set ev $self
|
||||
$ev clear_ulslot
|
||||
}
|
||||
$ev set_skip $epg $persist
|
||||
if {[catch {$ev insert_deferred} msg]} {
|
||||
error "Error during insert."
|
||||
}
|
||||
}
|
||||
|
||||
rsv method remove_pending {} {
|
||||
[rsv dbhandle] query "delete from pending where ulslot = $ulslot"
|
||||
}
|
||||
@ -606,7 +670,7 @@ proc {rsv fetch} {table ersvtype hsvc nsttime usevtid {crid ""} {extra ""}} {
|
||||
lappend params $nsttime
|
||||
}
|
||||
if {$crid ne ""} {
|
||||
append q " and szCRID = '%s' "
|
||||
append q " and szCRID = '%s' collate nocase "
|
||||
lappend params $crid
|
||||
}
|
||||
if {$extra ne ""} {
|
||||
@ -1251,3 +1315,56 @@ proc {rsv checkconflict} {s d thresh {debug 0}} {
|
||||
return $ret
|
||||
}
|
||||
|
||||
proc {rsv clearskip} {slot} {
|
||||
catch {
|
||||
[rsv dbhandle] query {delete from skip where ulslot = %s} $slot
|
||||
}
|
||||
}
|
||||
|
||||
proc {rsv reassert_skips} {} {
|
||||
set rsvdb [rsv dbhandle]
|
||||
|
||||
set changes 0
|
||||
set now [clock seconds]
|
||||
foreach s [$rsvdb query {
|
||||
select * from skip
|
||||
where state = 'live' and ulslot >= 0
|
||||
and start > %s and start < %s
|
||||
order by ulslot, service_id, event_id
|
||||
} $now $($now + 86400)] {
|
||||
if {![dict exists $s ulslot]} continue
|
||||
set r [rsv slot $s(ulslot)]
|
||||
if {$r eq "0"} {
|
||||
# Slot no longer exists.
|
||||
rsv clearskip $s(ulslot)
|
||||
continue
|
||||
}
|
||||
if {[$r get szCRID] ne $s(szCRID)} {
|
||||
# Slot is now for a different recording.
|
||||
rsv clearskip $s(ulslot)
|
||||
continue
|
||||
}
|
||||
|
||||
#puts "S: $s"
|
||||
#require classdump; classdump $r
|
||||
|
||||
if {"1$s(szSkipCRID)" in [\
|
||||
split [$r get szRecordedProgCrid] "|"]} {
|
||||
puts "Skip already in place."
|
||||
continue
|
||||
}
|
||||
# Need to re-assert skip.
|
||||
if {[catch {$r apply_skip $s(service_id) $s(event_id) false} \
|
||||
msg]} {
|
||||
puts $msg
|
||||
} else {
|
||||
puts "Re-applied skip."
|
||||
incr changes
|
||||
}
|
||||
}
|
||||
if {$changes} {
|
||||
puts "Commit."
|
||||
rsv commit
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user