#!/usr/bin/ruby -w require 'yaml' chns = YAML.load_file('/root/.xmltv/mythtv_chns.yaml') allspools = Dir["/root/.xmltv/*/spool/*.xml"] tvcat = Hash.new {|h,v| h[v] = Array.new } chns.each_pair do |xmltv, data| filenames, srcid = data filenames.each do |filename| source = filename.split('.')[1] full = "/root/.xmltv/#{source}/spool/#{filename}.xml" unless test(?f, full) STDERR.puts "#{full} not found" else tvcat[srcid] << full end allspools.delete(full) end end allspools.each do |fn| STDERR.puts "#{fn} has no use" end tvcat.each_pair do |src, files| system "tv_cat #{files.join(' ')} >/video/tv-#{src}" end