xmltv/grab/dtv_la tv_grab_dtv_la,1.10,1.11

Nick Morrott <[email protected]> Mon, 14 Mar 2016 20:58:50 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/dtv_la
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4120/grab/dtv_la

Modified Files:
	tv_grab_dtv_la 
Log Message:
Whitespace

Index: tv_grab_dtv_la
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/dtv_la/tv_grab_dtv_la,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** tv_grab_dtv_la	14 Mar 2016 20:53:24 -0000	1.10
--- tv_grab_dtv_la	14 Mar 2016 20:58:48 -0000	1.11
***************
*** 126,130 ****
  #    https://www.sky.com.br/servicos/Guiadatv/GravacaoDistancia.aspx
  #
! #		 the Sky MX site is rubbish
  #    http://www.sky.com.mx/sky/gu%C3%ADa-de-programaci%C3%B3n
  #
--- 126,130 ----
  #    https://www.sky.com.br/servicos/Guiadatv/GravacaoDistancia.aspx
  #
! #    the Sky MX site is rubbish
  #    http://www.sky.com.mx/sky/gu%C3%ADa-de-programaci%C3%B3n
  #
***************
*** 199,203 ****
  
  # Attributes of the root element in output.
! my $HEAD = { 
  			'source-info-url'     => 'http://directstage.directvla.com/',
  			'source-data-url'     => 'http://directstage.directvla.com/',
--- 199,203 ----
  
  # Attributes of the root element in output.
! my $HEAD = {
  			'source-info-url'     => 'http://directstage.directvla.com/',
  			'source-data-url'     => 'http://directstage.directvla.com/',
***************
*** 273,281 ****
  	my $data = shift;
  	my $r;
! 	
  	print STDERR "$method: $url ".($data?"[$data]":'')." \n" if $opt_debug;
! 	
  	# let's not overload the website with too many requests so we'll restrict the request frequency (as per Get_nice)
! 	
  	my $Delay = $opt_max_delay - $opt_min_delay; 	# in seconds
  	my $MinDelay = $opt_min_delay; 					# in seconds
--- 273,281 ----
  	my $data = shift;
  	my $r;
! 
  	print STDERR "$method: $url ".($data?"[$data]":'')." \n" if $opt_debug;
! 
  	# let's not overload the website with too many requests so we'll restrict the request frequency (as per Get_nice)
! 
  	my $Delay = $opt_max_delay - $opt_min_delay; 	# in seconds
  	my $MinDelay = $opt_min_delay; 					# in seconds
***************
*** 289,299 ****
  		sleep $sleep_time if $sleep_time > 0;
  	}
! 	
  	if (!defined $method || lc($method) eq 'get') {
  		$r = $ua->get($url);
! 		
  	} elsif (lc($method) eq 'post') {
  		$r = $ua->post($url, $data);	# $data must be a hash
! 		
  	} elsif (lc($method) eq 'jsonpost') {
  		#
--- 289,299 ----
  		sleep $sleep_time if $sleep_time > 0;
  	}
! 
  	if (!defined $method || lc($method) eq 'get') {
  		$r = $ua->get($url);
! 
  	} elsif (lc($method) eq 'post') {
  		$r = $ua->post($url, $data);	# $data must be a hash
! 
  	} elsif (lc($method) eq 'jsonpost') {
  		#
***************
*** 311,323 ****
  	}
  	$last_get_time = time();
! 	
  	#print STDERR Dumper($r);die;
  	die "Could not fetch $url". (lc($method) eq 'jsonpost'?"[$data]":'') .", error: " . $r->status_line  if ($r->is_error);
! 	
  	my $t;
  	if (lc($method) eq 'jsonpost') {
  		# expect a json reply!
  		$t = JSON::PP->new()->utf8(1)->decode($r->content) or die "cannot parse content of $url\n";
! 	
  	} else {
  		$t = new HTML::TreeBuilder;
--- 311,323 ----
  	}
  	$last_get_time = time();
! 
  	#print STDERR Dumper($r);die;
  	die "Could not fetch $url". (lc($method) eq 'jsonpost'?"[$data]":'') .", error: " . $r->status_line  if ($r->is_error);
! 
  	my $t;
  	if (lc($method) eq 'jsonpost') {
  		# expect a json reply!
  		$t = JSON::PP->new()->utf8(1)->decode($r->content) or die "cannot parse content of $url\n";
! 
  	} else {
  		$t = new HTML::TreeBuilder;
***************
*** 356,362 ****
  			$CHANNELS_URL = $country{url} . 'guia-de-canales';
  		}
! 		
  	}
