forked from hummypkg/webif
new db based EPG
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@433 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
93f1b67ba1
commit
2fb26975e2
@ -1,4 +0,0 @@
|
||||
<!--#include virtual="/lib/header.shtml" -->
|
||||
<!--#exec cmd="/mod/var/mongoose/include/fepg.jim" -->
|
||||
<!--#include virtual="/lib/footer.shtml" -->
|
||||
|
1
var/mongoose/html/img/channels/S4/C.png
Symbolic link
1
var/mongoose/html/img/channels/S4/C.png
Symbolic link
@ -0,0 +1 @@
|
||||
../S4C.png
|
@ -13,7 +13,14 @@ require epg.class spinner.class altrow epg_search totop
|
||||
require epg_popup
|
||||
|
||||
set start [clock milliseconds]
|
||||
set records [epg fetch dump -time [clock seconds]]
|
||||
set now [clock seconds]
|
||||
set then $($now + 7200)
|
||||
if {$::qepg} {
|
||||
set records [epg dbfetch dump -trange "$now:$then"]
|
||||
} else {
|
||||
require channelsort
|
||||
set records [channelsort [epg fetch dump -trange "$now:$then"]]
|
||||
}
|
||||
set got [clock milliseconds]
|
||||
|
||||
set favlist [epg favlist]
|
||||
@ -24,41 +31,37 @@ puts {
|
||||
<th colspan=3>Channel</th>
|
||||
<th>On Now</th>
|
||||
<th>On Next</th>
|
||||
<th>On Later</th>
|
||||
</tr>
|
||||
}
|
||||
|
||||
proc rsort {v1 v2} {
|
||||
set v1s [$v1 get channel_num]
|
||||
set v2s [$v2 get channel_num]
|
||||
|
||||
if {$v1s == $v2s} { return 0 }
|
||||
if {$v1s > $v2s } { return 1 }
|
||||
return -1
|
||||
}
|
||||
|
||||
set lcn 0
|
||||
set num 0
|
||||
foreach record $records {
|
||||
$record get_channel_info
|
||||
}
|
||||
|
||||
foreach record [lsort -command rsort $records] {
|
||||
if {$favlist != "" && [$record get service_id] ni $favlist} {
|
||||
continue
|
||||
}
|
||||
set num [$record get channel_num]
|
||||
if {$num == 0} { continue }
|
||||
altrow
|
||||
puts "<td>$num</td>"
|
||||
puts "<td>[$record channel_icon 50]</td>
|
||||
<td>
|
||||
set chnum [$record get channel_num]
|
||||
if {$chnum == 0} { continue }
|
||||
|
||||
if {$chnum != $lcn} {
|
||||
if {$lcn > 0} { puts "</tr>" }
|
||||
altrow
|
||||
puts "<td>$chnum</td>"
|
||||
puts "<td>[$record channel_icon 50]</td>
|
||||
<td>
|
||||
<a href=/cgi-bin/epg_service.jim?service=[$record get service_id]>
|
||||
[$record get channel_name]
|
||||
</a></td>"
|
||||
catch {
|
||||
puts [$record cell]
|
||||
puts [[$record next] cell]
|
||||
[$record get channel_name]
|
||||
</a></td>"
|
||||
set lcn $chnum
|
||||
set num 0
|
||||
}
|
||||
incr num
|
||||
if {$num < 4} {
|
||||
catch { puts [$record cell] }
|
||||
}
|
||||
puts "</tr>"
|
||||
}
|
||||
if {$lcn > 0} { puts "</tr>" }
|
||||
puts "</table>"
|
||||
|
||||
puts "
|
||||
|
@ -1,94 +0,0 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require epg.class spinner.class altrow epg_search totop
|
||||
|
||||
[spinner new {
|
||||
text "Loading Now/Next Information..."
|
||||
size "1.2em"
|
||||
style "margin: 1em;"
|
||||
}] start
|
||||
|
||||
require epg_popup
|
||||
|
||||
set start [clock milliseconds]
|
||||
set now [clock seconds]
|
||||
set then $($now + 7200)
|
||||
set records [epg fetch dump -trange "$now:$then"]
|
||||
set got [clock milliseconds]
|
||||
|
||||
set favlist [epg favlist]
|
||||
|
||||
puts {
|
||||
<table class=borders>
|
||||
<tr>
|
||||
<th colspan=3>Channel</th>
|
||||
<th>On Now</th>
|
||||
<th>On Next</th>
|
||||
</tr>
|
||||
}
|
||||
|
||||
proc rsort {v1 v2} {
|
||||
set v1s [$v1 get channel_num]
|
||||
set v2s [$v2 get channel_num]
|
||||
|
||||
if {$v1s > $v2s } { return 1 }
|
||||
if {$v1s == $v2s} {
|
||||
set v1t [$v1 get start]
|
||||
set v2t [$v2 get start]
|
||||
if {$v1t > $v2t} { return 1 }
|
||||
if {$v1t == $v2t} { return 0 }
|
||||
return -1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
foreach record $records {
|
||||
$record get_channel_info
|
||||
}
|
||||
|
||||
set lcn 0
|
||||
set num 0
|
||||
foreach record [lsort -command rsort $records] {
|
||||
if {$favlist != "" && [$record get service_id] ni $favlist} {
|
||||
continue
|
||||
}
|
||||
set chnum [$record get channel_num]
|
||||
if {$chnum == 0} { continue }
|
||||
|
||||
if {$chnum != $lcn} {
|
||||
if {$lcn > 0} { puts "</tr>" }
|
||||
altrow
|
||||
puts "<td>$chnum</td>"
|
||||
puts "<td>[$record channel_icon 50]</td>
|
||||
<td>
|
||||
<a href=/cgi-bin/epg_service.jim?service=[$record get service_id]>
|
||||
[$record get channel_name]
|
||||
</a></td>"
|
||||
set lcn $chnum
|
||||
set num 0
|
||||
}
|
||||
incr num
|
||||
if {$num < 4} {
|
||||
catch { puts [$record cell] }
|
||||
}
|
||||
}
|
||||
if {$lcn > 0} { puts "</tr>" }
|
||||
puts "</table>"
|
||||
|
||||
puts "
|
||||
<a href=/cgi-bin/settings.jim>
|
||||
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
|
||||
Visit settings to change EPG options.
|
||||
</a><br>
|
||||
"
|
||||
|
||||
set end [clock milliseconds]
|
||||
puts "<font class=footnote>
|
||||
Retrieved in: [expr [expr $got - $start] / 1000.0] seconds.
|
||||
Rendered in: [expr [expr $end - $start] / 1000.0] seconds.
|
||||
</font>"
|
||||
|
||||
epg cleanup
|
||||
|
@ -20,30 +20,16 @@ set stt [clock seconds]
|
||||
set stt [expr int($stt / 1800) * 1800]
|
||||
|
||||
set ett $($stt + 14400)
|
||||
set records [epg fetch dump -trange "$stt:$ett"]
|
||||
if {$::qepg} {
|
||||
set records [epg dbfetch dump -trange "$stt:$ett"]
|
||||
} else {
|
||||
require channelsort
|
||||
set records [channelsort [epg fetch dump -trange "$stt:$ett"]]
|
||||
}
|
||||
set got [clock milliseconds]
|
||||
|
||||
set favlist [epg favlist]
|
||||
|
||||
proc rsort {v1 v2} {
|
||||
set v1s [$v1 get channel_num]
|
||||
set v2s [$v2 get channel_num]
|
||||
|
||||
if {$v1s > $v2s } { return 1 }
|
||||
if {$v1s == $v2s} {
|
||||
set v1t [$v1 get start]
|
||||
set v2t [$v2 get start]
|
||||
if {$v1t > $v2t} { return 1 }
|
||||
if {$v1t == $v2t} { return 0 }
|
||||
return -1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
foreach record $records {
|
||||
$record get_channel_info
|
||||
}
|
||||
|
||||
puts {
|
||||
<table class=epggrid style="float: left; clear: both">
|
||||
<tr>
|
||||
@ -67,7 +53,7 @@ puts "</tr>"
|
||||
|
||||
set lcn 0
|
||||
set bg "odd"
|
||||
foreach record [lsort -command rsort $records] {
|
||||
foreach record $records {
|
||||
if {$favlist != "" && [$record get service_id] ni $favlist} {
|
||||
continue
|
||||
}
|
||||
@ -143,13 +129,13 @@ puts {
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#epgswitch').button().click(function() {
|
||||
window.location = '/epg.html';
|
||||
window.location = '/epg.shtml';
|
||||
});
|
||||
$('#earlier').button().click(function() {
|
||||
window.location = '/xepg.html?stt=<?php echo $stt - 3600*4; ?>';
|
||||
window.location = '/xepg.shtml?stt=<?php echo $stt - 3600*4; ?>';
|
||||
});
|
||||
$('#later').button().click(function() {
|
||||
window.location = '/xepg.html?stt=<?php echo $ett; ?>';
|
||||
window.location = '/xepg.shtml?stt=<?php echo $ett; ?>';
|
||||
});
|
||||
|
||||
});
|
||||
|
22
var/mongoose/lib/channelsort
Normal file
22
var/mongoose/lib/channelsort
Normal file
@ -0,0 +1,22 @@
|
||||
proc _channelsort {v1 v2} {
|
||||
set v1s [$v1 get channel_num]
|
||||
set v2s [$v2 get channel_num]
|
||||
|
||||
if {$v1s > $v2s } { return 1 }
|
||||
if {$v1s == $v2s} {
|
||||
set v1t [$v1 get start]
|
||||
set v2t [$v2 get start]
|
||||
if {$v1t > $v2t} { return 1 }
|
||||
if {$v1t == $v2t} { return 0 }
|
||||
return -1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
proc channelsort {records} {
|
||||
foreach record $records {
|
||||
$record get_channel_info
|
||||
}
|
||||
return [lsort -command _channelsort $records]
|
||||
}
|
||||
|
@ -5,13 +5,21 @@ if {![exists -proc sqlite3.open ]} { package require sqlite3 }
|
||||
|
||||
require settings.class progressbar rsv.class
|
||||
|
||||
set ::channeldb 0
|
||||
catch { set ::channeldb [sqlite3.open /var/lib/humaxtv/channel.db] }
|
||||
|
||||
set ::epgpath /mnt/hd1/dvbepg/epg.dat
|
||||
set ::epgdbpath /mnt/hd1/epg.db
|
||||
set ::hdepgpath /media/drive1/epgsavedata
|
||||
if {![file exists $::epgpath] && [file exists $::hdepgpath]} {
|
||||
set ::epgpath $::hdepgpath
|
||||
set ::epgdbpath /media/drive1/epg.db
|
||||
}
|
||||
|
||||
set ::channeldb 0
|
||||
set ::qepg 0
|
||||
catch { set ::channeldb [sqlite3.open /var/lib/humaxtv/channel.db] }
|
||||
if {[file exists $::epgdbpath]} {
|
||||
$::channeldb query {attach database '%s' as epg} $::epgdbpath
|
||||
set ::qepg 1
|
||||
}
|
||||
|
||||
set ::rsvlookup [rsv lookuptab]
|
||||
@ -312,6 +320,56 @@ proc {epg exec} {mode args} {
|
||||
return [exec {*}$cmd]
|
||||
}
|
||||
|
||||
proc {epg dbfetch} {mode args} {
|
||||
set records {}
|
||||
set extra ""
|
||||
set q "select distinct *,
|
||||
usLcn as channel_num,
|
||||
substr(szSvcName, 2) as channel_name,
|
||||
aucDefaultAuthority as channel_crid,
|
||||
hSvc as channel_hsvc
|
||||
from epg.epg e join TBL_SVC c
|
||||
on e.service_id = c.usSvcId where 1 "
|
||||
foreach arg $args {
|
||||
if {[string first "-" $arg] == 0} {
|
||||
set v $args($arg)
|
||||
switch -- $arg {
|
||||
-crid { append q \
|
||||
"and e.event_crid = '$v' " }
|
||||
-scrid { append q \
|
||||
"and e.series_crid = '$v' " }
|
||||
-type { append q \
|
||||
"and e.content_type = $v " }
|
||||
-service { append q \
|
||||
"and e.service_id = $v " }
|
||||
-event { append q \
|
||||
"and e.event_id = $v " }
|
||||
-time { append q \
|
||||
"and e.start < $v and e.end > $v " }
|
||||
-trange {
|
||||
lassign [split $v :] stt ett
|
||||
append q "and (
|
||||
(e.start > $stt and e.start < $ett) or
|
||||
(e.end > $stt and e.end < $ett) or
|
||||
(e.start < $stt and e.end > $stt)
|
||||
) "
|
||||
}
|
||||
|
||||
default { error "Invalid option, $arg" }
|
||||
}
|
||||
}
|
||||
}
|
||||
append q "order by channel_num, start"
|
||||
|
||||
#puts "QUERY -$q-"
|
||||
|
||||
set records {}
|
||||
foreach rec [$::channeldb query $q] {
|
||||
lappend records [epg new $rec]
|
||||
}
|
||||
return $records
|
||||
}
|
||||
|
||||
proc {epg fetch} {mode args} {
|
||||
set records ""
|
||||
foreach line [split [epg exec $mode {*}$args] "\n"] {
|
||||
|
Loading…
Reference in New Issue
Block a user