xmltv/grab/fi/fi/source foxtv.pm, 2.00, 2.01 mtv3.pm, 2.02, 2.03 telkku.pm, 2.02, 2.03 telvis.pm, 2.02, 2.03 yle.pm, 2.01, 2.02

Stefan Becker <[email protected]>
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/fi/fi/source
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23505/grab/fi/fi/source

Modified Files:
	foxtv.pm mtv3.pm telkku.pm telvis.pm yle.pm 
Log Message:
- refactored programmeStartOnly to use programme class
- added support for season/episode number to programme class
- updated foxtv to set season/episode (completes Feature #102)
- fix mtv3 channel list grabbing
- updated test.conf with latest full channel list
- added --test-mode option to check for empty channel/programme list


Index: telkku.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/telkku.pm,v
retrieving revision 2.02
retrieving revision 2.03
diff -C2 -d -r2.02 -r2.03
*** telkku.pm	10 Oct 2012 20:36:30 -0000	2.02
--- telkku.pm	1 Nov 2013 22:55:13 -0000	2.03
***************
*** 169,173 ****
      #  </ul>
      #
!     my $opaque = startProgrammeList();
      if (my $container = $root->look_down("class" => "l-stack programList")) {
        if (my @list = $container->find("li")) {
--- 169,173 ----
      #  </ul>
      #
!     my $opaque = startProgrammeList($id, "fi");
      if (my $container = $root->look_down("class" => "l-stack programList")) {
        if (my @list = $container->find("li")) {
***************
*** 195,201 ****
  
  	      # Only record entry if title isn't empty
! 	      appendProgramme($opaque, $hour, $minute, $title, $category,
! 			      $desc)
! 		if length($title) > 0;
  	    }
  	  }
--- 195,203 ----
  
  	      # Only record entry if title isn't empty
! 	      if (length($title) > 0) {
! 		my $object = appendProgramme($opaque, $hour, $minute, $title);
! 		$object->category($category);
! 		$object->description($desc);
! 	      }
  	    }
  	  }
***************
*** 226,231 ****
      #
      # Convert list to program objects
!     return(convertProgrammeList($opaque, $id, "fi",
! 				$yesterday, $today, $tomorrow));
    }
  
--- 228,232 ----
      #
      # Convert list to program objects
!     return(convertProgrammeList($opaque, $yesterday, $today, $tomorrow));
    }
  

Index: telvis.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/telvis.pm,v
retrieving revision 2.02
retrieving revision 2.03
diff -C2 -d -r2.02 -r2.03
*** telvis.pm	10 Oct 2011 16:38:57 -0000	2.02
--- telvis.pm	1 Nov 2013 22:55:13 -0000	2.03
***************
*** 104,108 ****
      # </div>
      #
!     my $opaque = startProgrammeList();
      if (my $container = $root->look_down("class" => "tm")) {
        if (my @rows = $container->find("tr")) {
--- 104,108 ----
      # </div>
      #
!     my $opaque = startProgrammeList($id, "fi");
      if (my $container = $root->look_down("class" => "tm")) {
        if (my @rows = $container->find("tr")) {
***************
*** 122,127 ****
  
  		# Only record entry if title isn't empty
! 		appendProgramme($opaque, $hour, $minute, $title, undef, $desc)
! 		  if length($title) > 0;
  	      }
  	    }
--- 122,129 ----
  
  		# Only record entry if title isn't empty
! 		if (length($title) > 0) {
! 		  my $object = appendProgramme($opaque, $hour, $minute, $title);
! 		  $object->description($desc);
! 		}
  	      }
  	    }
***************
*** 142,147 ****
      # $tomorrow. That means that the last entry will always be missing as we
      # don't have a stop time for it :-(
!     return(convertProgrammeList($opaque, $id, "fi",
! 				undef, $today, $tomorrow));
    }
  
--- 144,148 ----
      # $tomorrow. That means that the last entry will always be missing as we
      # don't have a stop time for it :-(
!     return(convertProgrammeList($opaque, undef, $today, $tomorrow));
    }
  

Index: foxtv.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/foxtv.pm,v
retrieving revision 2.00
retrieving revision 2.01
diff -C2 -d -r2.00 -r2.01
*** foxtv.pm	15 Oct 2013 21:01:13 -0000	2.00
--- foxtv.pm	1 Nov 2013 22:55:13 -0000	2.01
***************
*** 22,25 ****
--- 22,28 ----
  fi::programmeStartOnly->import();
  
+ # Cleanup filter regexes
+ my $cleanup_match = qr/\s*(?:\d+\.\s+Kausi\.\s+)?(?:Kausi\s+\d+\.\s+)?(?:Osa|Jakso)\s+\d+\.\s*/i;
+ 
  # Description
  sub description { 'foxtv.fi' }
