require 'v2h' require 'cgi' class V2H::EPG @conf.urlgen( "epg/at:#{t.to_i}") } _a.update :class => :now if day..(day.in 1.day) === t t = cgi.a( _a) { t.strftime -'%m-%d' } sm = Tagen::SelectMenu.new t, ts links.push sm.gen( @conf.urlgen, :timeselect) end links.push '' t = time.in -@dura links.push cgi.a( :href => @conf.urlgen( 'epg', "at:#{t.to_i}")) { CGI.escapeHTML "<< #{t.strftime -'%H:%M'}" } if time > Time.now t = time.in @dura links.push cgi.a( :href => @conf.urlgen( 'epg/now')) { -'Now' } links.push cgi.a( :href => @conf.urlgen( 'epg', "at:#{t.to_i}")) { CGI.escapeHTML "#{t.strftime -'%H:%M'} >>" } end.to_s end def get_epg chan = nil, time = nil, dura = nil vdr, dura = @conf.vdr, dura.to_i stime = if /^at\s+(\d+)/ =~ time then Time.at $1.to_i end x = if dura != 0 && stime && !chan {:between => stime.to_i .. stime.in( dura).to_i} else {:channel => chan, :between => stime} end.darkknight( 'get_epg: %s') vdr.epg.select( x).to_a end def epg key chan, time = self.key key epg, cgi = self.get_epg( chan, time).first, @conf.cgi raise 'No Entry found' unless epg start, stop = epg.event.start, epg.event.stop body = cgi.h1( :class => :title) do cgi.a( :class => :record, :href => @conf.urlgen( 'epg/record', key.join( '/'), :suf => ENV[ 'PATH_INFO'])) do 'o' end + ' ' + epg.title + ' ' + Tagen::Wikipedia.new.gen( epg.title) + ' ' + Tagen::IMDb.new.gen( epg.title) end + cgi.p do cgi.b do cgi.a( :href => @conf.urlgen( 'epg', chan)) do epg.channel.name end + ': ' + start.strftime( -'%m-%d-%Y') + ' ' + cgi.a( :href => @conf.urlgen( 'epg', "at:#{start.to_i}")) do start.strftime -'%H:%M' end + ' - ' + cgi.a( :href => @conf.urlgen( 'epg', "at:#{stop.to_i}")) do stop.strftime -'%H:%M' end end end + cgi.p do epg.description.gsub '|', cgi.br end Array.new.with do |links| links.push cgi.link( :rel =>:next, :title => -'Next', :href => @conf.urlgen( 'epg', "#{chan}/at:#{stop.to_i}")) V2H::Data.new links, epg.title, body end end def record key epg = self.get_epg( *self.key( key).darkknight( 'key => %s')).flatten[0].darkknight raise NoPage unless epg start, stop = epg.event.start-5.minutes, epg.event.stop+5.minutes @conf.redirect 'timer/form/timer/new', key[ 2..-1].join( '/'), :channel => epg.channel.to_i, :date_year => start.year, :date_month => start.month, :date_day => start.day, :start_hour => start.hour, :start_min => start.min, :stop_hour => stop.hour, :stop_min => stop.min, :file => epg.title, :summ => epg.description end def list key chan, time = self.key( key) list_epg self.get_epg( chan, time, @dura), chan, time end def list_epg epg, chan, time vdr, cgi = @conf.vdr, @conf.cgi table = Tagen::Table.new 'epg' table.push :title => -'Date', :value => lambda { |a| a.event.start.strftime -'%m-%d-%Y' } table.push :title => -'Start', :name => 'event.start', :value => lambda { |a| s = a.event.start Tagen.a :href => @conf.urlgen( 'epg', "at:#{s.to_i}") do s.strftime -'%H:%M' end } table.push :title => -'Stop', :name => 'event.stop', :value => lambda { |a| s = a.event.stop Tagen.a :href => @conf.urlgen( 'epg', "at:#{s.to_i}") do s.strftime -'%H:%M' end } table.push :title => -'Channel', :name => 'channel.name', :value => lambda { |a| c = a.channel Tagen.a :href => @conf.urlgen( 'epg', c.id) do c.name end } unless chan table.push :value => lambda { |a| start, stop = a.event.start, a.event.stop url = @conf.urlgen 'epg/record', "#{a.channel.id}/at:#{start.to_i}", :suf => ENV[ 'PATH_INFO'] start, stop = start.min+start.hour*60, stop.min+stop.hour*60 Tagen.a( :class => :record, :href => url) { 'o' } } table.push :title => -'Title', :name => 'title', :value => lambda { |a| start, stop = a.event.start, a.event.stop url = @conf.urlgen 'epg', "#{a.channel.id}/at:#{start.to_i}" start, stop = start.min+start.hour*60, stop.min+stop.hour*60 rec = a.record?.collect do |i| case i when false then :norecord when true then :fullrecord when -1 then :postrecord when 1 then :prerecord when 0 then :partrecord end end click = Tagen.a( :href => url, :class => rec) do if (start .. stop).include? 20*60+16 Tagen.b { CGI.escapeHTML( a.title) } else CGI.escapeHTML( a.title) end end click } if time && 'next' != time.to_s t = time.to_s == 'now' ? Time.now : Time.at( time.match( /\d+/).to_s.to_i) tagen = table.tagen eval <<-EOC def tagen.tbody *p ret = super *p #{ _t = t.in -@dura <<-EOCP if t < Time.now ret = self.tr( :class => [:link_prev_epg, :r1]) do self.td( :style => 'text-align: center;', :class => [:first, :last], :colspan => #{table.length}) do self.a( :href => #{ @conf.urlgen( 'epg', "at:#{_t.to_i}").inspect }) do "... #{_t.strftime -'%H:%M'} - #{t.strftime -'%H:%M'} ..." end end end+ ret EOCP } #{ _t = t.in @dura <<-EOCP ret += self.tr( :class => [:link_next_epg, :r1]) do self.td( :style => 'text-align: center;', :class => [:first, :last], :colspan => #{table.length}) do self.a( :href => #{ @conf.urlgen( 'epg', "at:#{_t.to_i}").inspect }) do "... #{_t.strftime -'%H:%M'} - #{_t.in( @dura).strftime -'%H:%M'} ..." end end end EOCP } end EOC end table.sort_by = @conf.opts['epg_sortBy'] || "1" body = self.chansel( chan, time) + table.generate( epg) V2H::Data.new Array.new, -'EPG', body end def find_form key end def find_search key h = @conf.opts.over.symbolize_keys list_epg @conf.vdr.epg.find( h), false, nil end def graph time chan, time = self.key( time) epg = self.get_epg nil, time, @dura @tagen.table( :class => :timeline) do @tagen.thead do @tagen.tr do end end + @tagen.tbody do epg.collect do |e| @tagen.tr do epg.collect do |f| @tagen.td do end end end end end end end end