Add svc.class

This commit is contained in:
HummyPkg 2020-04-04 22:54:49 +01:00
parent 7b53d0b549
commit a3cb0a6693
7 changed files with 140 additions and 99 deletions

View File

@ -2,7 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require system.class findhsvc epg.class rsv.class plugin
require system.class epg.class rsv.class svc.class plugin
set runmode cli
if {[string match {*jim} $argv0]} { set runmode cgi }

View File

@ -2,13 +2,18 @@
package require cgi
source /mod/webif/lib/setup
require epg.class spinner.class altrow findhsvc
require epg.class spinner.class altrow svc.class
jqplugin iphone-style-checkboxes freezeheader scrollto
jscss service.js service.css
set service [cgi_get service 4170]
set chname [system strip [get_channel_attr_bysvc $service szSvcName]]
set c [svc load usSvcId $service]
if {$c == 0} {
puts "No such channel."
exit
}
set chname [$c get szSvcName]
setpagetag "EPG - $chname"
header

View File

@ -3,7 +3,7 @@
package require cgi
source /mod/webif/lib/setup
require rsv.class findhsvc
require rsv.class svc.class
set dir /mod/var/backup

View File

@ -3,7 +3,7 @@ source /mod/webif/lib/setup
if {![exists -proc class]} { package require oo }
if {![exists -proc sqlite3.open]} { package require sqlite3 }
require settings.class progressbar rsv.class mwildcard
require settings.class progressbar rsv.class mwildcard svc.class
set ::epgpath /mnt/hd1/dvbepg/epg.dat
set ::epgdbpath /mnt/hd1/epg.db
@ -62,6 +62,7 @@ class epg {
series_crid ""
rec_crid ""
channel 0
channel_num 0
channel_name ""
channel_crid ""
@ -153,24 +154,19 @@ epg method channel_icon {{width 0} {style ""}} {
}
epg method get_channel_info {} {
global channeldb
if {$channel_num > 0} return
if {!$channel_num && $channeldb != ""} {
set chan [lindex [$channeldb query {
select szSvcName, usLcn, aucDefaultAuthority, hsvc
from TBL_SVC
where usSvcId = '%s'} $service_id
] 0]
if {[dict exists $chan usLcn]} {
set channel_num $chan(usLcn)
set channel_name [string range $chan(szSvcName) 1 end]
set channel_crid [string toupper $chan(aucDefaultAuthority)]
set channel_hsvc $chan(hSvc)
}
set channel [svc load usSvcId $service_id]
if {$channel != 0} {
set channel_num [$channel get usLcn]
set channel_name [$channel get szSvcName]
set channel_crid [$channel get aucDefaultAuthority]
set channel_hsvc [$channel get hSvc]
}
}
epg method copy_channel_info {s} {
set channel [$s get channel]
set channel_num [$s get channel_num]
set channel_name [$s get channel_name]
set channel_crid [$s get channel_crid]
@ -178,14 +174,14 @@ epg method copy_channel_info {s} {
}
epg method get_rsv {} {
if {$hsvc == 0} { $self get_channel_info }
if {$hsvc == 0} { return }
$self get_channel_info
if {$channel == 0} return
if {$rsv == 0 && $event_crid ne ""} {
set rsv [rsv entry $event_crid $hsvc]
set rsv [rsv entry $event_crid $channel_hsvc]
}
if {$rsv == 0 && $series_crid ne ""} {
set rsv [rsv entry $series_crid $hsvc]
set rsv [rsv entry $series_crid $channel_hsvc]
}
}

View File

@ -1,77 +1,35 @@
if {![exists -proc get_channel_attr]} {
if {![exists -proc rsv]} { require rsv.class }
if {![exists -proc svc]} { require svc.class }
proc get_channel_attr {channel {field hSvc}} {
set ff [[rsv dbhandle] query "
select $field
from channel.TBL_SVC
where szSvcName = '$channel'
or szSvcname = '\025$channel'
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return ""
set c [svc channel $channel]
if {$c == 0} { return "" }
return [$c get $field]
}
proc get_channel_attr_bylcn {lcn {field hSvc}} {
set ff [[rsv dbhandle] query "
select $field
from channel.TBL_SVC
where usLcn = $lcn
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return 0
set c [svc load usLcn $lcn]
if {$c == 0} { return "" }
return [$c get $field]
}
proc get_channel_attr_byorglcn {lcn {field hSvc}} {
set ff [[rsv dbhandle] query "
select $field
from channel.TBL_SVC
where usOrgLcn = $lcn
and usLcn < 800
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return 0
set c [svc _load_clause "usOrgLcn = $lcn and usLcn < 800" $lcn]
if {$c == 0} { return "" }
return [$c get $field]
}
proc get_channel_attr_byhsvc {hsvc {field usLcn}} {
set ff [[rsv dbhandle] query "
select $field
from channel.TBL_SVC
where hSvc = $hsvc
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return 0
set c [svc load hSvc $hsvc]
if {$c == 0} { return "" }
return [$c get $field]
}
proc get_channel_attr_bysvc {svc {field usLcn}} {
set ff [[rsv dbhandle] query "
select $field
from channel.TBL_SVC
where usSvcId = $svc
limit 1
"]
if {[llength $ff] == 1} {
return [lindex [lindex $ff 0] 1]
}
return 0
set c [svc load usSvcId $svc]
if {$c == 0} { return "" }
return [$c get $field]
}
}

View File

@ -3,7 +3,7 @@ source /mod/webif/lib/setup
if {![exists -proc class]} { package require oo }
if {![exists -proc sqlite3.open]} { package require sqlite3 }
if {![exists -proc binary]} { package require binary }
require settings.class system.class plugin findhsvc
require settings.class system.class plugin svc.class
set binaryfields aulEventToRecordInfo
@ -497,19 +497,17 @@ rsv method remove_pending {} {
}
rsv method fix_hsvc {} {
set _hsvc [get_channel_attr $szSvcName]
if {$_hsvc eq ""} {
set _hsvc [get_channel_attr_bylcn $usLcn]
}
set hsvc $_hsvc
set c [svc channel $szSvcName]
if {$c == 0} { set c [svc load usLcn $usLcn] }
if {$c == 0} return
set hsvc [$c get hSvc]
}
proc {rsv find_hsvc} {lcn channel} {
set _hsvc [get_channel_attr $channel]
if {$_hsvc eq ""} {
set _hsvc [get_channel_attr_bylcn $lcn]
}
return $_hsvc
set c [svc channel $szSvcName]
if {$c == 0} { set c [svc load usLcn $usLcn] }
if {$c == 0} { return 0 }
return [$c get hSvc]
}
rsv method cleanvars {} {
@ -876,8 +874,6 @@ proc {rsv construct} {event type} {
}
proc {rsv manual} {start end lcn type repeat {title ""}} {
require findhsvc
set args {}
set args(ersvtype) $type
@ -887,11 +883,11 @@ proc {rsv manual} {start end lcn type repeat {title ""}} {
-format {%Y%m%d%H%M%S}]
set args(nduration) $($end - $start)
set args(hsvc) [get_channel_attr_bylcn $lcn]
set c [svc load usLcn $lcn]
set args(hsvc) [$c get hSvc]
if {$title eq ""} {
set title [system strip [\
get_channel_attr_bylcn $lcn szSvcName]]
set title [$c get szSvcName]
}
set args(szevtname) $title
@ -1175,8 +1171,13 @@ proc {rsv restore} {file} {
puts " Restoring skip for $chan - $szSkipCRID"
# Fetch new hSvc and service_id
set _hsvc [get_channel_attr $chan]
set _service_id [get_channel_attr $chan usSvcId]
set c [svc channel $chan]
if {$c == 0} {
puts " Cannot find channel"
continue
}
set _hsvc [$c get hSvc]
set _service_id [$c get usSvcId]
if {$_hsvc eq "" || $_service_id eq ""} {
puts " Cannot map channel name to service."
continue
@ -1256,7 +1257,12 @@ proc {rsv restore} {file} {
puts " $chan"
set hsvc [get_channel_attr $chan]
set c [$svc channel $chan]
if {$c == 0} {
puts " Cannot map channel name to service."
continue
}
set hsvc [$c get hSvc]
if {$hsvc eq ""} {
puts " Cannot map channel name to service."
continue

76
webif/lib/svc.class Executable file
View File

@ -0,0 +1,76 @@
source /mod/webif/lib/setup
if {![exists -proc class]} { package require oo }
if {![exists -proc sqlite3.open]} { package require sqlite3 }
require system.class
class svc {
hSvc -1
usSvcId 0
szSvcName {}
aucDefaultAuthority {}
usLcn 0
eVideoType 0
eSystem 0
}
proc {svc dbhandle} {args} {
if {"-close" in $args} {
if {[info exists ::svc::db]} {
catch {$::svc::db close}
unset ::svc::db
return 1
}
return 0
}
if {[info exists ::svc::db]} {
return $::svc::db
}
set ::svc::db [sqlite3.open /var/lib/humaxtv/channel.db]
return $::svc::db
}
alias {svc cleanup} svc dbhandle -close
proc {svc _import} {data} {
set data(szSvcName) [system strip $data(szSvcName)]
return [svc new $data]
}
proc {svc _load_clause} {clause vals} {
set res [[svc dbhandle] query "
select szSvcName, usLcn, usSvcId, eVideoType,
TBL_SVC.aucDefaultAuthority as aucDefaultAuthority,
hSvc, eSystem
from TBL_SVC join TBL_TS using (tsIdx)
where $clause
limit 1
" {*}$vals]
if {[llength $res] > 0} {
return [svc _import [lindex $res 0]]
}
return 0
}
proc {svc load} {field val} {
return [svc _load_clause "TBL_SVC.%s = %s" [list $field $val]]
}
proc {svc channel} {channel} {
return [svc _load_clause "szSvcName = '%s'
or szSvcname = '\025%s'" [list $channel $channel]]
}
proc {svc hsvc} {hsvc} {
return [svc _load_clause "hSvc = %s" [list $hsvc]]
}
svc method definition {} {
if {$eVideoType == 2} { return "HD" }
return "SD"
}