***************
*** 92,96 ****
    my $root = fetchTree($url);
    if ($root) {
!     my $opaque = startProgrammeList();
  
      #
--- 95,99 ----
    my $root = fetchTree($url);
    if ($root) {
!     my $opaque = startProgrammeList($id, "fi");
  
      #
***************
*** 154,160 ****
  		$desc  = $desc->as_text();
  
- 		# Description can be empty or "-"
- 		undef $desc if ($desc eq '') || ($desc eq '-');
- 
  		# Season, episode number & episode name (optional)
  		($season)         = ($season->as_text() =~ /(\d+)/)
--- 157,160 ----
***************
*** 162,168 ****
  		($episode_number) = ($episode_number->as_text() =~ /(\d+)/)
  		  if $episode_number;
! 		($episode_name)   = ($episode_name->as_text() =~ /^\s*(.+)\s*$/)
  		  if $episode_name;
  
  		debug(3, "List entry fox ($hour:$minute) $title");
  		debug(4, $episode_name) if defined $episode_name;
--- 162,187 ----
  		($episode_number) = ($episode_number->as_text() =~ /(\d+)/)
  		  if $episode_number;
! 		($episode_name)   = ($episode_name->as_text() =~ /^\s*(.+)$/)
  		  if $episode_name;
  
+ 		# Cleanup some of the most common inconsistencies....
+ 		$desc =~ s/^$cleanup_match//o
+ 		  if defined($desc);
+ 		if (defined($episode_name)) {
+ 		  $episode_name =~ s/$cleanup_match//o;
+ 		  $episode_name =~ s/\s+$//;
+ 		  if (defined($desc)) {
+ 		    # Strip optional parental guidance to improve following match
+ 		    my $tmp;
+ 		    ($tmp = $episode_name) =~ s/\s+\((?:\d+|S)\)$//;
+ 		    $desc =~ s/^$tmp\.\s+//;
+ 		  }
+ 		}
+ 
+ 		# Description can be empty or "-"
+ 		undef $desc if ($desc eq '') || ($desc eq '-');
+ 		undef $episode_name
+ 		  if defined($episode_name) && ($episode_name eq '');
+ 
  		debug(3, "List entry fox ($hour:$minute) $title");
  		debug(4, $episode_name) if defined $episode_name;
***************
*** 171,175 ****
  		  if (defined($season) && defined($episode_number));
  
! 		appendProgramme($opaque, $hour, $minute, $title, undef, $desc);
  	      }
  	    }
--- 190,197 ----
  		  if (defined($season) && defined($episode_number));
  
! 		my $object = appendProgramme($opaque, $hour, $minute, $title);
! 		$object->description($desc);
! 		$object->episode($episode_name, "fi");
! 		$object->season_episode($season, $episode_number);
  	      }
  	    }
***************
*** 179,183 ****
  	  if ($first_tomorrow) {
  	    my($hour, $minute) = _start($first_tomorrow);
! 	    appendProgramme($opaque, $hour, $minute, "DUMMY", undef, undef)
  	      if ($hour && $minute);
  	  }
--- 201,205 ----
  	  if ($first_tomorrow) {
  	    my($hour, $minute) = _start($first_tomorrow);
! 	    appendProgramme($opaque, $hour, $minute, "DUMMY")
  	      if ($hour && $minute);
  	  }
***************
*** 198,202 ****
      # as a DUMMY program. This works for Monday to Saturday, but not for
      # Sunday :-(
!     return(convertProgrammeList($opaque, $id, "fi", undef, $today, $tomorrow));
    }
  
--- 220,224 ----
      # as a DUMMY program. This works for Monday to Saturday, but not for
      # Sunday :-(
!     return(convertProgrammeList($opaque, undef, $today, $tomorrow));
    }
  

Index: yle.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/yle.pm,v
retrieving revision 2.01
retrieving revision 2.02
diff -C2 -d -r2.01 -r2.02
*** yle.pm	10 Oct 2011 16:38:57 -0000	2.01
--- yle.pm	1 Nov 2013 22:55:13 -0000	2.02
***************
*** 167,171 ****
      #   overlapping programme entries. We only use it for the last entry.
      #
!     my $opaque = startProgrammeList();
      if (my @programmes = $root->look_down("class" => qr/^programme\s+/)) {
        my($last_hour, $last_minute);
--- 167,171 ----
      #   overlapping programme entries. We only use it for the last entry.
      #
!     my $opaque = startProgrammeList($id, $code);
      if (my @programmes = $root->look_down("class" => qr/^programme\s+/)) {
        my($last_hour, $last_minute);
***************
*** 202,206 ****
  
  	    # Add programme
! 	    appendProgramme($opaque, $hour, $minute, $title, $category, $desc);
  	  }
  	}
--- 202,208 ----
  
  	    # Add programme
! 	    my $object = appendProgramme($opaque, $hour, $minute, $title);
! 	    $object->category($category);
! 	    $object->description($desc);
  	  }
  	}
***************
*** 210,214 ****
        # Check for special case "24:00"
        appendProgramme($opaque, $last_hour == 24 ? 0 : $last_hour,
! 		      $last_minute, "", undef, undef)
  	if defined $last_hour;
      }
--- 212,216 ----
        # Check for special case "24:00"
        appendProgramme($opaque, $last_hour == 24 ? 0 : $last_hour,
! 		      $last_minute, "DUMMY")
  	if defined $last_hour;
      }