! 	
  	return $CHANNELS_URL;
  }
--- 356,362 ----
  			$CHANNELS_URL = $country{url} . 'guia-de-canales';
  		}
! 
  	}
! 
  	return $CHANNELS_URL;
  }
***************
*** 369,375 ****
  	##$base_url=~ s/default/detailch/;
  	##return "$base_url?c=$ch_id&n=chname";
! 	
  	# e.g. http://www.directv.com.ar/guia/Services/ProgrammingGuideAjax.asmx/GetProgramming
! 	
  	return $country{'url'} . 'guia/Services/ProgrammingGuideAjax.asmx/GetProgramming';
  }
--- 369,375 ----
  	##$base_url=~ s/default/detailch/;
  	##return "$base_url?c=$ch_id&n=chname";
! 
  	# e.g. http://www.directv.com.ar/guia/Services/ProgrammingGuideAjax.asmx/GetProgramming
! 
  	return $country{'url'} . 'guia/Services/ProgrammingGuideAjax.asmx/GetProgramming';
  }
***************
*** 378,384 ****
  ## Returns the URL for grabbing programme details
  sub get_program_detail_url() {
! 	
  	# e.g. http://www.directv.com.ar/guia/Services/ProgrammingGuideAjax.asmx/GetProgrammingDetail
! 	
  	return $country{'url'} . 'guia/Services/ProgrammingGuideAjax.asmx/GetProgrammingDetail';
  }
--- 378,384 ----
  ## Returns the URL for grabbing programme details
  sub get_program_detail_url() {
! 
  	# e.g. http://www.directv.com.ar/guia/Services/ProgrammingGuideAjax.asmx/GetProgrammingDetail
! 
  	return $country{'url'} . 'guia/Services/ProgrammingGuideAjax.asmx/GetProgrammingDetail';
  }
***************
*** 403,416 ****
  sub get_channel_programs ( $$$$ ) {
  	my ($ref_dates, $ref_channels, $ref_ch_all, $ref_programmes) = @_;
! 	
  	# convert @dates & @channels into hashes for faster searching
  	my %_dates = map { $_ => 1 } @$ref_dates;
  	my %_channels = map { $_ => 1 } @$ref_channels;
! 	
  	my @_ch_all = @$ref_ch_all;
! 	
  	# temporary store for programmes we fetch (used for detecting duplicates and clumps)
  	my $programmes = {};
! 	
  	# for parsing non-English language dates
  	my $lang;
--- 403,416 ----
  sub get_channel_programs ( $$$$ ) {
  	my ($ref_dates, $ref_channels, $ref_ch_all, $ref_programmes) = @_;
! 
  	# convert @dates & @channels into hashes for faster searching
  	my %_dates = map { $_ => 1 } @$ref_dates;
  	my %_channels = map { $_ => 1 } @$ref_channels;
! 
  	my @_ch_all = @$ref_ch_all;
! 
  	# temporary store for programmes we fetch (used for detecting duplicates and clumps)
  	my $programmes = {};
! 
  	# for parsing non-English language dates
  	my $lang;
***************
*** 420,424 ****
  		$lang = Date::Language->new('Spanish');
  	}
! 	
  	# site now uses a jQuery AJAX POST with JSON content in UTF-8
  	# e.g. { "day":19, "time":"12","minute":"30", "month":"4", "year":"2014", "onlyFavorites":"N" }
--- 420,424 ----
  		$lang = Date::Language->new('Spanish');
  	}
! 
  	# site now uses a jQuery AJAX POST with JSON content in UTF-8
  	# e.g. { "day":19, "time":"12","minute":"30", "month":"4", "year":"2014", "onlyFavorites":"N" }
