xmltv/grab/ch_search tv_grab_ch_search.in, 1.19, 1.20

Patric Mueller <[email protected]> Thu, 04 Feb 2016 11:37:14 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/ch_search
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28175

Modified Files:
	tv_grab_ch_search.in 
Log Message:
_ch_search: updating grabber for new layout


Index: tv_grab_ch_search.in
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/ch_search/tv_grab_ch_search.in,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** tv_grab_ch_search.in	20 Jun 2015 15:45:13 -0000	1.19
--- tv_grab_ch_search.in	4 Feb 2016 11:37:12 -0000	1.20
***************
*** 25,34 ****
  
  Output TV listings for several channels available in Switzerland and
! (partly) central Europe. 
  The data comes from tv.search.ch. The grabber relies on
  parsing HTML so it might stop working at any time.
  
! First run B<tv_grab_ch_search --configure> to choose, which channels 
! you want to download. Then running B<tv_grab_ch_search> with no 
  arguments will output listings in XML format to standard output.
  
--- 25,34 ----
  
  Output TV listings for several channels available in Switzerland and
! (partly) central Europe.
  The data comes from tv.search.ch. The grabber relies on
  parsing HTML so it might stop working at any time.
  
! First run B<tv_grab_ch_search --configure> to choose, which channels
! you want to download. Then running B<tv_grab_ch_search> with no
  arguments will output listings in XML format to standard output.
  
***************
*** 37,41 ****
  
  B<--config-file FILE> Set the name of the configuration file, the
! default is B<~/.xmltv/tv_grab_ch_search.conf>.  This is the file 
  written by B<--configure> and read when grabbing.
  
--- 37,41 ----
  
  B<--config-file FILE> Set the name of the configuration file, the
! default is B<~/.xmltv/tv_grab_ch_search.conf>.  This is the file
  written by B<--configure> and read when grabbing.
  
***************
*** 73,82 ****
  
  Daniel Bittel <[email protected]>. Inspired by tv_grab_ch by Stefan Siegl.
  
  =head1 BUGS
  
! If you happen to find a bug, you're requested to send a mail to me
! at B<[email protected]> or to one of the XMLTV mailing lists, see webpages
! at http://sourceforge.net/projects/xmltv/.
  
  =cut
--- 73,82 ----
  
  Daniel Bittel <[email protected]>. Inspired by tv_grab_ch by Stefan Siegl.
+ Patric Mueller <[email protected]>.
  
  =head1 BUGS
  
! If you happen to find a bug, you're requested to send a mail to one of the
! XMLTV mailing lists, see webpages at http://sourceforge.net/projects/xmltv/.
  
  =cut
***************
*** 84,87 ****
--- 84,88 ----
  use warnings;
  use strict;
+ use Encode;
  use DateTime;
  use LWP::Simple;
***************
*** 95,98 ****
--- 96,100 ----
  use HTML::Entities;
  use URI::Escape;
+ use URI::URL;
  use XMLTV;
  use XMLTV::Ask;
***************
*** 137,143 ****
  
  ## attributes of xmltv root element