***************
*** 219,224 ****
      # Convert list to program objects
      # First entry always starts $today -> don't use $yesterday
!     return(convertProgrammeList($opaque, $id, $code,
! 				undef, $today, $tomorrow));
    }
  
--- 221,225 ----
      # Convert list to program objects
      # First entry always starts $today -> don't use $yesterday
!     return(convertProgrammeList($opaque, undef, $today, $tomorrow));
    }
  

Index: mtv3.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/mtv3.pm,v
retrieving revision 2.02
retrieving revision 2.03
diff -C2 -d -r2.02 -r2.03
*** mtv3.pm	6 May 2012 15:08:03 -0000	2.02
--- mtv3.pm	1 Nov 2013 22:55:13 -0000	2.03
***************
*** 24,27 ****
--- 24,74 ----
  sub description { 'mtv3.fi' }
  
+ # Grab channels from one group page
+ sub _get_channels($$) {
+   my($channels, $page) = @_;
+ 
+   # Fetch & parse HTML
+   my $root = fetchTree("http://www.mtv3.fi/tvopas/${page}.shtml", "iso-8859-1");
+   if ($root) {
+ 
+     #
+     # Channel name & order can be found from the headers in this table:
+     #
+     #  <table cellspacing="0" cellpadding="0" border="0" class="ohjelmisto" id="ohjelmisto">
+     #   <tr>
+     #    <th width="17%"><div title="MTV3 Leffa" class="channel-logo channel-mtv3-leffa">MTV3 Leffa</div></th>
+     #    <th width="17%"><div title="C More First" class="channel-logo channel-cmore-first">C More First</div></th>
+     #    ...
+     #   </tr>
+     #   ...
+     #  </table>
+     #
+     if (my $container = $root->look_down("class" => "ohjelmisto")) {
+       if ((my @headers = $container->find("th")) &&
+ 	  (my @entries = $container->find("td"))) {
+ 
+         if (@entries >= @headers) {
+ 	  my $count = 0;
+ 
+ 	  debug(2, "Source mtv3.fi found " . scalar(@headers) . " channels in group ${page}");
+ 	  foreach my $option (@headers) {
+ 	    my $name  = $option->as_text();
+ 	    my $class = $entries[$count++]->attr("class");
+ 
+ 	    if (length($name) && defined($class) &&
+ 		(my($index) = ($class =~ /^kanava(\d+)$/))) {
+ 	      debug(3, "channel '$name' (${index}.${page})");
+ 	      $channels->{"${index}.${page}.mtv3.fi"} = "fi $name";
+ 	    }
+ 	  }
+ 	}
+       }
+     }
+ 
+     # Done with the HTML tree
+     $root->delete();
+   }
+ }
+ 
  # Grab channel list
  sub channels {
***************
*** 43,68 ****
      # </select>
      #
      if (my $container = $root->look_down("onchange" => qr/^window.open/)) {
        if (my @options = $container->find("option")) {
! 	my $count;
! 	my $oldpage = "";
  
  	debug(2, "Source mtv3.fi found " . scalar(@options) . " channels");
  	foreach my $option (@options) {
! 	  my $id   = $option->attr("value");
! 	  my $name = $option->as_text();
  
  	  if (defined($id) &&
! 	      (my($page) = ($id =~ m,^/tvopas/(\w+)\.shtml$,)) &&
! 	      length($name)) {
! 	    if ($page ne $oldpage) {
! 	      $count   = 0;
! 	      $oldpage = $page;
! 	    }
! 	    $count++;
! 	    debug(3, "channel '$name' (${count}.${page})");
! 	    $channels{"${count}.${page}.mtv3.fi"} = "fi $name";
  	  }
  	}
        }
      }
--- 90,110 ----
      # </select>
      #
+     # Unfortunately they are not in the correct order
+     #
      if (my $container = $root->look_down("onchange" => qr/^window.open/)) {
        if (my @options = $container->find("option")) {
! 	my %pages;
  
  	debug(2, "Source mtv3.fi found " . scalar(@options) . " channels");
  	foreach my $option (@options) {
! 	  my $id = $option->attr("value");
  
  	  if (defined($id) &&
! 	      (my($page) = ($id =~ m,^/tvopas/(\w+)\.shtml$,))) {
! 	    $pages{$page}++;
  	  }
  	}
+ 	debug(2, "Source mtv3.fi found " . scalar(keys %pages) . " groups");
+ 	_get_channels(\%channels, $_) foreach (keys %pages);
        }
      }
***************
*** 143,147 ****
  		$start   = _toEpoch($day, $start);
  		my $stop = _toEpoch($day, $end);
! 		if ($stop < $start) {
  		  $day  = $tomorrow;
  		  $stop = _toEpoch($day, $end);
--- 185,190 ----
  		$start   = _toEpoch($day, $start);
  		my $stop = _toEpoch($day, $end);
! 		# Sanity check: prevent day change on the first entry
! 		if (@objects && ($stop < $start)) {
  		  $day  = $tomorrow;
  		  $stop = _toEpoch($day, $end);


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.