xmltv/grab/fr tv_grab_fr,1.104,1.105

Nick Morrott <[email protected]> Fri, 07 Aug 2015 00:47:04 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/fr
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11457/grab/fr

Modified Files:
	tv_grab_fr 
Log Message:
Remove trailing whitespace

Index: tv_grab_fr
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fr/tv_grab_fr,v
retrieving revision 1.104
retrieving revision 1.105
diff -C2 -d -r1.104 -r1.105
*** tv_grab_fr	7 Aug 2015 00:29:22 -0000	1.104
--- tv_grab_fr	7 Aug 2015 00:47:02 -0000	1.105
***************
*** 10,27 ****
  =head1 SYNOPSIS
  
!  To configure: 
     tv_grab_fr --configure [--config-file FILE] [--gui OPTION]
!  To configure AUTRES CHAINES list: 
     tv_grab_fr --configure-more-channels
!  To grab listings: 
!    tv_grab_fr [--config-file FILE] [--output FILE] [--days N] 
      [--offset N] [--quiet] [--debug]
   To list available channels:
     tv_grab_fr --list-channels
!  To show capabilities: 
     tv_grab_fr --capabilities
!  To show version:  
     tv_grab_fr --version
!  Help: 
     tv_grab_fr --help
  
--- 10,27 ----
  =head1 SYNOPSIS
  
!  To configure:
     tv_grab_fr --configure [--config-file FILE] [--gui OPTION]
!  To configure AUTRES CHAINES list:
     tv_grab_fr --configure-more-channels
!  To grab listings:
!    tv_grab_fr [--config-file FILE] [--output FILE] [--days N]
      [--offset N] [--quiet] [--debug]
   To list available channels:
     tv_grab_fr --list-channels
!  To show capabilities:
     tv_grab_fr --capabilities
!  To show version:
     tv_grab_fr --version
!  Help:
     tv_grab_fr --help
  
***************
*** 37,47 ****
  
  B<--configure-more-channels> Use this option to create AUTRES CHAINES list.
! This allows grabbing listings for some channels that are not listed  in the 
! bouquets on the website. For more information and a list of channels see 
  L<http://www.lahiette.com/biboobox/forum/viewtopic.php?t=1842>.
  
  B<--list-channels> List available channels for chosen bouquets.
  
! B<--config-file FILE> Use FILE as config file instead of the default config 
  file. This allows one to have different config files for i.e. different apps.
  
--- 37,47 ----
  
  B<--configure-more-channels> Use this option to create AUTRES CHAINES list.
! This allows grabbing listings for some channels that are not listed  in the
! bouquets on the website. For more information and a list of channels see
  L<http://www.lahiette.com/biboobox/forum/viewtopic.php?t=1842>.
  
  B<--list-channels> List available channels for chosen bouquets.
  
! B<--config-file FILE> Use FILE as config file instead of the default config
  file. This allows one to have different config files for i.e. different apps.
  
***************
*** 130,134 ****
  use XMLTV::Config_file;
  use XMLTV::DST;
! use XMLTV::Get_nice qw(get_nice); 
  $XMLTV::Get_nice::ua->parse_head(0);
  $XMLTV::Get_nice::FailOnError = 0;
--- 130,134 ----
  use XMLTV::Config_file;
  use XMLTV::DST;
! use XMLTV::Get_nice qw(get_nice);
  $XMLTV::Get_nice::ua->parse_head(0);
  $XMLTV::Get_nice::FailOnError = 0;
***************
*** 217,221 ****
  die 'Cannot get more than one day before current day' if (defined $opt_offset && $opt_offset < -1);
  die 'Error: You cannot specify --quiet with --debug, exiting' if ($opt_quiet && $opt_debug);
!     
  usage(1) if $opt_help;
  
--- 217,221 ----
  die 'Cannot get more than one day before current day' if (defined $opt_offset && $opt_offset < -1);
  die 'Error: You cannot specify --quiet with --debug, exiting' if ($opt_quiet && $opt_debug);
! 
  usage(1) if $opt_help;
  
***************
*** 352,356 ****
      if ( (scalar keys  %morechannels) > 0 ) {
          $input_file_notempty= 1;
!     } 
      my $choice = "";
      my ($chid, $chname, $chicon);