***************
*** 433,455 ****
  			my $data = '{ "day":'.$_d.', "time":"'.$_h.'","minute":"00", "month":"'.$_m.'", "year":"'.$_y.'", "onlyFavorites":"N" }';
  			##print STDERR $data."\n";
! 			
! 	
  			my $json = get_tree( get_channel_programs_url(undef), 'jsonpost', $data );
  			##print STDERR Dumper($json);die;
! 		
  			# response is a JSON string containing just one k:v pair, 'd' => "..."
  			#  (see http://www.directv.com.ar/guia/js/Program-Guide/ProgrammingGuideAjax.js for details)
! 			
  			# we don't need the overhead of TreeBuilder - we'll go 'old school' and use a regexp
  			my (@li) = $json->{'d'} =~ m/(<li.*?<\/li>)/g;
  			##print Dumper(@li);die;
! 			
  			foreach $li (@li) {
! 				
  				# <li id="PG_ctl02_Prog_ctl00_liItem" class="" style="width:267px" eventId="121190335202" channel="121"><a href="javascript:return false;" class="ChannelArrowLeft"></a><span id="PG_ctl02_Prog_ctl00_HDCh" style="padding-left:10px;"><literal id="PG_ctl02_Prog_ctl00_litHDCh">Las aventuras de Robin Hood</literal></span><a href="/guia/RecordBox.aspx?iframe&eventId=121190335202&page=grid" class="Action loginAvailable"></a></li>
  				# <li id="PG_ctl02_Prog_ctl01_liItem" class=" toolTip" style="width:99.5px" title="Enciclopedia digital del cosmos" eventId="121190335203" channel="121"><span id="PG_ctl02_Prog_ctl01_HDCh"><literal id="PG_ctl02_Prog_ctl01_litHDCh">Enciclopedia di...</literal></span><a href="/guia/RecordBox.aspx?iframe&eventId=121190335203&page=grid" class="Action loginAvailable"></a></li>
! 				
  				# <li id="PG_ctl214_Prog_ctl00_liItem" class=" PpvVenezuela toolTip last disabled" style="width:806px" eventid="" channel="1003" original-title="Programación no disponible"><span id="PG_ctl214_Prog_ctl00_HDCh" style="padding-right:10px;" class="HdActive"><literal id="PG_ctl214_Prog_ctl00_litHDCh">Programación no disponible</literal><span id="PG_ctl214_Prog_ctl00_imgIcon" class="3d"></span></span><a href="javascript:return false;" class="ChannelArrowRight"></a><a href="https://www.directv.com.ve/midirectv/PPVBrowse.aspx?language=&amp;section=DOD&amp;film=" class="Action loginAvailable"></a></li>
! 			
  				# Method:
  				# The programme schedule is returned as a 4-hour window. Unfortunately the html contains nothing of use
--- 433,455 ----
  			my $data = '{ "day":'.$_d.', "time":"'.$_h.'","minute":"00", "month":"'.$_m.'", "year":"'.$_y.'", "onlyFavorites":"N" }';
  			##print STDERR $data."\n";
! 
! 
  			my $json = get_tree( get_channel_programs_url(undef), 'jsonpost', $data );
  			##print STDERR Dumper($json);die;
! 
  			# response is a JSON string containing just one k:v pair, 'd' => "..."
  			#  (see http://www.directv.com.ar/guia/js/Program-Guide/ProgrammingGuideAjax.js for details)
! 
  			# we don't need the overhead of TreeBuilder - we'll go 'old school' and use a regexp
  			my (@li) = $json->{'d'} =~ m/(<li.*?<\/li>)/g;
  			##print Dumper(@li);die;
! 
  			foreach $li (@li) {
! 
  				# <li id="PG_ctl02_Prog_ctl00_liItem" class="" style="width:267px" eventId="121190335202" channel="121"><a href="javascript:return false;" class="ChannelArrowLeft"></a><span id="PG_ctl02_Prog_ctl00_HDCh" style="padding-left:10px;"><literal id="PG_ctl02_Prog_ctl00_litHDCh">Las aventuras de Robin Hood</literal></span><a href="/guia/RecordBox.aspx?iframe&eventId=121190335202&page=grid" class="Action loginAvailable"></a></li>
  				# <li id="PG_ctl02_Prog_ctl01_liItem" class=" toolTip" style="width:99.5px" title="Enciclopedia digital del cosmos" eventId="121190335203" channel="121"><span id="PG_ctl02_Prog_ctl01_HDCh"><literal id="PG_ctl02_Prog_ctl01_litHDCh">Enciclopedia di...</literal></span><a href="/guia/RecordBox.aspx?iframe&eventId=121190335203&page=grid" class="Action loginAvailable"></a></li>
! 
  				# <li id="PG_ctl214_Prog_ctl00_liItem" class=" PpvVenezuela toolTip last disabled" style="width:806px" eventid="" channel="1003" original-title="Programación no disponible"><span id="PG_ctl214_Prog_ctl00_HDCh" style="padding-right:10px;" class="HdActive"><literal id="PG_ctl214_Prog_ctl00_litHDCh">Programación no disponible</literal><span id="PG_ctl214_Prog_ctl00_imgIcon" class="3d"></span></span><a href="javascript:return false;" class="ChannelArrowRight"></a><a href="https://www.directv.com.ve/midirectv/PPVBrowse.aspx?language=&amp;section=DOD&amp;film=" class="Action loginAvailable"></a></li>
! 
  				# Method:
  				# The programme schedule is returned as a 4-hour window. Unfortunately the html contains nothing of use
***************
*** 461,465 ****
  				# 5. Parse the prog details and add to a hash
  				#
! 				
  				# parse the <li> element
  				my ( $eventId, $channelId, $hasStarted ) = $li =~ m/eventId="(\d*)"\schannel="(\d*)".*?(?(?=.*ChannelArrowLeft)(ChannelArrowLeft)|())/;
--- 461,465 ----
  				# 5. Parse the prog details and add to a hash
  				#
! 
  				# parse the <li> element
  				my ( $eventId, $channelId, $hasStarted ) = $li =~ m/eventId="(\d*)"\schannel="(\d*)".*?(?(?=.*ChannelArrowLeft)(ChannelArrowLeft)|())/;
***************
*** 467,493 ****
  				next if $hasStarted;						# if prog has already started
  				next if ! $_channels{ $channelId };			# if channel not wanted
! 				next if !defined $eventId || $eventId eq '';# e.g. Programación no disponible (can't output anything since no start/stop time!)				
! 				
  				# post content: { "eventId":121190335202, "day":20, "time":"4","minute":"0", "month":"4", "year":"2014" }
  				my $data = '{ "eventId":'.$eventId.', "day":'.$_d.', "time":"'.$_h.'","minute":"0", "month":"'.$_m.'", "year":"'.$_y.'" }';
! 		
  				my $json = get_tree( get_program_detail_url(), 'jsonpost', $data );
  				##print STDERR Dumper($json);die;
! 				
  				my $t = HTML::TreeBuilder->new()->parse( $json->{'d'} ) or die "cannot parse content of programme detail\n";
  				$t->eof;
  				##$t->dump();die;
! 		
  				my $p;	# programme
! 				
  				my $div;  if ( my $_t = $t->look_down('_tag'=>'h2') ) { $div = $_t->parent(); }
  				if (!defined $div) {
! 					# why is it not? 
  					print STDERR 'Warn: No programme description (no <h2> element for "eventId":'.$eventId.', "day":'.$_d.', "time":"'.$_h.")\n";
  					next;
  				}
! 				
  				my $h;	# html (tree) element
! 				
  				if ( $h = $div->look_down('_tag'=>'h2') ) {
  					if ( my $h_ = $div->look_down('_tag'=>'img', 'alt'=>'HD program') ) {
--- 467,493 ----
  				next if $hasStarted;						# if prog has already started
  				next if ! $_channels{ $channelId };			# if channel not wanted
! 				next if !defined $eventId || $eventId eq '';# e.g. Programación no disponible (can't output anything since no start/stop time!)
! 
  				# post content: { "eventId":121190335202, "day":20, "time":"4","minute":"0", "month":"4", "year":"2014" }
  				my $data = '{ "eventId":'.$eventId.', "day":'.$_d.', "time":"'.$_h.'","minute":"0", "month":"'.$_m.'", "year":"'.$_y.'" }';
! 
  				my $json = get_tree( get_program_detail_url(), 'jsonpost', $data );
  				##print STDERR Dumper($json);die;
! 
  				my $t = HTML::TreeBuilder->new()->parse( $json->{'d'} ) or die "cannot parse content of programme detail\n";
  				$t->eof;
  				##$t->dump();die;
! 
  				my $p;	# programme
! 
  				my $div;  if ( my $_t = $t->look_down('_tag'=>'h2') ) { $div = $_t->parent(); }
  				if (!defined $div) {
! 					# why is it not?
  					print STDERR 'Warn: No programme description (no <h2> element for "eventId":'.$eventId.', "day":'.$_d.', "time":"'.$_h.")\n";
  					next;
  				}
! 
  				my $h;	# html (tree) element
! 
  				if ( $h = $div->look_down('_tag'=>'h2') ) {
  					if ( my $h_ = $div->look_down('_tag'=>'img', 'alt'=>'HD program') ) {
***************
*** 499,503 ****
  				# 'title' is mandatory in the DTD. If we don't have one then set to unknown
  				$p->{'title'} = ($LANG eq 'pt_BR' ? 'ignorado' : 'incógnito') if (!defined $p->{'title'} || $p->{'title'} eq '');
! 				
  
  				# 1st <p> is the description
--- 499,503 ----
  				# 'title' is mandatory in the DTD. If we don't have one then set to unknown
  				$p->{'title'} = ($LANG eq 'pt_BR' ? 'ignorado' : 'incógnito') if (!defined $p->{'title'} || $p->{'title'} eq '');
! 
  
  				# 1st <p> is the description
***************
*** 506,515 ****
  					$h->detach;
  				}
! 		
  				# 2nd <p> is the start time and duration
  				if ( $h = $div->look_down('_tag'=>'p') ) {
  					my $h_ = trim( $h->as_text() );
  					my ($_junk, $_date, $_dur) = $h_ =~ m/(Comienza|Start):\s*(.*?)\|(.*?)$/s;		# Caribe = "Start:"
! 					
  					# Date::Language doesn't currently do Portuguese
  					#  (the Sky BR site isn't handled in this grabber anyway)
--- 506,515 ----
  					$h->detach;
  				}
! 
  				# 2nd <p> is the start time and duration
  				if ( $h = $div->look_down('_tag'=>'p') ) {
  					my $h_ = trim( $h->as_text() );
  					my ($_junk, $_date, $_dur) = $h_ =~ m/(Comienza|Start):\s*(.*?)\|(.*?)$/s;		# Caribe = "Start:"
! 
  					# Date::Language doesn't currently do Portuguese
  					#  (the Sky BR site isn't handled in this grabber anyway)
***************
*** 520,524 ****
  						$dt = $lang->str2time($_date, $TZ);
  					}
! 					
  					$p->{'start_epoch'} = $lang->str2time($_date, $TZ);
  					( $p->{'duration'} ) = $_dur =~ /(\d*)\s(?=minutos|minutes)/;
--- 520,524 ----
  						$dt = $lang->str2time($_date, $TZ);
  					}
! 
  					$p->{'start_epoch'} = $lang->str2time($_date, $TZ);
  					( $p->{'duration'} ) = $_dur =~ /(\d*)\s(?=minutos|minutes)/;
***************
*** 528,532 ****
  					$h->detach;
  				}
! 					
  				# <div> class "Rank" = rating & programme url
  				if ( $h = $div->look_down('_tag'=>'div', 'class'=>qw/Rank/) ) {
--- 528,532 ----
  					$h->detach;
  				}
! 
  				# <div> class "Rank" = rating & programme url
  				if ( $h = $div->look_down('_tag'=>'div', 'class'=>qw/Rank/) ) {
***************
*** 535,539 ****
  						( $p->{'rating'} ) = $h_ =~ m/Rating:\s*(\S*)\s/s;
  					}
! 					
  					if ( my $h = $h->look_down('_tag'=>'div') ) {
  						if ( my $h_ = $h->look_down('_tag'=>'a') ) {
--- 535,539 ----
  						( $p->{'rating'} ) = $h_ =~ m/Rating:\s*(\S*)\s/s;
  					}
! 
  					if ( my $h = $h->look_down('_tag'=>'div') ) {
  						if ( my $h_ = $h->look_down('_tag'=>'a') ) {
***************
*** 545,551 ****
  					$h->detach;
  				}
! 				
! 				
! 				
  				# Reformat the data to Create the data structure for the programme
  				my $p_out = {};
--- 545,551 ----
  					$h->detach;
  				}
! 
! 
! 
  				# Reformat the data to Create the data structure for the programme
  				my $p_out = {};
***************
*** 559,563 ****
  				$p_out->{'url'} 	  	= [ encode($OUT_ENCODING, $p->{'url'}) ]  if (defined $p->{'url'} && $p->{'url'} ne '');
  				$p_out->{'video'} 		= $p->{'video'}  if (defined $p->{'video'});
! 				
  				# store the programme avoiding duplicates
  				# also check for duplicate start times and set clumpidx
--- 559,563 ----
  				$p_out->{'url'} 	  	= [ encode($OUT_ENCODING, $p->{'url'}) ]  if (defined $p->{'url'} && $p->{'url'} ne '');
  				$p_out->{'video'} 		= $p->{'video'}  if (defined $p->{'video'});
! 
  				# store the programme avoiding duplicates
  				# also check for duplicate start times and set clumpidx
***************
*** 569,573 ****
  					}
  					next if $dup;	# ignore duplicates (go to next <li> programme element)
! 					if (!$dup) { 
  						# contemporary programme so set clumpidx
  						my $numclumps = scalar @{ $programmes->{ $channelId }->{ $p->{'start_epoch'} } }  + 1;
--- 569,573 ----
  					}
  					next if $dup;	# ignore duplicates (go to next <li> programme element)
! 					if (!$dup) {
  						# contemporary programme so set clumpidx
  						my $numclumps = scalar @{ $programmes->{ $channelId }->{ $p->{'start_epoch'} } }  + 1;
***************
*** 582,598 ****
  					}
  				}
! 				
  				# store the programme in our temporary store
  				push @{ $programmes->{ $channelId }->{ $p->{'start_epoch'} } }, $p_out;
! 				
  			}
! 			
  			$mainbar->update() if not $opt_quiet;
  		}