! my $head = { 
!     'source-data-url'      => 'http://tv.classic.search.ch/channels.de.html',
!     'source-info-url'      => 'http://tv.classic.search.ch/index.de.html',
      'generator-info-name'  => 'XMLTV',
      'generator-info-url'   => 'http://xmltv.org/',
--- 139,145 ----
  
  ## attributes of xmltv root element
! my $head = {
!     'source-data-url'      => 'http://tv.search.ch/channels',
!     'source-info-url'      => 'http://tv.search.ch/',
      'generator-info-name'  => 'XMLTV',
      'generator-info-url'   => 'http://xmltv.org/',
***************
*** 176,180 ****
      'offset=i'       => \$opt_offset,
      'quiet'          => \$opt_quiet,
!     'slow'           => \$opt_slow,    
      'list-channels'  => \$opt_list_channels,
      'help'           => \$opt_help,
--- 178,182 ----
      'offset=i'       => \$opt_offset,
      'quiet'          => \$opt_quiet,
!     'slow'           => \$opt_slow,
      'list-channels'  => \$opt_list_channels,
      'help'           => \$opt_help,
***************
*** 196,201 ****
  
  my $mode = XMLTV::Mode::mode('grab', # default value
!     $opt_configure 	=> 'configure',
!     $opt_list_channels	=> 'list-channels',
  );
  
--- 198,203 ----
  
  my $mode = XMLTV::Mode::mode('grab', # default value
!     $opt_configure => 'configure',
!     $opt_list_channels => 'list-channels',
  );
  
***************
*** 208,215 ****
  if($mode eq 'configure') {
      XMLTV::Config_file::check_no_overwrite($config_file);
! } 
  elsif($mode eq 'grab' || $mode eq 'list-channels') {
      @config_lines = XMLTV::Config_file::read_lines($config_file);
! } 
  else { die("never heard of XMLTV mode $mode, sorry :-(") }
  
--- 210,217 ----
  if($mode eq 'configure') {
      XMLTV::Config_file::check_no_overwrite($config_file);
! }
  elsif($mode eq 'grab' || $mode eq 'list-channels') {
      @config_lines = XMLTV::Config_file::read_lines($config_file);
! }
  else { die("never heard of XMLTV mode $mode, sorry :-(") }
  
***************
*** 234,243 ****
  
      if (/^channel:?\s+(\S+)/) {
! 	warn("\nConfigured channel $1 not available anymore. \nPlease reconfigure tv_grab_ch_search.\n"),
! 	  next unless(defined($channels{$1}));
! 	push @requests, $1;
!     } 
!     else {
! 	warn "$config_file:$line: bad line\n";
      }
  }
--- 236,244 ----
  
      if (/^channel:?\s+(\S+)/) {
!         warn("\nConfigured channel $1 not available anymore. \nPlease reconfigure tv_grab_ch_search.\n"),
!           next unless(defined($channels{$1}));
!         push @requests, $1;
!     } else {
!         warn "$config_file:$line: bad line\n";
      }
  }
***************
*** 254,269 ****
  
      foreach (@chs) {
! 	my $w = shift @want;
! 	my $chname = shift @names;
! 	
! 	warn("cannot read input, stopping to ask questions ..."), last if not defined $w;
  
! 	print CONFIG '#' if not $w; #- comment line out if user answer 'no'
  
! 	# shall we store the display name in the config file?
! 	# leave it in, since it probably makes it a lot easier for the
! 	# user to choose which channel to comment/uncommet - when manually
! 	# viing the config file -- are there people who do that?
! 	print CONFIG "channel $_ #$chname\n";
      }
  
--- 255,270 ----
  
      foreach (@chs) {
!         my $w = shift @want;
!         my $chname = shift @names;
  
!         warn("cannot read input, stopping to ask questions ..."), last if not defined $w;
  
!         print CONFIG '#' if not $w; #- comment line out if user answer 'no'
! 
!         # shall we store the display name in the config file?
!         # leave it in, since it probably makes it a lot easier for the
!         # user to choose which channel to comment/uncommet - when manually
!         # viing the config file -- are there people who do that?
!         print CONFIG "channel $_ #$chname\n";
      }
  
***************
*** 292,297 ****
  if( defined( $opt_days )) {
      $writer_args{offset} = $opt_offset;
! 	$writer_args{days} = $opt_days;
! 	$writer_args{cutoff} = "000000";
  }
  
--- 293,298 ----
  if( defined( $opt_days )) {
      $writer_args{offset} = $opt_offset;
!     $writer_args{days} = $opt_days;
!     $writer_args{cutoff} = "000000";
  }
  
