xmltv/grab/uk_tvguide tv_grab_uk_tvguide,1.18,1.19

Geoff <[email protected]> Sun, 01 Jan 2017 12:56:41 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/uk_tvguide
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23487

Modified Files:
	tv_grab_uk_tvguide 
Log Message:
Fix stop time and film classification which broke after website changed

Index: tv_grab_uk_tvguide
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_tvguide/tv_grab_uk_tvguide,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** tv_grab_uk_tvguide	5 Aug 2016 17:26:56 -0000	1.18
--- tv_grab_uk_tvguide	1 Jan 2017 12:56:39 -0000	1.19
***************
*** 214,218 ****
  					if (@shows) {
  						foreach my $show (@shows) {
! 							#		$show->dump;
  							
  							# are we processing yesterday's schedule? (see above)
--- 214,218 ----
  					if (@shows) {
  						foreach my $show (@shows) {
! 							#	$show->dump;
  							
  							# are we processing yesterday's schedule? (see above)
***************
*** 319,339 ****
  								
  									
! 									# removed after site changed 2014-11-26
! 									if (0) {  my ($treespans);
  									
! 								#	rating 		i.e. "Certificate"
! 								my $showcertificate = $treespans->look_down('_tag' => 'span', 'class' => 'tvchannel', sub { $_[0]->as_text =~ /Certificate/ } );
! 								if ($showcertificate) {
! 									$showcertificate = $showcertificate->right;
! 									if ($showcertificate->tag eq 'span' && $showcertificate->attr('class') eq 'programmetext') {
! 										if ($showcertificate->as_text) {
! 											$prog{'rating'} = [[ $showcertificate->as_text, 'BBFC' ]]
  										}
  									}
- 									$showcertificate->detach;
  								}
  								
  								
! 								# start and stop time (actually an optional DTD element)
  								#		<span class="datetime">10:00am-11:50am <span class=programmetext> (1 hour 50 minutes)</span> Wed 20 Mar</span>
  								# (use the Date provided to avoid issues with the site running from 06:00-06:00)
--- 319,341 ----
  								
  									
! 								# Get the "Left Panel" which contains the programme times and attributes
! 								my $lhs = $showdetail->look_down('_tag' => 'div', 'class' => qr/divLHS-section-2/);
! 
  									
! 								# Get the programme's "attributes" e.g. "Certificate"
! 								if ($lhs) {
! 									my @attrs = $lhs->look_down('_tag' => 'span', 'class' => 'LHS-attribute');
! 									if (@attrs) {
! 										foreach my $attr (@attrs) {
! 											# $attr->dump;
! 											if ( my $showattr = $attr->as_text() ) {												
! 												if ( $showattr =~ /^Certificate\s:\s(.*)\s*$/ ) { $prog{'rating'} = [[ $1, 'BBFC' ]]; }
! 											}
  										}
  									}
  								}
  								
  								
! 								# start time, and stop time (actually an optional DTD element)
  								#		<span class="datetime">10:00am-11:50am <span class=programmetext> (1 hour 50 minutes)</span> Wed 20 Mar</span>
  								# (use the Date provided to avoid issues with the site running from 06:00-06:00)
***************
*** 344,350 ****
  								# 	this makes $showtime->set barf on "invalid local time for date in timezone"
  								#
! 								my $showtimes = $treedetail->look_down('_tag' => 'span', 'class' => 'datetime');
! 								if ($showtimes) {
! 									my ($h, $i, $a, $h2, $i2, $a2, $dt) = $showtimes->as_text =~ /(\d*):(\d*)(am|pm)(?:-(\d*):(\d*)(am|pm))?\s*(?:\(.*\))?\s*(.*)$/;
  									if ($dt && $dt !~ /\D\D\D\s\d\d?\s\D\D\D/) {
  										my @thedt = localtime(time);	# ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
--- 346,359 ----
  								# 	this makes $showtime->set barf on "invalid local time for date in timezone"
  								#
! 								#  1/Jan/17 times are now in the left panel. 'datetime' is used for user comments!
! 								#     my $showtimes = $showdetail->look_down('_tag' => 'span', 'class' => 'datetime');
! 								#  
! 								if ($lhs) {
! 
! 									# Unfortunately the div with the date doesn't have any safe identifier. There are several ways we could remove the
! 									#  cruft from the container but the following, although clunky, is probably the safest
! 									my ($dt, $h, $i, $a, $h2, $i2, $a2) = $lhs->as_text =~ /((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun|Christmas|Boxing Day|New Year).*?)(\d*):(\d*)(am|pm)(?:-(\d*):(\d*)(am|pm))?/;
! 									# print STDERR $dt."\n"; 
! 
  									if ($dt && $dt !~ /\D\D\D\s\d\d?\s\D\D\D/) {
  										my @thedt = localtime(time);	# ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
***************
*** 356,361 ****
  											$dt =~ 'Christmas\s+Day' 		&& do { $dt = '25 Dec '.$yr1; last SWITCH; };
  											$dt =~ 'Boxing\s+Day' 			&& do { $dt = '26 Dec '.$yr1; last SWITCH; };
! 											$dt =~ 'New\s+Years\s+Eve' 	&& do { $dt = '31 Dec '.$yr1; last SWITCH; };
! 											$dt =~ 'New\s+Years\s+Day' 	&& do { $dt = '1 Jan ' .$yr2; last SWITCH; };
  											undef $dt;
  										}
--- 365,370 ----
  											$dt =~ 'Christmas\s+Day' 		&& do { $dt = '25 Dec '.$yr1; last SWITCH; };
  											$dt =~ 'Boxing\s+Day' 			&& do { $dt = '26 Dec '.$yr1; last SWITCH; };
! 											$dt =~ 'New\s+Years\s+Eve' 		&& do { $dt = '31 Dec '.$yr1; last SWITCH; };
! 											$dt =~ 'New\s+Years\s+Day' 		&& do { $dt = '1 Jan ' .$yr2; last SWITCH; };
  											undef $dt;
  										}
***************
*** 391,397 ****
  									}
  								}
! 								
! 									}
! 									
  									
  									undef @lis;
--- 400,404 ----
  									}
  								}
! 														
  									
  									undef @lis;


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot