Sha256: a38955100b142d6fb869079997df98cc91ecbd973276e2d2598592320ec65e40

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby

require 'date'

tvlisting_dir = "/mnt/part5/www/tvlistings/"

html_cmd = "/home/kvh/bin/xmltv2html.rb"
index_cmd = "/home/kvh/bin/tvlistings_index"

conf = "/home/kvh/.xmltv2htmlrc"

files = Dir[tvlisting_dir + "20*.xml"]

files.each { |f|
	fd = File.basename(f)
	
#	$stderr.print f, "  ", File.stat(f).zero?,"\n"
	if File.stat(f).zero? then
		print "^^^ Zero file - Deleting #{f}\n"
		if File.delete(f) != 1 then
			print " Error deleting #{f}\n"
		end
		next
	end
	output_file = f.gsub(/.xml$/,".html")
	if File.exists?(output_file) and File.stat(output_file).zero? then
		print "^^^ Zero file - Deleting #{output_file}\n"
		if File.delete(output_file) != 1 then
			print " Error deleting #{output_file}\n"
		end
		next
	end
	output_file = f.gsub(/.xml$/,".html")
	if File.exists?(output_file)
      print "^^^ #{output_file} already exists.\n"
      next
   end

	fdd = fd.gsub(/.xml$/,"")

   prevday = nil
   nextday = nil

#	$stderr.print "#{fdd}\n"
#      d = Date.new(fdate[0,4].to_i, fdate[4,2].to_i, fdate[6,2].to_i)
   d = Date.new(fdd[0,4].to_i, fdd[5,2].to_i, fdd[8,2].to_i)
	nextday = d + 1
   nextday_file = nextday.strftime("%Y-%m-%d") + ".html"
	prevday = d - 1
   prevday_file = prevday.strftime("%Y-%m-%d") + ".html"

#	$stderr.print "prev day #{prevday}; #{prevday_file}\n"
#	$stderr.print "next day #{nextday}; #{nextday_file}\n"


   run_me = html_cmd
   run_me += " --configfile=" + conf if File.exists?(conf)
   run_me += " < " + f + " > " + output_file
   run_me += " --urlprev=" + prevday_file if prevday_file
   run_me += " --urlnext=" + nextday_file if nextday_file

   print run_me,"\n"
   status = system(run_me)
   $stderr.print "Error ",status," occurred while running : ", run_me,"\n\n" if !status

}


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xmltv2html-0.5.3 contrib/kvh/generate_html