***************
*** 304,309 ****
  if ($mode eq 'list-channels') {
      foreach (keys %channels) {
!         my %channel = ('id'           => channel_id($_), 
!                        'display-name' => [[$channels{$_}, $lang]]); 
          $writer->write_channel(\%channel);
      }
--- 305,310 ----
  if ($mode eq 'list-channels') {
      foreach (keys %channels) {
!         my %channel = ('id'           => channel_id($_),
!                        'display-name' => [[$channels{$_}, $lang]]);
          $writer->write_channel(\%channel);
      }
***************
*** 325,332 ****
  foreach(@requests) {
      my $id = channel_id($_);
!     my %channel = ('id'           => $id, 
!                    'display-name' => [[$channels{$_}, $lang]]); 
      $writer->write_channel(\%channel);
!      $paramstr = $paramstr."&channel[]=".$_; 
  
  }
--- 326,333 ----
  foreach(@requests) {
      my $id = channel_id($_);
!     my %channel = ('id'           => $id,
!                    'display-name' => [[$channels{$_}, $lang]]);
      $writer->write_channel(\%channel);
!     $paramstr = $paramstr."&channels[]=".$_;
  
  }
***************
*** 341,350 ****
  my $url=$head->{q(source-data-url)};
  
! 	
! my $ua = LWP::UserAgent->new(keep_alive => 300);	
  $ua->cookie_jar(HTTP::Cookies->new());
  $ua->agent("xmltv/$XMLTV::VERSION");
  $ua->env_proxy;
! 	
  my $req = HTTP::Request->new(POST => $url);
  $req->content_type('application/x-www-form-urlencoded');
--- 342,351 ----
  my $url=$head->{q(source-data-url)};
  
! 
! my $ua = LWP::UserAgent->new(keep_alive => 300);
  $ua->cookie_jar(HTTP::Cookies->new());
  $ua->agent("xmltv/$XMLTV::VERSION");
  $ua->env_proxy;
! 
  my $req = HTTP::Request->new(POST => $url);
  $req->content_type('application/x-www-form-urlencoded');
***************
*** 363,578 ****
  
  ## channel_id($s) :: turn site channel id into an xmltv id
! sub channel_id($) {  
      my $s = shift;
-     #for (my $s = shift) {
-     #$_ = lc(defined($chid_mapping{$_}) ? $chid_mapping{$_} : "$_.search.ch");
- 	#$_ = "C$_" if /^\d/;
- 	#return $_;
-     #}
      $s =~ s|^tv_||;
      return "$s.search.ch"
  }
  
  
  
! sub grab_channels
! {
!  my $grabDate = $grab_start;
!  my $url = $head->{q(source-info-url)};
!  
!  $bar = new XMLTV::ProgressBar('grabbing channels       ', (6*$opt_days))
!   if not $opt_quiet;
  
!  grab_channel_loop:
!  for (my $count = 0; $count < 6; $count++) 
!  {
!   my $tb = HTML::TreeBuilder->new();
  
!   my $loop_date = $grabDate->year() . '-' . substr("0".$grabDate->month(),-2) . '-' . substr("0".$grabDate->day(),-2);
!   my $req = HTTP::Request->new(GET => "$url?time=$loop_date+" . 4*$count .".00");
!   $req->header('Accept' => 'text/html');
!     
!   $tb->parse(($ua->request($req))->content)
!       or die "cannot parse content of http://tv.search.ch/?time=$loop_date+" . 4*$count .".00"; ;    
!   $tb->eof;
  
!   foreach my $tv_channel ( $tb->look_down('_tag' => 'div', 'class' => 'tv_channel') )
!   {
!    my $channel_id = $tv_channel->attr('id');
!    if ( defined($channel_id) )
!    {
!     foreach my $tv_show ( $tv_channel ->look_down('_tag' => 'tr', sub { ($_[0]->as_HTML() =~ m{tv_b_}) && !($_[0]->as_HTML() =~ m{tv_before})  && !($_[0]->as_HTML() =~ m{tv_timegroup}) } ) )
!     {
!      my %show;
!      $show{channel} = channel_id($channel_id);
!      
!      my $tmp = (($tv_show->look_down('_tag', 'td'))[0])->as_text();
!      $show{start} = DateTime->new (
!         year => $grabDate->year()
!        ,month => $grabDate->month() 
!        ,day   => $grabDate->day()
!        ,hour  => substr($tmp,0,2) 
!        ,minute => substr($tmp,3,2)
!        ,second => 00
!        ,time_zone => 'Europe/Zurich'
!       )->strftime( "%Y%m%d%H%M%S %z" );
  
!      $tmp  = $tv_show->as_HTML();
!      if ( $tmp =~ /Untertitel für Gehörlose/)
!      {
!       $show{subtitles} = [{ type => 'teletext' }];
!      }
!      if ( $tmp =~ /Zweikanalton/)
!      {
!       $show{audio}{stereo} = 'bilingual';
!      }
!      if ( $tmp =~ /16:9/)
!      {
!       $show{video}{aspect} = '16:9';
!      }  
!      
!      foreach my $div ( $tv_show->look_down('_tag' => 'div', 
!      		sub {
!      			( defined $_[0]->attr('class') && ( ( $_[0]->attr ('class') eq "tv_tooltip") || ( $_[0]->attr ('class') eq "tv_tr_notooltip" ) ) )
!      		    } )
!      	     )
!      {
!       if ( $div->attr ('class') eq 'tv_tr_notooltip' )
!       {
!              $show{'title'} = [[$div->as_text(), $lang]]; 
!       }
!       else
!       {
!       
!        my $title = (($div->look_down('_tag' => 'td', 'class' => 'title'))->look_down('_tag' => 'h2'))->as_text();
!        my $sub_title = ($div->look_down('_tag' => 'td', 'class' => 'title'))->as_text();
  
!        $sub_title =~ s/\Q$title \E//;
!        if ( "$title" eq "$sub_title" )
!        {
!         $sub_title ="";
!        } 
  
! if($channel_id  =~ /tv_nickch/)
  
!                                 {
  
!     $title =~ m/(.*?)([\s](((\d+\D+)|(\d+))))?$/;
  
!                $title = $1;           # only get first group with the title (there is always content in it)
  
!                 # group 3 matches something like "123", "123B", "123BB" (not yet seen, but taken care of), after a title with a space, and could be prepended to sub_title
  
! }
  
!        foreach  my $year ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Produktionsjahr<\/th>} } ) )
!        {
!         $show{date} =  (($year->look_down('_tag', 'td'))->as_text());        
!        }
!        
!        foreach  my $category ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Kategorie<\/th>} } ) )
! 	   {
!         my $s =  (($category->look_down('_tag', 'td'))->as_text());        
!         my @categories = split(m/\s*[\/]\s*/, $s);
!         foreach ( @categories )
!         {
!          if ( $_ )
!          {
!           push @{$show{category}}, [$_, $lang ];
!          }
!         }
! 	   }
! 	   
! 	   foreach  my $category ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Produktionsinfos<\/th>} } ) )
!        {
!         my $s = (($category->look_down('_tag', 'td'))->as_text());        
!         $s=~ s/\(.*//;
!         my @categories = split(m/\s*[\/,]\s*/, $s);
!         foreach my $category ( @categories )
!         {
!          if ( $category )
!          {
!           my $is_defined = 0;
! 		  foreach ( @{$show{category}} )
! 		  {
! 		    if ("${$_}[0]" eq "$category" )
! 		    {
! 		     $is_defined = 1;
! 		     last;
! 		    }
! 		  }
! 		  if ( $is_defined == 0 )
! 		  {
! 			push @{$show{category}}, [$category, $lang ];
! 		  }		  
!          }
!         }
!        }	   
!        
  
! 	   foreach  my $country ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Produktionsland<\/th>} } ) )
!        {
!         my $s =  (($country->look_down('_tag', 'td'))->as_text());        
!         my @countries = split(m/\s*[\/,]\s*/, $s);
!         foreach ( @countries )
!         {
! 		  push @{$show{country}}, [$_, $lang ];         
!         }
!        }
  
