#!/mod/bin/jimsh package require cgi source /mod/webif/lib/setup require epg.class spinner.class altrow puts "Content-Type: text/html" puts "" header require totop puts "" cgi_input #cgi_dump set ct 0 catch { set ct [dict get $_cgi ct] } set crid "" catch { set crid [dict get $_cgi crid] } set scrid "" catch { set scrid [dict get $_cgi scrid] } if {[dict exists $_cgi term]} { set lterm [dict get $_cgi term] if {[string match {CRID:*} $lterm]} { set crid [string range $lterm 5 end] } elseif {[string match {SCRID:*} $lterm]} { set scrid [string range $lterm 6 end] } } elseif {$crid ne ""} { set _cgi(term) "CRID:$crid" } elseif {$scrid ne ""} { set _cgi(term) "SCRID:$scrid" } require epg_search [spinner new { text "Searching EPG..." size "1.2em" style "margin: 1em;" }] start require epg_popup #set _cgi [dict create term "doctor who"] #set env(REQUEST_URI) "test" set cmd "search" if {$searchfull} { set cmd "searchall" } if {$ct > 0 } { set records [epg fetch dump -type $ct] } elseif {$crid ne ""} { set records [epg fetch dump -crid $crid] } elseif {$scrid ne ""} { set records [epg fetch dump -scrid $scrid] } elseif {$searchterm ne ""} { set records [epg dbfetch $cmd -term $searchterm] } else { set records {} } set favlist [epg favlist] if {[llength $records] > 0} { puts { } } else { puts "No results found." } proc rsort {v1 v2} { set v1s [$v1 get start] set v2s [$v2 get start] if {$v1s == $v2s} { return 0 } if {$v1s > $v2s } { return 1 } return -1 } set i 0 foreach record [lsort -command rsort $records] { if {$favlist != "" && [$record get service_id] ni $favlist} { continue } altrow $record get_channel_info set ended [$record ended] if $ended { puts "" puts "" puts "" puts "" puts [$record cell] puts "" puts "" } puts "
Date Channel Programme Synopsis
" } else { puts ""} puts " [clock format [$record get start] -format "%a %d %b %Y"]
[clock format [$record get start] -format "%H:%M %Z"]" puts "
[$record get channel_num][$record channel_icon 50] [$record get channel_name] [$record get text][$record get warning]
" if {$searchterm != ""} { puts " " } epg cleanup footer