Class: XMLTV::Film1Grabber
Constant Summary
Constants inherited from Grabber
Grabber::Dag, Grabber::MythTV, Grabber::Vandaag
Instance Attribute Summary
Attributes inherited from Grabber
#all_channels, #base_url, #channel_list, #chnbasedir, #config, #config_file_name, #generator, #lang, #myname, #reject_file_name, #spooldir
Instance Method Summary collapse
- #fetch_all_channels ⇒ Object
-
#fetch_programs ⇒ Object
Helpers.
-
#grab_channel(chan_id) ⇒ Object
Must Implement.
-
#initialize ⇒ Film1Grabber
constructor
A new instance of Film1Grabber.
- #transform(chan_id) ⇒ Object
Methods inherited from Grabber
#add_channels_to_config, #cachefile, #channel_display, #channel_name, #check_argv, #check_channel, #clean_cache_dir, #clean_spool_dir, #config_channels, #date_stats, #delete_channels_from_config, #do_list, #do_options, #dump, #fetch, #fix_times, #get_channels, #list_all, #list_config, #load_cachefile, #load_channel_file, #load_config_file, #outputfile, #printline, #proghash, #reject, #report, #run, #save, #save_config, #save_object, #version
Constructor Details
#initialize ⇒ Film1Grabber
Returns a new instance of Film1Grabber.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/xmltv/sites/film1.rb', line 9 def initialize super @programs = nil @all_channels = { '1' => 'Film1 1', '2' => 'Film1 +1', '3' => 'Film1 2', '4' => 'Film1 3' } end |
Instance Method Details
#fetch_all_channels ⇒ Object
19 20 21 |
# File 'lib/xmltv/sites/film1.rb', line 19 def fetch_all_channels all_channels end |
#fetch_programs ⇒ Object
Helpers
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/xmltv/sites/film1.rb', line 32 def fetch_programs @programs = Hash.new @n_progs = [ 0, 0, 0, 0] %w{ sun mon tues wednes thurs fri satur }.each do |day| url = "#{base_url}/tv/epg.php?day=#{day}day" # url = '/home/han/epg.php' page = fetch(url) date = page.at('//span[@id="current"]').inner_text STDERR.puts("#{url} #{date}") if XmltvOptions.verbose @programs[date] = day_hash = Hash.new %w{ 1 2 3 4 }.each do |col| day_hash[col] = colarray = Array.new page.search("//div.epg_block").each do |dagdeel| period = dagdeel.previous_sibling.inner_text.strip dagdeel.search("//dl.col#{col}").each do |el| el.search('dd').each do |pg| program = Hash.new program['period'] = period # STDERR.puts pg.class, pg, '====' info = pg.previous_sibling %w{ time title genre short_info }.each do |inf| program[inf] = info.at("/.#{inf}").inner_text.to_utf end program['desc'] = pg.children[3].to_s.strip.to_utf @n_progs[col.to_i - 1] += 1 colarray << program unless program.empty? end end end end end end |
#grab_channel(chan_id) ⇒ Object
Must Implement
67 68 69 70 |
# File 'lib/xmltv/sites/film1.rb', line 67 def grab_channel(chan_id) fetch_programs unless @programs @n_progs[chan_id.to_i - 1] end |
#transform(chan_id) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/xmltv/sites/film1.rb', line 72 def transform(chan_id) now = Time.new jaar = now.year progdata_array = Array.new @programs.each_pair do |dag, schedule| date = Date.dutch(dag) jaar, maand, dag = date.year, date.month, date.day schedule.each_pair do |ch, programs| next unless ch == chan_id programs.each do |p| progdata = proghash(p, ch) startuur, startmin, stopuur, stopmin = p['time'].split(/[:-]/).map{|x| x.to_i} progdata['start'] = Time.local(jaar, maand, dag, startuur, startmin) progdata['start'] += Dag if p['period'] == 'nacht' date_stats(chan_id, progdata['start']) progdata['stop'] = Time.local(jaar, maand, dag, stopuur, stopmin) progdata['stop'] += Dag if progdata['stop'] < progdata['start'] progdata['category'] = 'Movies' progdata['credits']['actor'] = p['short_info'].split(',').map {|x| x.strip} progdata_array << progdata end end end progdata_array end |