bin/xmltv2html.rb in xmltv2html-0.5.4 vs bin/xmltv2html.rb in xmltv2html-0.5.5

- old
+ new

@@ -1,10 +1,10 @@ #!/usr/bin/ruby -w # # xmltv2html.rb - A Ruby script to tranform the XMLTV output into HTML. # -# Version : 0.5.4 +# Version : 0.5.5 # Author : Kurt V. Hindenburg <public@kurt.hindenburg.name> # # Copyright (C) 2003, 2004, 2005 Kurt V. Hindenburg # # This program is free software; you can redistribute it and/or modify @@ -71,12 +71,12 @@ require "optparse" require "rexml/document" require 'singleton' require 'time' -XMLTV2HTML_VERSION="0.5.4" -XMLTV2HTML_DATE="Sep 10, 2005" +XMLTV2HTML_VERSION="0.5.5" +XMLTV2HTML_DATE="Sep 17, 2005" module Xmltv2Html def die(*args) $stderr.print args @@ -116,12 +116,12 @@ attr_reader(:popup_title_font, :popup_body_font) attr_reader(:time_divisor) attr_accessor(:start_date, :stop_date) attr_accessor(:days, :total_hours, :total_span) attr_accessor(:url_next, :url_prev) - attr_accessor(:start_time, :stop_time) + attr_accessor(:output_favorites) def initialize @opts = {} @keys = %w{ times_interval chanels_interval time_format_12 } @favorites = Hash.new @@ -170,10 +170,12 @@ "CSI: Crime Scene Investigation", "Law & Order: Special Victims Unit", "Angel", "Law & Order", "The Shield", "Law & Order: Criminal Intent", "Charmed", "The West Wing" ] + # Print out list of favorites beneath the listings? + @output_favorites = false # Name of CSS file @css_filename = 'xmltv2html.css' # Categories - use specified CSS class for given category. @@ -403,17 +405,17 @@ return if not @stopSlot @spanSlots = @stopSlot - @startSlot end - def start_time - @times.start_time - end +# def start_time +# @times.start_time +# end - def stop_time - @times.stop_time - end +# def stop_time +# @times.stop_time +# end def to_s @title end @@ -665,11 +667,11 @@ t2 = Time.parse(@lastShowStopDate) @time_first = t1.strftime("%a %b %d %I:%M %p") @time_last = t2.strftime("%a %b %d %I:%M %p %Z") - if (t1.hour > 19) and (t2.hour < 05) + if ( (t1.hour == 0) or (t1.hour > 19) ) and (t2.hour < 05) t3 = t1 + (5 * 3600) @top_title += t3.strftime("%A %b %d") @HTML_title = @top_title @top_title += "<br />" @@ -868,10 +870,11 @@ end def generateHTML sindex =-1 times_counter = 1 + favorites_list = [] @out.dates = @dates @out.doctype @out.header(@xml.HTML_title) @@ -896,11 +899,17 @@ when "D" @out.outputDummyProgramme(span) when "P" # Programme sindex += 1 pi += 1 - @out.outputProgramme(c.programme_at(pi), sindex, span) + prog = c.programme_at(pi) + @out.outputProgramme(prog, sindex, span) +# @out.outputProgramme(c.programme_at(pi), sindex, span) + if $params.use_favorites and $params.output_favorites and $params.favorites.has_key?(prog.title) +#$stderr.print "found a fav #{prog.title}\n" + favorites_list << prog + end when "Q" # Use previous Programme's info @out.outputProgramme(c.programme_at(pi), sindex, span) when "C" @out.outputChannel(c) else @@ -912,10 +921,13 @@ @out.table_times if times_counter % $params.times_interval == 0 times_counter += 1 } @out.table_end + + @out.output_favorites_list(favorites_list) if not favorites_list.empty? + @out.text_after_table @out.footer end end @@ -1201,9 +1213,40 @@ end else print s.title ; nl end print '</td>'; nl + end + + def output_favorites_list(fav_list) + fav_list = fav_list.sort! { |a, b| a.title<=>b.title } + + + print '<br><br>'; nl + print '<table width="100%" border="3" cellpadding="3">'; nl + print '<tr><td colspan="3" align="center">Favorites</td></tr>'; nl + print '<tr><td width="50%" align="center" nowrap>Title</td>'; + print '<td width="25%" align="center">Start</td>'; + print '<td width="25%" align="center">Stop</td>'; + print '</tr>'; nl + + fav_list.each { |p| + print '<tr>'; nl + + outputProgramme(p, p.popupIndex, 1) + + print '<td align="center">'; nl + print p.times.fullStartTime.strftime("%a %b %d %I:%M %p") + print '</td>'; nl + + print '<td align="center">'; nl + print p.times.fullStopTime.strftime("%a %b %d %I:%M %p") + print '</td>'; nl + + print '</tr>'; nl + } + + print '</table>'; nl end def outputInfo print '<br>' print '<span class="info">'