--- 352,356 ----
      if ( (scalar keys  %morechannels) > 0 ) {
          $input_file_notempty= 1;
!     }
      my $choice = "";
      my ($chid, $chname, $chicon);
***************
*** 385,389 ****
                  say ("Channel $chname removed");
              } else {
!                 say("Channel $chid does not exist in the list");  
              }
          }
--- 385,389 ----
                  say ("Channel $chname removed");
              } else {
!                 say("Channel $chid does not exist in the list");
              }
          }
***************
*** 410,414 ****
              $choice = "exit";
          }
!     } 
      say("Finished configuration for OTHERCHANNELS.");
      exit();
--- 410,414 ----
              $choice = "exit";
          }
!     }
      say("Finished configuration for OTHERCHANNELS.");
      exit();
***************
*** 448,452 ****
  if ($mode eq 'list-channels') {
      # Get a list of all available channels, for all grid types
!     # 
      # Unlike channel configuration in --configure, we do not ask the user
      # for any input to select grid types, we list everything
--- 448,452 ----
  if ($mode eq 'list-channels') {
      # Get a list of all available channels, for all grid types
!     #
      # Unlike channel configuration in --configure, we do not ask the user
      # for any input to select grid types, we list everything
***************
*** 487,491 ****
      next if not defined;
  
!     # Here we store the channel name with the ID in the config file, as 
      # XMLTV id = Website ID
      if (/^channel:?\s+(\S+)\s+([^\#]+);([^\#]+)/) {
--- 487,491 ----
      next if not defined;
  
!     # Here we store the channel name with the ID in the config file, as
      # XMLTV id = Website ID
      if (/^channel:?\s+(\S+)\s+([^\#]+);([^\#]+)/) {
***************
*** 517,522 ****
      my $i;
      my $dayoff;
!     $writer->write_channel({ id => $xmltvid, 
!                              'display-name' => [[encode_utf8( $chname )]], 
                               'icon' => [{src=>$channels{$ind}{icon}}] });
      debug_print("\n  <channel>: xmltvid=$xmltvid, name=$chname, icon=$channels{$ind}{icon}");
--- 517,522 ----
      my $i;
      my $dayoff;
!     $writer->write_channel({ id => $xmltvid,
!                              'display-name' => [[encode_utf8( $chname )]],
                               'icon' => [{src=>$channels{$ind}{icon}}] });
      debug_print("\n  <channel>: xmltvid=$xmltvid, name=$chname, icon=$channels{$ind}{icon}");
***************
*** 530,534 ****
          debug_print( "    adding: url=$url, chid=$chid, i=$i" );
      }
! }    
  
  my $bar = new XMLTV::ProgressBar('getting listings', scalar @to_get) if not $opt_quiet;
--- 530,534 ----
          debug_print( "    adding: url=$url, chid=$chid, i=$i" );
      }
! }
  
  my $bar = new XMLTV::ProgressBar('getting listings', scalar @to_get) if not $opt_quiet;
***************
*** 536,540 ****
  # Hash to track processed programmes by programme ID
  my %processed;
!   
  debug_print("\nProcessing list of pages to grab...\n");
  foreach (@to_get) {
--- 536,540 ----
  # Hash to track processed programmes by programme ID
  my %processed;
! 
  debug_print("\nProcessing list of pages to grab...\n");
  foreach (@to_get) {
***************
*** 558,563 ****
  # Process a page of listings for a particular channel on a particular day,
  # based on the given url. The page is designed as a grid of program cells,
! # arranged in 6 rows (tables) of 4hrs each (4h-8h, 8h-12h, ...., 0h-4h). 
! # Each of these tables is processed in via process_program_table() when 
  # identified to extract the programmes contained therein
  #
--- 558,563 ----
  # Process a page of listings for a particular channel on a particular day,
  # based on the given url. The page is designed as a grid of program cells,
! # arranged in 6 rows (tables) of 4hrs each (4h-8h, 8h-12h, ...., 0h-4h).
! # Each of these tables is processed in via process_program_table() when
  # identified to extract the programmes contained therein
  #
***************
*** 572,576 ****
          return;
      }
!     
      # Reset some working variables
      my ($day, $month, $year) = 0;
--- 572,576 ----
          return;
      }
! 
      # Reset some working variables
      my ($day, $month, $year) = 0;
***************
*** 598,607 ****
          process_program_table( $writer, $chid, $tbl_prog, $dateindex);
      }
!     
      $t->delete(); undef $t;
  }
  
  # Process a table of programme cells from the channel grid page. Each cell
! # contains basic information which is extracted and a link to a dedicated 
  # page of more detailed information for the programme which is processed
  # via process_prog_details_page()
--- 598,607 ----
          process_program_table( $writer, $chid, $tbl_prog, $dateindex);
      }
! 
      $t->delete(); undef $t;
  }
  
  # Process a table of programme cells from the channel grid page. Each cell