! 		
  	}
! 	
! 	
! 	# All data has been gathered. We can now write the programme element to the output. 
  	#
  	foreach ( keys %{$programmes} ) {
--- 582,598 ----
  					}
  				}
! 
  				# store the programme in our temporary store
  				push @{ $programmes->{ $channelId }->{ $p->{'start_epoch'} } }, $p_out;
! 
  			}
! 
  			$mainbar->update() if not $opt_quiet;
  		}
! 
  	}
! 
! 
! 	# All data has been gathered. We can now write the programme element to the output.
  	#
  	foreach ( keys %{$programmes} ) {
***************
*** 622,629 ****
  	# Get channels that are transmiting now
  	my $tree = get_tree($url);
! 	get_channels_from_tree($tree,\%channels); 
  	# We will try to find more channels for later hours
  	#get_channels_for_later_hours($tree,\%channels);
! 	
  	# Finish using Tree
  	$tree=undef;
--- 622,629 ----
  	# Get channels that are transmiting now
  	my $tree = get_tree($url);
! 	get_channels_from_tree($tree,\%channels);
  	# We will try to find more channels for later hours
  	#get_channels_for_later_hours($tree,\%channels);
! 
  	# Finish using Tree
  	$tree=undef;
***************
*** 691,701 ****
  sub get_channels_from_tree( ) {
  	my ($tree,$channels) = @_;
! 	
  	# see if there's a 'pMain' so we can ignore the CMS content (which contains the on-demand channels)
  	my $chan_div = $tree->look_down('_tag' => 'div', 'id' => 'pMain');
  	$tree = $chan_div  if $chan_div;
! 	
  	my @chan_groups = $tree->look_down('_tag' => 'div', 'class' => 'guia-canales')->look_down('_tag' => 'div', 'class' => 'combo-canal-content');
! 	
  	foreach (@chan_groups) {
  		my @chan_elems = $_->look_down('_tag' => 'li');
--- 691,701 ----
  sub get_channels_from_tree( ) {
  	my ($tree,$channels) = @_;
! 
  	# see if there's a 'pMain' so we can ignore the CMS content (which contains the on-demand channels)
  	my $chan_div = $tree->look_down('_tag' => 'div', 'id' => 'pMain');
  	$tree = $chan_div  if $chan_div;
! 
  	my @chan_groups = $tree->look_down('_tag' => 'div', 'class' => 'guia-canales')->look_down('_tag' => 'div', 'class' => 'combo-canal-content');
! 
  	foreach (@chan_groups) {
  		my @chan_elems = $_->look_down('_tag' => 'li');
***************
*** 706,710 ****
  			#	 </a>
  			# </li>
! 			
  			if ( my $chan = $_->look_down('_tag' => 'a') ) {
  				my ($chan_id, $chan_name, $chan_url, %chan_icon) = ('', '', '', ());
--- 706,710 ----
  			#	 </a>
  			# </li>
! 
  			if ( my $chan = $_->look_down('_tag' => 'a') ) {
  				my ($chan_id, $chan_name, $chan_url, %chan_icon) = ('', '', '', ());
***************
*** 731,735 ****
  		}
  	}
! 	
  }
  
--- 731,735 ----
  		}
  	}
! 
  }
  
***************
*** 748,752 ****
  			$country{'url'} = $tag->attr('href');
  			$country{'id'} = $country_codes->{$country{'name'}};
! 			
  			# we won't do the Sky sites - they are very different to DirecTV
  			if ( $country{'name'} =~ /(SKY Brasil|SKY Mexico)/ ) {
--- 748,752 ----
  			$country{'url'} = $tag->attr('href');
  			$country{'id'} = $country_codes->{$country{'name'}};
! 
  			# we won't do the Sky sites - they are very different to DirecTV
  			if ( $country{'name'} =~ /(SKY Brasil|SKY Mexico)/ ) {
***************
*** 754,763 ****
  				next;
  			}
! 			
  			if ( !defined $country_codes->{$country{'name'}} ) {
  				print "Unknown country - $country{'name'} \n" unless $opt_quiet;
  				next;
  			}
! 			
  			$countries{$tag->as_text()} = \%country;
  		}
--- 754,763 ----
  				next;
  			}
