if {[expr ! [exists -proc class ]]} { package require oo } if {[expr ! [exists -proc sqlite3.open ]]} { package require sqlite3 } source /mod/var/mongoose/lib/progressbar set channeldb 0 catch { set channeldb [sqlite3.open /var/lib/humaxtv/channel.db] } # * 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 "" } epg method channel {chnum chname} { set channel_num $chnum set channel_name $chname } 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]] } epg method cell {} { set name [$self get name] set text [$self get text] set percent [$self percent] puts "