2011-06-07 13:26:45 +00:00
|
|
|
|
|
|
|
if {[expr ! [exists -proc class ]]} { package require oo }
|
|
|
|
if {[expr ! [exists -proc sqlite3.open ]]} { package require sqlite3 }
|
2011-06-14 11:48:55 +00:00
|
|
|
if {[expr ! [exists -proc settings ]]} {
|
|
|
|
source /mod/var/mongoose/lib/settings.class
|
|
|
|
}
|
2011-06-07 13:26:45 +00:00
|
|
|
|
|
|
|
source /mod/var/mongoose/lib/progressbar
|
|
|
|
|
2011-06-07 14:45:01 +00:00
|
|
|
set channeldb 0
|
2011-06-14 11:48:55 +00:00
|
|
|
catch { set channeldb [sqlite3.open /var/lib/humaxtv/channel.db] }
|
2011-06-07 13:26:45 +00:00
|
|
|
|
|
|
|
# * service_id, event_id, start, duration, encrypted, name, text
|
|
|
|
# * warning, content code, content type,
|
|
|
|
# * event CRID, series CRID, rec CRID
|
|
|
|
|
|
|
|
class epg {
|
|
|
|
service_id 0
|
|
|
|
event_id 0
|
|
|
|
start 0
|
|
|
|
duration 0
|
|
|
|
encrypted 0
|
|
|
|
name ""
|
|
|
|
text ""
|
|
|
|
warning ""
|
|
|
|
content_code 0
|
|
|
|
content_type ""
|
|
|
|
event_crid ""
|
|
|
|
series_crid ""
|
|
|
|
rec_crid ""
|
|
|
|
|
|
|
|
channel_num 0
|
|
|
|
channel_name ""
|
2011-06-08 23:33:35 +00:00
|
|
|
channel_crid ""
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
epg method _parse {line} {
|
|
|
|
set vars [split $line "\t"]
|
|
|
|
|
|
|
|
set service_id [lindex $vars 0]
|
|
|
|
set event_id [lindex $vars 1]
|
|
|
|
set start [lindex $vars 2]
|
|
|
|
set duration [lindex $vars 3]
|
|
|
|
set encrypted [lindex $vars 4]
|
|
|
|
set name [lindex $vars 5]
|
|
|
|
set text [lindex $vars 6]
|
|
|
|
set warning [lindex $vars 7]
|
|
|
|
set content_code [lindex $vars 8]
|
|
|
|
set content_type [lindex $vars 9]
|
|
|
|
set event_crid [lindex $vars 10]
|
|
|
|
set series_crid [lindex $vars 11]
|
|
|
|
set rec_crid [lindex $vars 12]
|
|
|
|
}
|
|
|
|
|
|
|
|
epg method percent {} {
|
|
|
|
set now [clock seconds]
|
|
|
|
if {$start > $now} { return 0 }
|
|
|
|
if {$start + $duration < $now} { return 100 }
|
|
|
|
return [expr [expr $now - $start] * 100 / $duration]
|
|
|
|
}
|
|
|
|
|
|
|
|
epg method showing {} {
|
|
|
|
set percent [$self percent]
|
|
|
|
if {$percent > 0 && $percent < 100} { return 1 } else { return 0 }
|
|
|
|
}
|
|
|
|
|
|
|
|
epg method elapsed {} {
|
|
|
|
set percent [$self percent]
|
|
|
|
if {$percent == 0} { return 0 }
|
|
|
|
if {$percent == 100} { return $duration }
|
|
|
|
return [expr $duration * $percent / 100]
|
|
|
|
}
|
|
|
|
|
|
|
|
epg method remaining {} {
|
|
|
|
return [expr $duration - [$self elapsed]]
|
|
|
|
}
|
|
|
|
|
2011-06-08 23:33:35 +00:00
|
|
|
epg method type_icon {} {
|
2011-06-07 13:26:45 +00:00
|
|
|
set img ""
|
|
|
|
switch -- [$self get content_code] {
|
|
|
|
1 { set img "Movie" }
|
|
|
|
2 { set img "News" }
|
|
|
|
3 { set img "Show" }
|
|
|
|
4 { set img "Sports" }
|
|
|
|
5 { set img "Children" }
|
|
|
|
6 { set img "Music" }
|
|
|
|
7 { set img "Art" }
|
|
|
|
8 { set img "Society" }
|
|
|
|
9 { set img "Education" }
|
|
|
|
10 { set img "Leisure" }
|
|
|
|
}
|
|
|
|
if {$img != ""} {
|
2011-06-08 23:33:35 +00:00
|
|
|
return "/images/173_3_00_G3_$img.png"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc {epg channelicon} {name {width 0} {style ""}} {
|
|
|
|
set str "<img src=\"/img/channels/$name.png\"";
|
|
|
|
if {$width > 0} { append str " width=$width" }
|
|
|
|
if {$style ne ""} { append str " style=\"$style\" }
|
|
|
|
append str " alt=\"\">"
|
|
|
|
return $str
|
|
|
|
}
|
|
|
|
|
2011-06-09 21:16:30 +00:00
|
|
|
epg method channel_icon {{width 0} {style ""}} {
|
2011-06-14 11:48:55 +00:00
|
|
|
set str "<img src=\"/img/channels/[$self get channel_name].png\"";
|
2011-06-09 21:16:30 +00:00
|
|
|
if {$width > 0} { append str " width=$width" }
|
|
|
|
if {$style ne ""} { append str " style=\"$style\" }
|
|
|
|
append str " alt=\"\">"
|
|
|
|
return $str
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
epg method get_channel_info {} {
|
|
|
|
global channeldb
|
|
|
|
|
|
|
|
if {!$channel_num && $channeldb != ""} {
|
|
|
|
set chan [lindex [$channeldb query {
|
|
|
|
select szSvcName, usLcn, aucDefaultAuthority
|
|
|
|
from TBL_SVC
|
|
|
|
where usSvcId = %s} "[$self get service_id]"
|
|
|
|
] 0]
|
|
|
|
set channel_num $chan(usLcn)
|
|
|
|
set channel_name [string range $chan(szSvcName) 1 end]
|
|
|
|
set channel_crid [string toupper $chan(aucDefaultAuthority)]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 23:33:35 +00:00
|
|
|
epg method icon_set {{height 0}} {
|
|
|
|
if {$height > 0} { set height "height=$height" } else { set height "" }
|
|
|
|
set icon [$self type_icon]
|
2011-06-09 00:42:26 +00:00
|
|
|
set set ""
|
2011-06-08 23:33:35 +00:00
|
|
|
if {$icon != ""} {
|
2011-06-09 00:42:26 +00:00
|
|
|
lappend set "<img src=$icon $height
|
2011-06-07 13:26:45 +00:00
|
|
|
alt=\"[$self get content_type]\"
|
2011-06-08 23:33:35 +00:00
|
|
|
title=\"[$self get content_type]\">"
|
|
|
|
}
|
|
|
|
if {[$self get rec_crid] != ""} {
|
2011-06-09 00:42:26 +00:00
|
|
|
lappend set \
|
2011-06-08 23:33:35 +00:00
|
|
|
"<img src=/images/178_1_26_Icon_Recommend.png $height>"
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
if {[$self get series_crid] != ""} {
|
2011-06-09 00:42:26 +00:00
|
|
|
lappend set \
|
2011-06-08 23:33:35 +00:00
|
|
|
"<img src=/images/178_1_00_Icon_Serise.png $height>"
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
2011-06-09 00:42:26 +00:00
|
|
|
return $set
|
2011-06-08 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
epg method cell {} {
|
|
|
|
set name [$self get name]
|
|
|
|
set text [$self get text]
|
|
|
|
|
|
|
|
set percent [$self percent]
|
|
|
|
|
|
|
|
puts "<td nowrap valign=top title=\"$text\">"
|
|
|
|
|
2011-06-09 00:42:26 +00:00
|
|
|
puts [join [$self icon_set 14] ""]
|
2011-06-08 23:33:35 +00:00
|
|
|
|
2011-06-07 13:26:45 +00:00
|
|
|
puts "
|
2011-06-14 11:48:55 +00:00
|
|
|
<a class=event href=# xref=/cgi-bin/epg_info.jim?service=[$self get service_id]&event=[$self get event_id]>
|
2011-06-07 13:26:45 +00:00
|
|
|
$name</a>"
|
|
|
|
|
|
|
|
puts "<br>"
|
|
|
|
|
|
|
|
puts "<font class=footnote>"
|
|
|
|
puts "[clock format [$self get start] -format %H:%M]"
|
|
|
|
puts " ([clock format [$self get duration] -format %T])"
|
|
|
|
if {$percent > 0 && $percent < 100} {
|
|
|
|
puts "<br>[progressbar $percent]"
|
|
|
|
puts "$percent% [clock format [$self elapsed] -format %T] /
|
|
|
|
[clock format [$self remaining] -format %T]"
|
|
|
|
}
|
|
|
|
puts "</font>"
|
|
|
|
puts "</td>"
|
|
|
|
}
|
|
|
|
|
|
|
|
epg method next {} {
|
|
|
|
set tm [expr [$self get start] + [$self get duration] + 60]
|
|
|
|
set nextlist [epg fetch dump -service [$self get service_id] -time $tm]
|
|
|
|
|
|
|
|
if {[llength nextlist] > 0} {
|
|
|
|
return [lindex $nextlist 0]
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 23:33:35 +00:00
|
|
|
epg method recommended {} {
|
|
|
|
set rec ""
|
|
|
|
if {[$self get rec_crid] != ""} {
|
|
|
|
catch { set rec [lindex [
|
|
|
|
epg fetch dump -crid [$self get rec_crid]] 0] }
|
|
|
|
}
|
|
|
|
return $rec
|
|
|
|
}
|
|
|
|
|
2011-06-07 13:26:45 +00:00
|
|
|
proc {epg parse} {line} {
|
|
|
|
set e [epg new]
|
|
|
|
$e _parse $line
|
|
|
|
return $e
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {epg cleanup} {} {
|
|
|
|
global channeldb
|
|
|
|
|
2011-06-08 23:33:35 +00:00
|
|
|
if {$channeldb != ""} { $channeldb close }
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc {epg exec} {mode args} {
|
|
|
|
set raw 0
|
|
|
|
set cmd [list /mod/bin/epg]
|
|
|
|
set extra ""
|
|
|
|
foreach arg $args {
|
|
|
|
if {[string first "-" $arg] == 0} {
|
|
|
|
switch -- $arg {
|
|
|
|
-raw { set raw 1 }
|
|
|
|
-crid { lappend cmd -C $args($arg) }
|
2011-06-08 23:33:35 +00:00
|
|
|
-scrid { lappend cmd -R $args($arg) }
|
2011-06-07 13:26:45 +00:00
|
|
|
-type { lappend cmd -T $args($arg) }
|
|
|
|
-service { lappend cmd -S $args($arg) }
|
|
|
|
-event { lappend cmd -E $args($arg) }
|
|
|
|
-time { lappend cmd -@ $args($arg) }
|
|
|
|
-extra { set extra $args($arg) }
|
|
|
|
default { error "Invalid option, $arg" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if { $raw == 0 } { lappend cmd -p }
|
|
|
|
lappend cmd $mode
|
|
|
|
lappend cmd $extra
|
|
|
|
|
|
|
|
#puts "CMD -$cmd-"
|
|
|
|
|
|
|
|
return [exec {*}$cmd]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {epg fetch} {mode args} {
|
2011-06-08 23:33:35 +00:00
|
|
|
set records ""
|
2011-06-07 13:26:45 +00:00
|
|
|
foreach line [split [epg exec $mode {*}$args] "\n"] {
|
2011-06-14 11:48:55 +00:00
|
|
|
lappend records [epg parse $line]
|
2011-06-07 13:26:45 +00:00
|
|
|
}
|
|
|
|
return $records
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc {epg favlist} {} {
|
|
|
|
global channeldb
|
|
|
|
|
|
|
|
set num [[settings] channel_group]
|
|
|
|
|
|
|
|
if {!$num} { return "" }
|
|
|
|
|
|
|
|
return [lmap i [$channeldb query "
|
|
|
|
select TBL_SVC.usSvcid
|
|
|
|
from TBL_SVC join TBL_FAV
|
|
|
|
using(hSvc)
|
|
|
|
where TBL_FAV.eFavGroup == $num
|
|
|
|
"] { lindex $i end }]
|
|
|
|
}
|
|
|
|
|