! # contains basic information which is extracted and a link to a dedicated
  # page of more detailed information for the programme which is processed
  # via process_prog_details_page()
***************
*** 610,614 ****
      my ($writer, $chid, $myrow, $dateindex) = @_;
      debug_print("      process_program_table: chid=$chid, dateindex=$dateindex");
!     
      # Each show is described in a table cell with one of several class values:
      #
--- 610,614 ----
      my ($writer, $chid, $myrow, $dateindex) = @_;
      debug_print("      process_program_table: chid=$chid, dateindex=$dateindex");
! 
      # Each show is described in a table cell with one of several class values:
      #
***************
*** 627,631 ****
          # - If the cell is wide enough, the link is appplied to the programme title text
          #   and the start time of the programme is also shown (class = hour)
!         # - If the cell is very narrow (<20min), no text is displayed and 
          #   instead a small icon is displayed
          # - An onmouseover attribute for the link contains useful program details that are
--- 627,631 ----
          # - If the cell is wide enough, the link is appplied to the programme title text
          #   and the start time of the programme is also shown (class = hour)
!         # - If the cell is very narrow (<20min), no text is displayed and
          #   instead a small icon is displayed
          # - An onmouseover attribute for the link contains useful program details that are
***************
*** 633,637 ****
          # - Programme icons may also be displayed - these are also linked to the
          #   detailed description for the programme
!         # - If no information is available for part of a 4hr block, the cell can contain 
          #   a cell with the text 'Pas de programme'
          # - If there are no programmes at all in the 4hr block, there will be no
--- 633,637 ----
          # - Programme icons may also be displayed - these are also linked to the
          #   detailed description for the programme
!         # - If no information is available for part of a 4hr block, the cell can contain
          #   a cell with the text 'Pas de programme'
          # - If there are no programmes at all in the 4hr block, there will be no
***************
*** 642,646 ****
          next if (!$link);
  
!         # Each showing has a unique ID present in the url. Extract this and 
          # use it to avoid reprocessing duplicate cells
          my ($prog_url, $prog_id);
--- 642,646 ----
          next if (!$link);
  
!         # Each showing has a unique ID present in the url. Extract this and
          # use it to avoid reprocessing duplicate cells
          my ($prog_url, $prog_id);
***************
*** 690,694 ****
          debug_print("        Initial start date/time: '" . $start . "'");
          debug_print("        Initial stop  date/time: '" . $stop  . "'");
!         
          # Initial check to see if start time is later than stop time. This
          # can indicate that a programme is straddling midnight.
--- 690,694 ----
          debug_print("        Initial start date/time: '" . $start . "'");
          debug_print("        Initial stop  date/time: '" . $stop  . "'");
! 
          # Initial check to see if start time is later than stop time. This
          # can indicate that a programme is straddling midnight.
***************
*** 697,705 ****
              die 'could not add one day to stop time' if not $stop;
          }
!         
          # Now set the proper timezone (WT/ST) according to current date
          die if not $start; die if not $stop;
          # Do not apply utc_offset until we are happy timings are correct
!         
          debug_print("        Creating programme hash for '" . $title . " / " . $start . " " . $stop);
          my %prog = (channel => "C".$chid.".telepoche.com",
--- 697,705 ----
              die 'could not add one day to stop time' if not $stop;
          }
! 
          # Now set the proper timezone (WT/ST) according to current date
          die if not $start; die if not $stop;
          # Do not apply utc_offset until we are happy timings are correct