!        my $description =  "";
!        foreach  my $desc ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Beschreibung<\/th>} } ) )
!        {
!         $description = (($desc->look_down('_tag', 'td'))->as_text());
!         $description =~ s/ mehr... / /;
!         $description =~ s/Folge verpasst(.*)voller Länge zum kostenlosen Abruf bereit\.//;
!         
!        }
  
!        foreach  my $cast ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Cast<\/th>} } ) )
!        {
!         my $s = (($cast->look_down('_tag', 'td'))->as_text());        
!         $s=~ s/\(.*//;
!         my @actors = split(m/\s*,\s*/, $s);
!         $show{credits}{actor} = \@actors;
!        }
  
!        foreach my $directors ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Regisseur<\/th>} } ) )
!        {
!         my @directors = split(m/\s*,\s*/, (($directors->look_down('_tag', 'td'))->as_text()));
!         $show{credits}{director} = \@directors;
!        }
  
!        foreach  ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Wiederholung<\/th>} } ) )
!        {
!         $show{'previously-shown'} = {}
!        }
!  
!        foreach my $writers ($div->look_down('_tag' => 'tr', sub { $_[0]->as_HTML() =~ m{<th>Drehbuch<\/th>} } ) )
!        {
!         my @writers = split(m/\s*,\s*/, (($writers->look_down('_tag', 'td'))->as_text()));
!         $show{credits}{writer} = \@writers;
!        }
!        $show{'title'} = [[$title, $lang]]; 
!        $show{'sub-title'} = [[$sub_title, $lang]] if(length($sub_title));
!        $show{desc} = [[ $description, $lang ]] if(length($description));
!       }
!      }
!      $writer->write_programme(\%show); 
  
