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 svc.class 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 } # Maps the top nibble of descriptor 84 (content_type) to a description and # icon. set ::epg::genrelist { 0 { Unclassified Unclassified } 1 { Film Movie } 2 { "News & Factual" News } 3 { Entertainment Show } 4 { Sport Sports } 5 { Children Children } 6 { Entertainment Music } 7 { Art Art } 8 { Society Society } 9 { Education Education } 10 { Lifestyle Leisure } 11 { Unknown Unclassified } 12 { Unknown Unclassified } 13 { Unknown Unclassified } 14 { Unknown Unclassified } 15 { Drama Show } } # * service_id, event_id, start, duration, encrypted, name, text # * warning, content code, content type, # * event CRID, series CRID, rec CRID, warning mode class epg { service_id 0 event_id 0 start 0 duration 0 encrypted 0 name "" text "" warning "" warning_mode 0 content_code 0 content_type "" event_crid "" series_crid "" rec_crid "" channel 0 channel_num 0 channel_name "" channel_crid "" channel_hsvc 0 content_mgmt 0 sched_type -1 rsv 0 } epg method _parse {line} { lassign [split $line "\t"] \ service_id event_id start duration encrypted name text warning \ content_code content_type event_crid series_crid rec_crid \ warning_mode content_mgmt } 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 now [clock seconds] if {$start > $now} { return 0 } if {$start + $duration < $now} { return 0 } return 1 } epg method ended {} { if {$start + $duration < [clock seconds]} { return 1 } return 0 } epg method not_started {} { if {$start > [clock seconds]} { return 1 } 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]] } epg method end {} { return $($start + $duration) } epg method type_icon {} { set img "" if {[dict exists $::epg::genrelist $content_code]} { lassign $::epg::genrelist($content_code) x img } if {$img != "" && $img ne "Unclassified"} { return "/images/173_3_00_G3_$img.png" } else { return "" } } proc {epg channeliconpath} {name} { return "/img/channels/out/$name.png" } proc {epg channelicon} {name {width 0} {style ""}} { set str " 0} { append str " width=$width" } if {$style ne ""} { append str " style=\"$style\"" } append str " alt=\"\">" return $str } epg method channel_icon {{width 0} {style ""}} { set str " 0} { append str " width=$width" } if {$style ne ""} { append str " style=\"$style\"" } append str " alt=\"\">" return $str } epg method get_channel_info {} { if {$channel_num > 0} return 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] set channel_hsvc [$s get channel_hsvc] } epg method get_rsv {} { $self get_channel_info if {$channel == 0} return if {$rsv == 0 && $event_crid ne ""} { set rsv [rsv entry $event_crid $channel_hsvc] } if {$rsv == 0 && $series_crid ne ""} { set rsv [rsv entry $series_crid $channel_hsvc] } } epg method process_sched {{debug 0}} { $self scheduled $debug } set rsvlookup "" epg method scheduled {{debug 0}} { global rsvlookup if {$sched_type >= 0} { return $sched_type } set sched_type 0 if {$rsvlookup eq ""} { set st [clock milliseconds] set rsvlookup [rsv lookuptab] if {$debug} { puts "mS $([clock milliseconds] - $st) --- $rsvlookup" } } set p 0 foreach key [list \ "$service_id:$event_id" \ "$channel_hsvc:$event_id" \ [string tolower "$service_id:$channel_crid$series_crid"] \ [string tolower "$channel_crid$series_crid:$channel_crid$event_crid"] \ ] { if {$debug} { puts "Check key ($key)" } if {[dict exists $rsvlookup $key]} { set p $rsvlookup($key) if {$debug} {puts "FOUND ($p)"} break } } switch $p { S { set sched_type 2 } E { set sched_type 1 } R { set sched_type 3 } X { set sched_type 4 } default { set sched_type 0 } } if {$debug} { puts "SCHED_TYPE: ($sched_type)" } return $sched_type } proc {epg update_lookup_tab} {svcid evtid {add true} {type "S"}} { global rsvlookup # Update the reservations look up table (if present) with single entry if {$rsvlookup == ""} return set key $svcid:$evtid if {$add} { # add new entry dict set rsvlookup $key $type } else { # remove existing entry if {[dict exists $rsvlookup $key]} { dict unset rsvlookup $key } } #puts "$svcid:$evtid $add $type == $rsvlookup" } epg method icon_set {{height 0}} { if {$height > 0} { set height "height=$height" } else { set height "" } set icon [$self type_icon] set set "" if {$icon != ""} { lappend set "" } if {$warning ne ""} { if {$warning_mode} { set icon "Guidance_red" } else { set icon "Guidance_blue" } lappend set "" } $self process_sched if {$sched_type == 1} { lappend set \ "" } if {$sched_type == 2} { lappend set \ "" } elseif {$series_crid ne ""} { lappend set \ "" } if {$rec_crid ne ""} { lappend set \ "" } if {[string match {/*#*} $event_crid]} { lappend set \ "" } if {$content_mgmt eq "1"} { lappend set \ "" } return $set } epg method cell {} { set percent [$self percent] puts "