! 
          debug_print("        Creating programme hash for '" . $title . " / " . $start . " " . $stop);
          my %prog = (channel => "C".$chid.".telepoche.com",
***************
*** 708,718 ****
                      stop    => $stop,
                     );
!         
          # Process the title sub-title in all cases from the popup title
!         # The text for the <a> tag contains the title without the sub-title 
!         # so we can use that to separate the two. However the text for the <a> 
!         # tag may have been truncated so it fits the slot on the page. Also 
!         # some titles may contain a ' - '. Still the heuristic works very 
!         # well. In addition, sometimes, the title is not present as text, 
          # only with icons notably in case of short programs.
          #
--- 708,718 ----
                      stop    => $stop,
                     );
! 
          # Process the title sub-title in all cases from the popup title
!         # The text for the <a> tag contains the title without the sub-title
!         # so we can use that to separate the two. However the text for the <a>
!         # tag may have been truncated so it fits the slot on the page. Also
!         # some titles may contain a ' - '. Still the heuristic works very
!         # well. In addition, sometimes, the title is not present as text,
          # only with icons notably in case of short programs.
          #
***************
*** 723,727 ****
                  $prog{'title'}     = [ [ encode_utf8( trim($1) ) ] ];
                  $prog{'sub-title'} = [ [ encode_utf8( trim($2) ) ] ];