! 
  			if ( !defined $country_codes->{$country{'name'}} ) {
  				print "Unknown country - $country{'name'} \n" unless $opt_quiet;
  				next;
  			}
! 
  			$countries{$tag->as_text()} = \%country;
  		}
***************
*** 780,784 ****
  	my $bar = new XMLTV::ProgressBar("Trying to fetch channel icons for $country{name}", $#ch_all + 1) if not $opt_quiet;
  	my $tree=get_tree($channels_icon_url);
! 	my $table=$tree->look_down( 
  		'_tag'=>'table',sub {
  			defined $_[0]->attr('width') and $_[0]->attr('width')== '600'
--- 780,784 ----
  	my $bar = new XMLTV::ProgressBar("Trying to fetch channel icons for $country{name}", $#ch_all + 1) if not $opt_quiet;
  	my $tree=get_tree($channels_icon_url);
! 	my $table=$tree->look_down(
  		'_tag'=>'table',sub {
  			defined $_[0]->attr('width') and $_[0]->attr('width')== '600'
***************
*** 809,813 ****
  	my $tree=get_tree( get_channels_url() );
  	my $table=$tree->look_down('_tag' => 'div', 'class' => 'guia-canales');
! 	
  	foreach my $ch (@ch_all){
  		my $ch_num=$ch->{'channel-num'};
--- 809,813 ----
  	my $tree=get_tree( get_channels_url() );
  	my $table=$tree->look_down('_tag' => 'div', 'class' => 'guia-canales');
! 
  	foreach my $ch (@ch_all){
  		my $ch_num=$ch->{'channel-num'};
***************
*** 881,886 ****
  }elsif ($mode eq 'list-channels') {
  	# Config file not used.
! }else { 
! 	die 
  }
  
--- 881,886 ----
  }elsif ($mode eq 'list-channels') {
  	# Config file not used.
! }else {
! 	die
  }
  
***************
*** 892,896 ****
  ######################################################################
  ## write configuration
! #    
  if ($mode eq 'configure') {
  	open(CONF, ">$config_file") or die "cannot write to $config_file: $!";
--- 892,896 ----
  ######################################################################
  ## write configuration
! #
  if ($mode eq 'configure') {
  	open(CONF, ">$config_file") or die "cannot write to $config_file: $!";
***************
*** 898,902 ****
  	print CONF "country $country{id} $country{name} $country{url} \n";
  	%channels = get_channels(); # sets @ch_all
! 	
  	# Ask about each channel.
  	my @chs = sort keys %channels;
--- 898,902 ----
  	print CONF "country $country{id} $country{name} $country{url} \n";
  	%channels = get_channels(); # sets @ch_all
! 
  	# Ask about each channel.
  	my @chs = sort keys %channels;
***************
*** 940,944 ****
  	# must have a country before we can list channels!
  	die "please select a country ('--loc xx')"  if (!defined $opt_loc || $opt_loc eq '');
! 	
  	%countries = get_countries();
  	while ( ($key, $value) = each %countries ) {
--- 940,944 ----
  	# must have a country before we can list channels!
  	die "please select a country ('--loc xx')"  if (!defined $opt_loc || $opt_loc eq '');
! 
  	%countries = get_countries();
  	while ( ($key, $value) = each %countries ) {
***************
*** 949,955 ****
  		}
  	}
! 		
  	%channels = get_channels(); # sets @ch_all based on %country
! 	
  	foreach (@ch_all) {
  		delete $_->{'channel-num'};  # not an DTD item!
--- 949,955 ----
  		}
  	}
! 
  	%channels = get_channels(); # sets @ch_all based on %country
! 
  	foreach (@ch_all) {
  		delete $_->{'channel-num'};  # not an DTD item!
***************
*** 975,979 ****
  	next if not defined;
  	if (/^country:?\s+(\S+)\s+(\S+)\s+([^\#]+)/) {
! 		%country=( id => $1, name=>$2, url=>$3 );      
  	}else{
  		if (/^channel:?\s+(\S+)\s+([^\#]+)/) {
--- 975,979 ----
  	next if not defined;
  	if (/^country:?\s+(\S+)\s+(\S+)\s+([^\#]+)/) {
! 		%country=( id => $1, name=>$2, url=>$3 );
  	}else{
  		if (/^channel:?\s+(\S+)\s+([^\#]+)/) {
***************
*** 992,996 ****
  		}
  	}
! }   
  
  ######################################################################
--- 992,996 ----
  		}
  	}
! }
  
  ######################################################################
***************
*** 1014,1018 ****
  	push @dates, $day;
  	#for each day
! 	$day=nextday($day); 
  	die if not defined $day;
  }
--- 1014,1018 ----
  	push @dates, $day;
  	#for each day
! 	$day=nextday($day);
  	die if not defined $day;
  }
***************
*** 1070,1079 ****
  #   but let's try for some better programming practice ;-)
  get_channel_programs(\@dates, \@channels, \@ch_all, \@programmes);
! 	
  # Write the <programme> elements
  foreach (@programmes) {
  	$writer->write_programme($_);
  }
! 	
  # end the progress bar
  $mainbar->finish() if not $opt_quiet;
--- 1070,1079 ----
  #   but let's try for some better programming practice ;-)
  get_channel_programs(\@dates, \@channels, \@ch_all, \@programmes);
! 
  # Write the <programme> elements
  foreach (@programmes) {
  	$writer->write_programme($_);
  }
! 
  # end the progress bar
  $mainbar->finish() if not $opt_quiet;
***************
*** 1088,1090 ****
  #debug "Exiting without warnings.";
  exit(0);
- 
--- 1088,1089 ----

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140

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