!     } 
     }
!   }
!   $tb->delete();
!   update $bar if not $opt_quiet;
  
!  }
!  $grabDate = $grabDate->add ( days => 1 );
!  if( DateTime->compare ( $grab_stop, $grabDate ) > 0) 
!  {
!   goto grab_channel_loop;
!  }
!  $bar->finish()
!   unless($opt_quiet);
  }
  
--- 364,553 ----
  
  ## channel_id($s) :: turn site channel id into an xmltv id
! sub channel_id($) {
      my $s = shift;
      $s =~ s|^tv_||;
      return "$s.search.ch"
  }
  
+ sub parse_page {
+     my ($tb, $start_parse_date) = @_;
+     foreach my $tv_channel ( $tb->look_down('class' => 'sl-card tv-index-channel') ) {
+         my $channel_id = substr($tv_channel->attr('id'), 3); # tv-sf1 -> sf1
+         if ( defined($channel_id) ) {
+             foreach my $tv_show ( $tv_channel ->look_down('class' => 'tv-tooltip') ) {
+                 my %show;
+                 $show{channel} = channel_id($channel_id);
  
+                 my $tmp = $tv_show->look_down('_tag', 'a');
+                 next unless defined($tmp);
  
!                 my %params = URI::URL->new($tmp->attr('href'))->query_form();
!                 my $start_date = $params{'start'};
!                 my $end_date = $params{'end'};
!                 next unless defined($start_date);
  
!                 my $show_start = DateTime->new (
!                     year => substr($start_date, 0, 4)
!                     ,month => substr($start_date, 5, 2)
!                     ,day   => substr($start_date, 8, 2)
!                     ,hour  => substr($start_date, 11, 2)
!                     ,minute => substr($start_date, 14, 2)
!                     ,second => substr($start_date, 17, 2)
!                     ,time_zone => 'Europe/Zurich');
!                 $show{start} = $show_start->strftime( "%Y%m%d%H%M%S %z" );
!                 # skip shows starting before the start date to prevent duplicates
!                 next if $show_start < $start_parse_date;
  
!                 $show{stop} = DateTime->new (
!                     year => substr($end_date, 0, 4)
!                     ,month => substr($end_date, 5, 2)
!                     ,day   => substr($end_date, 8, 2)
!                     ,hour  => substr($end_date, 11, 2)
!                     ,minute => substr($end_date, 14, 2)
!                     ,second => substr($end_date, 17, 2)
!                     ,time_zone => 'Europe/Zurich'
!                 )->strftime( "%Y%m%d%H%M%S %z" );
  
!                 my $title_tag = $tv_show->look_down('_tag' => 'h2');
!                 $title_tag->objectify_text();
!                 my $title = $title_tag->look_down('_tag', '~text')->attr('text');
!                 $show{'title'} = [[$title, $lang]];
  
!                 my $sub_title = $tv_show->look_down('_tag' => 'h3');
!                 $show{'sub-title'} = [[$sub_title->as_text(), $lang]] if($sub_title);
  
!                 # Note: The layout is using dl lists for displaying this data
!                 # and only the dt tag is marked with meaningful classes. That's
!                 # why $variable->right()-as_text() is employed here to get the
!                 # content of the  unmarked dd tag.
  
!                 # Beschreibung
!                 foreach my $description ($tv_show->look_down('class' => 'tv-detail-description')) {
!                     $show{desc} = [[ $description->right()->as_text(), $lang ]]
!                 }
  
!                 # Produktionsjahr
!                 foreach my $year ($tv_show->look_down('class' => 'tv-detail-year tv-detail-short')) {
!                     $show{date} = $year->right()->as_text();
!                 }
  
!                 # Kategorie
!                 foreach my $category ($tv_show->look_down('class' => 'tv-detail-catname tv-detail-short')) {
!                     my $s = $category->right()->as_text();
!                     my @categories = split(m/\s*[\/]\s*/, $s);
!                     foreach  (@categories) {
!                         push @{$show{category}}, [$_, $lang ] if ($_)
!                     }
!                 }
  
!                 # Produktionsinfos
!                 foreach my $category ($tv_show->look_down('class' => 'tv-detail-production tv-detail-short')) {
!                     my $s = $category->right()->as_text();
!                     $s=~ s/\(.*//;
!                     my @categories = split(m/\s*[\/,]\s*/, $s);
!                     foreach my $category (@categories) {
!                         if ($category) {
!                             my $is_defined = 0;
!                             foreach ( @{$show{category}} ) {
!                                 if ("${$_}[0]" eq "$category" ) {
!                                     $is_defined = 1;
!                                     last;
!                                 }
!                             }
!                             push @{$show{category}}, [$category, $lang ] if ($is_defined == 0);
!                         }
!                     }
!                 }
  
!                 # Produktionsland
!                 foreach my $country ($tv_show->look_down('class' => 'tv-detail-country tv-detail-short')) {
!                     my @countries = split(m/\s*[\/,]\s*/, $country->right()->as_text());
!                     foreach (@countries) {
!                         push @{$show{country}}, [$_, $lang ];
!                     }
!                 }
  
!                 # Cast
!                 foreach my $cast ($tv_show->look_down('class' => 'tv-detail-cast')) {
!                     my $s = $cast->right()->as_text();
!                     $s=~ s/\(.*//;
!                     my @actors = split(m/\s*,\s*/, $s);
!                     $show{credits}{actor} = \@actors;
!                 }
  
!                 # Regisseur
!                 foreach my $directors ($tv_show->look_down('class' => 'tv-detail-director tv-detail-short')) {
!                     my @directors = split(m/\s*,\s*/, $directors->right()->as_text());
!                     $show{credits}{director} = \@directors;
!                 }
  
!                 # Drehbuch
!                 foreach my $writers ($tv_show->look_down('class' => 'tv-detail-writer tv-detail-short')) {
!                     my @writers = split(m/\s*,\s*/, $writers->right()->as_text());
!                     $show{credits}{writer} = \@writers;
!                 }
  
!                 # Wiederholung
!                 foreach my $previously_shown ($tv_show->look_down('class' => 'tv-detail-repetition')) {
!                     $show{'previously-shown'} = {}
!                 }
  
!                 # Episode
!                 foreach my $episode ($tv_show->look_down('class' => 'tv-detail-episode tv-detail-short')) {
!                     $show{'episode-num'} = [[ $episode->right()->as_text(), 'onscreen' ]]
!                 }
  
!                 # Untertitel für Gehörlose
!                 foreach my $deaf ($tv_show->look_down('_tag' => 'img', 'title' => encode("utf-8", "Untertitel für Gehörlose"))) {
!                     $show{subtitles} = [{ type => 'teletext' }];
!                 }
  
!                 # Zweikanalton
!                 foreach my $bilingual ($tv_show->look_down('_tag' => 'img', 'title' => 'Zweikanalton')) {
!                     $show{audio}{stereo} = 'bilingual';
!                 }
  
!                 # 16:9
!                 foreach my $aspect ($tv_show->look_down('_tag' => 'img', 'title' => '16:9')) {
!                     $show{video}{aspect} = '16:9';
!                 }
! 
!                 $writer->write_programme(\%show);
!            }
!        }
     }
! }
  
! sub grab_channels {
!     my $grabDate = $grab_start;
!     my $url = $head->{q(source-info-url)};
! 
!     $bar = new XMLTV::ProgressBar('grabbing channels       ', (6*$opt_days))
!     if not $opt_quiet;
! 
!     grab_channel_loop:
!     for (my $count = 0; $count < 6; $count++) {
!         my $tb = HTML::TreeBuilder->new();
! 
!         my $loop_date = $grabDate->year() . '-' . substr("0".$grabDate->month(),-2) . '-' . substr("0".$grabDate->day(),-2);
!         my $req = HTTP::Request->new(GET => "$url?time=$loop_date+" . 4*$count .".00");
!         $req->header('Accept' => 'text/html');
! 
!         $tb->ignore_unknown(0); # otherwise, html5 tags like section are stripped out
!         $tb->parse(($ua->request($req))->content)
!             or die "cannot parse content of http://tv.search.ch/?time=$loop_date+" . 4*$count .".00";
!         $tb->eof;
! 
!         parse_page($tb, $grabDate->clone()->set_hour(4*$count));
! 
!         $tb->delete();
!         update $bar if not $opt_quiet;
!     }
!     $grabDate = $grabDate->add ( days => 1 );
!     if( DateTime->compare ( $grab_stop, $grabDate ) > 0) {
!         goto grab_channel_loop;
!     }
!     $bar->finish()
!     unless($opt_quiet);
  }
  
***************
*** 585,617 ****
      my $tb=new HTML::TreeBuilder();
      $tb->parse(get_page($url))
! 	  or die "cannot parse content of $url";    
      $tb->eof;
  
! 	## getting the channels directly selectable
! 	foreach($tb->look_down('_tag' => 'span', 'style' => 'float:right;display:inline' )) {
!         next unless(ref($_) eq "HTML::Element");
          my $channel_name = $_->as_text();
- 	my $id = (((($_->look_up('_tag' => 'div'))[0])->look_down('_tag' => 'input', 'type' => 'checkbox'))[0])->attr('value');
  
!         $channels{uri_escape($id)} = $channel_name;      
      }
      $tb->delete;
  
-     # adding the sky-channels manually... why do these sites _NEVER_ stick to their own design?
-     $channels{uri_escape("skyaction")} = "SKY ACTION";
-     $channels{uri_escape("skycinema")} = "SKY CINEMA";
-     $channels{uri_escape("skycinema1")} = "SKY CINEMA +1";
-     $channels{uri_escape("skycinema24")} = "SKY CINEMA +24";
-     $channels{uri_escape("skycinemahits")} = "SKY CINEMA HITS";
-     $channels{uri_escape("skycomedy")} = "SKY COMEDY";
-     $channels{uri_escape("skyemotion")} = "SKY EMOTION";
-     $channels{uri_escape("skyfussballbundesliga")} = "Sky Fussball Bundesliga";
-     $channels{uri_escape("skykrimi")} = "SKY KRIMI";
-     $channels{uri_escape("skynostalgie")} = "SKY NOSTALGIE";
-     $channels{uri_escape("skyselect")} = "Sky Select";
-     $channels{uri_escape("skysport1")} = "Sky Sport 1";
-     $channels{uri_escape("skysport2")} = "Sky Sport 2";
-     $channels{uri_escape("skysportaustria")} = "SKY SPORT AUSTRIA";
-     $channels{uri_escape("skysporthd")} = "SKY SPORT HD"; 
      return %channels;
  }
--- 560,576 ----
      my $tb=new HTML::TreeBuilder();
      $tb->parse(get_page($url))
!         or die "cannot parse content of $url";
      $tb->eof;
  
!     ## getting the channels directly selectable
!     foreach($tb->look_down('_tag' => 'label')) {
!         my $id = ($_->look_down('_tag' => 'input'))->id; # tv-channel-sf1
!         next unless(substr($id, 0, 10) eq "tv-channel");
          my $channel_name = $_->as_text();
  
!         $channels{uri_escape(substr($id, 11))} = $channel_name;
      }
      $tb->delete;
  
      return %channels;
  }
***************
*** 625,629 ****
  
      local $SIG{__DIE__} = sub { die "\n$url: $_[0]" };
!     
      while($retry < 2) {
          my $got = eval { get_nice($url . ($retry ? "&retry=$retry" : "")); };
--- 584,588 ----
  
      local $SIG{__DIE__} = sub { die "\n$url: $_[0]" };
! 
      while($retry < 2) {
          my $got = eval { get_nice($url . ($retry ? "&retry=$retry" : "")); };

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

_______________________________________________
xmltv-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltv-commit