!             } 
          } else {
              if ($text =~ s/\.\.\.$//) {
--- 723,727 ----
                  $prog{'title'}     = [ [ encode_utf8( trim($1) ) ] ];
                  $prog{'sub-title'} = [ [ encode_utf8( trim($2) ) ] ];
!             }
          } else {
              if ($text =~ s/\.\.\.$//) {
***************
*** 741,745 ****
              my $subgenre;
              ($genre, $subgenre) = split(",", tidy_html($genre) );
!             if (defined $genre && $genre =~ /\w+/) { 
                  $genre = trim($genre);
                  debug_print("        Programme genre:     '" . $genre . "'");
--- 741,745 ----
              my $subgenre;
              ($genre, $subgenre) = split(",", tidy_html($genre) );
!             if (defined $genre && $genre =~ /\w+/) {
                  $genre = trim($genre);
                  debug_print("        Programme genre:     '" . $genre . "'");
***************
*** 749,755 ****
                      debug_print("        Programme sub-genre: '" . $subgenre . "'");
  
!                     $prog{category} = [ [ encode_utf8( lc($genre) ), $LANG ], 
                                          [ encode_utf8( lc($subgenre) ), $LANG ] ];
!                 } 
                  else {
                      $prog{category} = [ [ encode_utf8( lc($genre) ), $LANG ] ];
--- 749,755 ----
                      debug_print("        Programme sub-genre: '" . $subgenre . "'");
  
!                     $prog{category} = [ [ encode_utf8( lc($genre) ), $LANG ],
                                          [ encode_utf8( lc($subgenre) ), $LANG ] ];
!                 }
                  else {
                      $prog{category} = [ [ encode_utf8( lc($genre) ), $LANG ] ];
***************
*** 768,773 ****
          }
  
!         # Get more detailed program information (description, review, 
!         # original title, etc) from programme details page. We can also 
          # use this data to check dates/times etc.
          if ( $link->attr('class') eq 'details' ) {
--- 768,773 ----
          }
  
!         # Get more detailed program information (description, review,
!         # original title, etc) from programme details page. We can also
          # use this data to check dates/times etc.
          if ( $link->attr('class') eq 'details' ) {
***************
*** 846,850 ****
                  $p_year = $3;
                  debug_print("          Programme start date: '".$p_day."/".$p_month."/".$p_year."'");
!             }   
  
              if (trim($td_timings[3]->as_text()) =~ /^Dur.*e\s*:\s*(?:(\d{1,2})h)?\s*(\d{1,2})min/) {
--- 846,850 ----
                  $p_year = $3;
                  debug_print("          Programme start date: '".$p_day."/".$p_month."/".$p_year."'");
!             }
  
              if (trim($td_timings[3]->as_text()) =~ /^Dur.*e\s*:\s*(?:(\d{1,2})h)?\s*(\d{1,2})min/) {
***************
*** 887,891 ****
                  debug_print("          Programme rating description: '" . $text . "'");
                  my $rating;
!                 
                  if ($text =~ /interdit - 10 ans/i) {
                      $rating = "-10";
--- 887,891 ----
                  debug_print("          Programme rating description: '" . $text . "'");
                  my $rating;
! 
                  if ($text =~ /interdit - 10 ans/i) {
                      $rating = "-10";
***************
*** 912,917 ****
          }
          debug_print("");
!         
!         # Process content in third table - programme icon, director, writer 
          if ( my $table_cat = $tdetails->look_down('_tag', 'table', 'width', '298', 'cellpadding', '4') ) {
              debug_print("        Located crew/programme icon table");
--- 912,917 ----
          }
          debug_print("");
! 
!         # Process content in third table - programme icon, director, writer
          if ( my $table_cat = $tdetails->look_down('_tag', 'table', 'width', '298', 'cellpadding', '4') ) {
              debug_print("        Located crew/programme icon table");
***************
*** 956,960 ****
                      my ($c_lang, $c_code) = get_country_code($original_country);
                      if (defined $c_code) {
!                         debug_print("          Programme originated in '" . $original_country 
                                      . "' (country code '" . $c_code . "')");
                          push @{$prog->{country}}, [ encode_utf8( $original_country ), $LANG ];
--- 956,960 ----
                      my ($c_lang, $c_code) = get_country_code($original_country);
                      if (defined $c_code) {
!                         debug_print("          Programme originated in '" . $original_country
                                      . "' (country code '" . $c_code . "')");
                          push @{$prog->{country}}, [ encode_utf8( $original_country ), $LANG ];
***************
*** 962,966 ****
                      }
                      else {
!                         debug_print("          Programme originated in '" . $original_country 
                                      . "' (unknown country code)");
                      }
--- 962,966 ----
                      }
                      else {
!                         debug_print("          Programme originated in '" . $original_country
                                      . "' (unknown country code)");
                      }
***************
*** 977,981 ****
                  my $sibling = $crew->left();
                  next if (!defined $sibling);
!                 
                  # find matching <span> element
                  if (!ref $sibling) {
--- 977,981 ----
                  my $sibling = $crew->left();
                  next if (!defined $sibling);
! 
                  # find matching <span> element
                  if (!ref $sibling) {
***************
*** 985,989 ****
                  }
                  next if ($sibling->attr('_tag') ne "span");
!                 
                  my $job = trim($sibling->as_text());
                  my $name = trim($crew->as_text());
--- 985,989 ----
                  }
                  next if ($sibling->attr('_tag') ne "span");
! 
                  my $job = trim($sibling->as_text());
                  my $name = trim($crew->as_text());
***************
*** 1063,1067 ****
          }
      }
!     
      # $resume is the main description, $histoire is a short summary
      foreach ($resume, $histoire) {
--- 1063,1067 ----
          }
      }
! 
      # $resume is the main description, $histoire is a short summary
      foreach ($resume, $histoire) {
***************
*** 1080,1084 ****
  }
  
! # Return a hash of available channels for a given bouquet. Channels configured 
  # in --configure-more-channels mode are retrieved via get_manual_channels()
  #
--- 1080,1084 ----
  }
  
! # Return a hash of available channels for a given bouquet. Channels configured
  # in --configure-more-channels mode are retrieved via get_manual_channels()
  #
***************
*** 1105,1109 ****
  
      foreach my $cellTree ( $t->look_down( "_tag", "td", "class", "channel" ) ) {
!         my $tag = $cellTree->look_down( "_tag", "a" ); 
          if (defined $tag) {
              my $progurl = $tag->attr('href');
--- 1105,1109 ----
  
      foreach my $cellTree ( $t->look_down( "_tag", "td", "class", "channel" ) ) {
!         my $tag = $cellTree->look_down( "_tag", "a" );
          if (defined $tag) {
              my $progurl = $tag->attr('href');
***************
*** 1129,1133 ****
      if (-e $morechannels_file && ((-s $morechannels_file)>0) ) {
          @morechannels_lines = XMLTV::Config_file::read_lines($morechannels_file);
!     } 
      my %morechannels;
      my ($chid, $chname, $chicon);
--- 1129,1133 ----
      if (-e $morechannels_file && ((-s $morechannels_file)>0) ) {
          @morechannels_lines = XMLTV::Config_file::read_lines($morechannels_file);
!     }
      my %morechannels;
      my ($chid, $chname, $chicon);
***************
*** 1151,1158 ****
  }
  
! # Return the full path of the configuration file used to store 
  # channels configured manually (--configure-more-channels)
  #
! sub get_manual_config_filename() { 
      my $home = $ENV{HOME};
      $home = '.' if not defined $home;
--- 1151,1158 ----
  }
  
! # Return the full path of the configuration file used to store
  # channels configured manually (--configure-more-channels)
  #
! sub get_manual_config_filename() {
      my $home = $ENV{HOME};
      $home = '.' if not defined $home;
***************
*** 1170,1177 ****
      my $today = get_date_ymd();
      my $url = $GRID_BY_CHANNEL_PER_DAY.$chid.'/telepoche/soiree/'.$today;
!     print $chid;  
      # Get the current page
      my $t = get_tree($url);
!     
      debug_print("get_manual_channel_icon(): url = $url\n");
      # Set by default an EMPTY logo
--- 1170,1177 ----
      my $today = get_date_ymd();
      my $url = $GRID_BY_CHANNEL_PER_DAY.$chid.'/telepoche/soiree/'.$today;
!     print $chid;
      # Get the current page
      my $t = get_tree($url);
! 
      debug_print("get_manual_channel_icon(): url = $url\n");
      # Set by default an EMPTY logo
***************
*** 1200,1216 ****
  # Remove leading/trailing whitespace
  #
! sub trim( $ ) {    
      for (my $s = shift) {
          s/^\s*//;
          s/\s*$//;
!         
          return $s;
      }
  }
  
! # Replaces specific HTML entities with text replacements, and then 
  # decodes any remaining entities in the string
  #
! sub tidy_html( $ ) {    
      for (my $s = shift) {
          # handle specific entities
--- 1200,1216 ----
  # Remove leading/trailing whitespace
  #
! sub trim( $ ) {
      for (my $s = shift) {
          s/^\s*//;
          s/\s*$//;
! 
          return $s;
      }
  }
  
! # Replaces specific HTML entities with text replacements, and then
  # decodes any remaining entities in the string
  #
! sub tidy_html( $ ) {
      for (my $s = shift) {
          # handle specific entities
***************
*** 1233,1237 ****
          # decode remaining entities
          decode_entities($s);
!         
          return $s;
      }
--- 1233,1237 ----
          # decode remaining entities
          decode_entities($s);
! 
          return $s;
      }
***************
*** 1245,1249 ****
          $s = trim($s);
          $s = s/\s+(?:avec|et)\s+/, /i;
!         
          return split /(?:\s*,)+\s*/, $s;
      }
--- 1245,1249 ----
          $s = trim($s);
          $s = s/\s+(?:avec|et)\s+/, /i;
! 
          return split /(?:\s*,)+\s*/, $s;
      }
***************
*** 1261,1265 ****
          ++$nbretry;
          return undef if $nbretry > $MAX_RETRY;
!         debug_print("*** Retrying URL: '" . $url 
                  . "' (attempt " . $nbretry . " of " . $MAX_RETRY . ") ***");
      }
--- 1261,1265 ----
          ++$nbretry;
          return undef if $nbretry > $MAX_RETRY;
!         debug_print("*** Retrying URL: '" . $url
                  . "' (attempt " . $nbretry . " of " . $MAX_RETRY . ") ***");
      }
***************
*** 1276,1280 ****
  #   1) the two character language code for a country (given in French)
  #      per ISO 639-1 (http://en.wikipedia.org/wiki/ISO_639-1)
! #   2) the two character country code for a country (given in French) 
  #      per ISO 3166-1 alpha-2 (http://en.wikipedia.org/wiki/ISO_3166-1)
  #
--- 1276,1280 ----
  #   1) the two character language code for a country (given in French)
  #      per ISO 639-1 (http://en.wikipedia.org/wiki/ISO_639-1)
! #   2) the two character country code for a country (given in French)
  #      per ISO 3166-1 alpha-2 (http://en.wikipedia.org/wiki/ISO_3166-1)
  #


------------------------------------------------------------------------------