xmltv/grab/huro tv_grab_huro.in,1.48,1.49

Geoff <[email protected]>
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/huro
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21356

Modified Files:
	tv_grab_huro.in 
Log Message:
#408 allow for blank programme title
#443 allow for invalid category mapping
#445 'uninitialized value' when parsing programme tree
#447 fix sponsored links
#448 year extracted wrongly sometimes
#451 fix <actor> credits
#74 add season extraction for .ro
#80 add support for roman numerals in series numbers. e.g. V./3
#83 Romanian jobmap translations
#84 fix episode extraction for .ro
#61 add programme icon
fix sub-title
fix jobmap parsing causes invalid credits
add credits to .cz and .sk
add rating element
add star-rating

Index: tv_grab_huro.in
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/huro/tv_grab_huro.in,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** tv_grab_huro.in	19 Jun 2012 06:32:25 -0000	1.48
--- tv_grab_huro.in	10 Apr 2014 16:05:16 -0000	1.49
***************
*** 196,207 ****
                   Slovakia => [ 'sk', '+0100' ]);
  our %WORDS = (
! 		cz => { episode => "Epizoda"},
  		hu => {	episode => "rész",
  				minute =>  "perc",
  				links => "linkek" },
! 		ro => { episode =>  "no such info on webpage",
  				minute => "minute",
  				links => "Linkuri" },
! 		sk => { episode => "Epizóda"}
  	) ;
  
--- 196,211 ----
                   Slovakia => [ 'sk', '+0100' ]);
  our %WORDS = (
! 		cz => { episode => "Epizoda",
! 				minute  =>  "minut",
! 				links   => "Linky" },
  		hu => {	episode => "rész",
  				minute =>  "perc",
  				links => "linkek" },
! 		ro => { episode => "episodul",		# patch #84
  				minute => "minute",
  				links => "Linkuri" },
! 		sk => { episode => "Epizóda",
! 				minute  =>  "minút",	
! 				links   => "Linky" }
  	) ;
  
***************
*** 211,217 ****
  sub process_table( $$$$ );
  sub parse_short_desc ( $ );
! sub get_channels();
  sub get_infourl_data( $$ );
  sub add_person ( $$$ );
  sub grab_icon( $ );
  sub get_channel_urls( $ );
--- 215,222 ----
  sub process_table( $$$$ );
  sub parse_short_desc ( $ );
! sub get_channels( ;$ );
  sub get_infourl_data( $$ );
  sub add_person ( $$$ );
+ sub extract_episode( $ );
  sub grab_icon( $ );
  sub get_channel_urls( $ );
***************
*** 334,342 ****
  		$XMLTV::Get_nice::FailOnError = 1;
  		my $data=get_nice($url);
! 		# FIXME strip sponsored links, they don't work in xmltv anyway
! 		$data =~ s|\x0D||g; # strip carriage return
  		$data =~ s|<span class=\"spons_link.*?</span>||g;
! 		$data =~ s|<div style=\"display:none\">.*?</div>||g;
! 		# strip links to divido.hu
  		$data =~ s|<a onclick=\"loggin.*?</a>||g;
  
--- 339,347 ----
  		$XMLTV::Get_nice::FailOnError = 1;
  		my $data=get_nice($url);
! 		# strip links to bet-at-home.com  # bug #447
!  		$data =~ s|\x0A||g; # strip new line
  		$data =~ s|<span class=\"spons_link.*?</span>||g;
! 		$data =~ s|<script type=\"text\/javascript\">.*?</script>||g;
! 		# strip links to divido.hu and provideo.ro
  		$data =~ s|<a onclick=\"loggin.*?</a>||g;
  
***************
*** 532,536 ****
  					warn "cannot found title: $startdate" ;
  				}
! 				# add one space after the title, if there is none
  				my @tmp = get_all_text($col);
  				$_ = join(' ', @tmp);
--- 537,542 ----
  					warn "cannot found title: $startdate" ;
  				}
! 				# add one space after the title, if there is none           # ???
! 				$program{title} = ' ' if $program{title} eq '';   # bug #408
  				my @tmp = get_all_text($col);
  				$_ = join(' ', @tmp);
***************
*** 715,728 ****
  	t "parse_short_desc: text: '$cont'";
          $WORDS{$COUNTRY}->{episode}="zdontmatchz" unless exists $WORDS{$COUNTRY}->{episode};
! 	# port.hu episode style
! 	if (m/\s*([0-9\/]+)\. $WORDS{$COUNTRY}->{episode}/) { $episode = $1; }
  	# port.cz/.sk episode style with season
! 	elsif (m/$WORDS{$COUNTRY}->{episode} \s*([0-9]+, [IVX]+\.)/) { $episode = $1; }
  	# port.cz/.sk episode style for two episodes back to back in one slot
  	elsif (m/$WORDS{$COUNTRY}->{episode} \s*(\d+, \d+)/) { $episode = $1; }
! 	# port.cz/.sk episode style without season
  	elsif (m/$WORDS{$COUNTRY}->{episode} \s*([0-9\/]+)/) { $episode = $1; }
  	if (m/\s*(\d+)'/)           { $minutes = $1; }
! 	if (m/\s*([12][0-9]{3})/)    { $year = $1 }
  
  	t "found episode: '$episode'" if defined $episode;
--- 721,739 ----
  	t "parse_short_desc: text: '$cont'";
          $WORDS{$COUNTRY}->{episode}="zdontmatchz" unless exists $WORDS{$COUNTRY}->{episode};
! 	# port.hu episode style with season   (# patch #80)
! 	if (m/\s*([IVX]+\.\/[0-9]+)\. $WORDS{$COUNTRY}->{episode}/) { $episode = $1; }
! 	# port.hu episode style without season
! 	elsif (m/\s*([0-9\/]+)\. $WORDS{$COUNTRY}->{episode}/) { $episode = $1; }
! 	# port.ro episode style with season   (# patch #74)
! 	elsif (m/$WORDS{$COUNTRY}->{episode} \s*([0-9]+, [A-Za-z]+ [0-9])/) { $episode = $1; }
  	# port.cz/.sk episode style with season
! 	elsif (m/$WORDS{$COUNTRY}->{episode} \s*([0-9]+, [IVX]+)\./) { $episode = $1; }
  	# port.cz/.sk episode style for two episodes back to back in one slot
  	elsif (m/$WORDS{$COUNTRY}->{episode} \s*(\d+, \d+)/) { $episode = $1; }
! 	# port.cz/.sk/.ro episode style without season
  	elsif (m/$WORDS{$COUNTRY}->{episode} \s*([0-9\/]+)/) { $episode = $1; }
+ 	
  	if (m/\s*(\d+)'/)           { $minutes = $1; }
! 	if (m/\(.*?((?:19|20)[0-9]{2})/) { $year = $1 }		# bug #448 
  
  	t "found episode: '$episode'" if defined $episode;
***************
*** 731,734 ****
--- 742,746 ----
  
  	foreach (keys %CATMAP) {
+ 		next unless defined $CATMAP{$_};		# bug #443
  		if ($cont =~ /$CATMAP{$_}[0]/i) {
  			push @categories, [$_, "en"];
***************
*** 741,771 ****
  	$prog->{q(length)} = $minutes * 60 if defined $minutes;
  	$prog->{q(date)} = $year if defined $year ;
! 	if (defined($episode)) {
! 		if($episode =~ m#(\d+)/(\d+)#) {
! 			my $current = $1;
! 			my $total = $2;
! 			# swap numbers for port.hu, they have total/current
! 			if ($current > $total) {
! 				($total, $current) = ($current, $total);
! 			}
! 			# episode-num spec with the total number specified.
! 			# however XMLTV counts from 0 on ...
! 			$prog->{q(episode-num)} = [[ sprintf('. %d/%d .', $current - 1, $total), "xmltv_ns" ],
! 				[ $episode, "onscreen" ]];
! 		} elsif($episode =~ m#(\d+), ([IVX]+)#) {
! 			# decode season from roman numeral
! 			my $season = arabic ($2);
! 			# episode-num spec with the total number specified.
! 			# however XMLTV counts from 0 on ...
! 			$prog->{q(episode-num)} = [[ sprintf('%d . %d .', $season - 1, $1 - 1), "xmltv_ns" ],
! 				[ $episode, "onscreen" ]];
! 		} elsif($episode =~ m#(\d+)#) {
! 			# episode-num spec with just the episode number
! 			# however XMLTV counts from 0 on ...
! 			$prog->{q(episode-num)} = [[ sprintf('. %d .', $1 - 1), "xmltv_ns" ]];
! 		} else {
! 			$prog->{q(episode-num)} = [[ $episode, "onscreen" ]];
! 		}
! 	}
  }
  
--- 753,760 ----
  	$prog->{q(length)} = $minutes * 60 if defined $minutes;
  	$prog->{q(date)} = $year if defined $year ;
! 	
! 	$prog->{q(episode-num)} = extract_episode( $episode )
! 		if defined $episode ;
! 		
  }
  
***************
*** 801,805 ****
  #				'icon' => [ { src => $iconurl } ] )
  #-------------------------------------------------------------------------------
! sub get_channels() {
  	my $d = domain();
  	my $bar = new XMLTV::ProgressBar('getting list of channels', 1)
--- 790,795 ----
  #				'icon' => [ { src => $iconurl } ] )
  #-------------------------------------------------------------------------------
! sub get_channels( ;$ ) {
! 	my $mode = shift;
  	my $d = domain();
  	my $bar = new XMLTV::ProgressBar('getting list of channels', 1)
***************
*** 839,842 ****
--- 829,833 ----
  						'id' => "$channel_id.$d"
  					) ;
+ 					if (!defined $mode || $mode ne 'grab') {  # no point doing this for 'grab'
  					# fetch and get icon url
  					worker("base-downloading");
***************
*** 845,848 ****
--- 836,840 ----
  					}
  					worker("base-parsing");
+ 					}
  					$CHANNELS{$channel_id} = \%channel;
  				} 
***************
*** 872,882 ****
  	return unless length($person);
  
! 	if (defined($JOBMAP{$job})) {
  		push @{$$rcredits{$JOBMAP{$job}}}, $person;
  	}
  	else {
! 		push @{$$rcredits{'actor'}}, $person;
  	}
- 	t "credits: added: '$job -> $person'";
  }
  
--- 864,875 ----
  	return unless length($person);
  
! 	# suppress if job is not known, or if not mapped to DTD
! 	if (defined $JOBMAP{$job} && length($JOBMAP{$job})) {
  		push @{$$rcredits{$JOBMAP{$job}}}, $person;
+ 		t "credits: added: '$job -> $person'";
  	}
  	else {
! 		t "credits: NOT added: '$job -> $person'";
  	}
  }
  
***************
*** 954,957 ****
--- 947,951 ----
  	t "subtitle parsing ...";
  	($anchor) = $tree->look_down(_tag=>"span", class=>"blackbigtitle");
+ 	($anchor) = $tree->look_down(_tag=>"h1", class=>"blackbigtitle") if !defined $anchor;	# 2014-04-09 it seems to now be in <h1>
  	if ($anchor) {
  		$elem = $anchor; 
***************
*** 977,984 ****
--- 971,995 ----
  		$joined =~ s/^\s+//;	# remove blanks
  		$joined =~ s/\s+$//;	# remove blanks
+ 		$joined =~ s/,$//;  	# remove trailing comma
  		t "anchor and right sibling found, joinedlines parsed :'$joined'";
  		$prog->{q(sub-title)} = [[$joined, $COUNTRY]] if length($joined);
  	}
  
+ 	# ICON
+ 	# anchor point: 
+ 	# the programme image will be tagged as follows:
+ 	#		<div class="random-media-wrapper"><img class="object_picture" src="http://media.port-network.com/picture/instance_2/92418_2.jpg" width="250" height="221" style="float:" alt="Închisoarea îngerilor - Tim Robbins" border="0" />
+ 
+ 	t "programme icon parsing ...";
+ 	$anchor = $tree->look_down(_tag=>"div", class=>"random-media-wrapper");
+ 	$anchor = $anchor->look_down(_tag=>"img", class=>"object_picture") if $anchor;
+ 	if ($anchor) {
+ 		my %icon;
+ 		$icon{'src'} = $anchor->attr('src') if $anchor->attr('src');
+ 		$icon{'width'} = $anchor->attr('width') if $anchor->attr('width');
+ 		$icon{'height'} = $anchor->attr('height') if $anchor->attr('height');
+ 		$prog->{q(icon)} = [ \%icon ] if $anchor->attr('src');
+ 	}
+ 	
  	# LINKS:
  	# try to grab IMDB, All Movie, official web site of the program
***************
*** 1042,1046 ****
  			$joined =~ s/\xA0//;	# remove the to_text()'s results of &nbsp
  			$joined =~ s/^\s+//;	# remove blanks
! 			t "found description $joined";
  			
  			if (length($joined)) {
--- 1053,1057 ----
  			$joined =~ s/\xA0//;	# remove the to_text()'s results of &nbsp
  			$joined =~ s/^\s+//;	# remove blanks
! 			t "found description: $joined";
  			
  			if (length($joined)) {
***************
*** 1069,1077 ****
  	
  	($anchor) = $separators[1];
! 	if ($anchor->parent()->tag() ne "td" || $anchor->parent->attr('width') ne "98%") {
  		t "credits section not found";
  		return;
  	}
  
  	# collect all text lines, we
  	# achive this to jump to the parent first, and walk all the childs until
--- 1080,1158 ----
  	
  	($anchor) = $separators[1];
! 	if ($anchor->parent()->tag() ne "td" || !defined $anchor->parent->attr('width') || $anchor->parent->attr('width') ne "98%") {   # bug #445
  		t "credits section not found";
  		return;
  	}
  
+ 	# get the rating if available
+ 	#    <img alt="(AP)" title="Recomandat acordul parintilor" class="age_limit_icon" src="http://media.port-network.com/page_elements/parental_guidance_mini_pix_ro.png">
+ 	if (my $img = $anchor->parent()->look_down('_tag' => 'img', 'class' => 'age_limit_icon')) {
+ 		my $rating = $img->attr('alt');
+ 		$rating =~ s/[\(\)]//g;			# strip the brackets
+ 		my $rating_icon = $img->attr('src');
+ 		$prog->{q(rating)} = [[ $rating, '', [{'src' => $rating_icon }] ]];
+ 	}
+ 	
+ 	# unfortunately the star-rating (vote_box) if fetched with an AJAX call
+ 	# e.g.  http://www.port.sk/arrow/pls/fi/vote.print_vote_box?i_object_id=139692&i_area_id=6&i_reload_container=id%3D%22vote_box%22&i_is_separator=0
+ 	#
+ 	# we could use TreeBuilder->store_cdata(true)  to store the cdata under the root node, but I think it's easier to just regexp the html
+ 	#  /*<![CDATA[*/
+ 	#  ajaxRequest(
+ 	#  {'url':'vote.print_vote_box?',
+ 	#  'parameters':'i_object_id=139692&i_area_id=6&i_reload_container=id%3D%22vote_box%22&i_is_separator=0',
+ 	#  'method':'GET',
+ 	#  ...
+ 	#
+ 	if ( $data =~ m/ajaxRequest\(.*?{'url':'(vote.print_vote_box\?)',.*?'parameters':'(.*?)',.*?'method':'GET'/s ) {
+ 		
+ 		my $ajaxurl = $1 . $2;					# ajax uri
+ 		(my $baseurl) = $url =~ m#(.*/)#;		# greedy match up to last / char
+ 		$ajaxurl = $baseurl . $ajaxurl;			# prepend the uri
+ 	
+ 		t "fetching ajax url" . d $ajaxurl; 
+ 		
+ 		# store current values of get_nice
+ 		my $get_fail = $XMLTV::Get_nice::FailOnError;
+ 		my $get_delay = $XMLTV::Get_nice::Delay;
+ 		$XMLTV::Get_nice::FailOnError = 0;		# don't abort if not found
+ 		$XMLTV::Get_nice::Delay = 0;			# no delay
+ 		
+ 		my $ajaxdata;
+ 		if (defined($ajaxdata = get_nice($ajaxurl))) {
+ 			worker("ajax-downloading");
+ 			my $ajaxtree = HTML::TreeBuilder->new_from_content($ajaxdata) or
+ 				die "could not fetch/parse $ajaxurl (infopage)";
+ 				
+ 			worker("ajax-parsing");
+ 			if (my $anchor = $ajaxtree->look_down(_tag=>"div", class=>qr/starholder/)) {
+ 				my $starsval;
+ 				if (my $stars = $anchor->look_down(_tag=>"span", class=>"ctxt")) {
+ 					$starsval = $stars->as_text();
+ 					$starsval =~ s/,/./; $starsval += 0;	# convert to float
+ 					$prog->{q(star-rating)} = [[ sprintf("%.0f / 10", $starsval) ]];
+ 				}
+ 				#
+ 				# add another "star-rating" showing the number of votes (it doesn't really belong here but there's nowhere better)
+ 				# - this gives a clue as to whether 0 means 'bad' or it simply means 'unrated'!
+ 				#
+ 				if (my $votes = $anchor->look_down(_tag=>"div", class=>"votenum")) {
+ 					my $votesval = $votes->as_text();
+ 					if ($votesval) {
+ 						(my $num_votes) = $votesval =~ /(\d*)/;
+ 						# if star-rating is 0 and num_votes is null then we'll assume it hasn't been voted on yet
+ 						if ($starsval == 0 && $num_votes eq '') { undef $prog->{q(star-rating)} }
+ 						push @{ $prog->{q(star-rating)} }, [ $num_votes, "votes" ]  if $num_votes ne '';
+ 					}
+ 				}
+ 			}
+ 		}
+ 		# restore the previous values
+ 		$XMLTV::Get_nice::FailOnError = $get_fail;
+ 		$XMLTV::Get_nice::Delay = $get_delay;
+ 	}
+ 	
+ 	
+ 	
  	# collect all text lines, we
  	# achive this to jump to the parent first, and walk all the childs until
***************
*** 1114,1117 ****
--- 1195,1200 ----
  				# 1: amerikai filmdráma sorozat, 90 perc, 2000, 2. rész
  				# 12 éven aluliak számára ....
+ 				#   added 2004-04-07 :
+ 				# (ro) Coreea de Sud, 2009, serial de aventuri, episodul 5
  
  				$_ = $part;
***************
*** 1119,1122 ****
--- 1202,1207 ----
  					if ((m/\s*([0-9\/]+)\. $WORDS{$COUNTRY}->{episode}/) && (! defined $episode))
  						{ $episode = $1; last SWITCH;}
+ 					if ((m/$WORDS{$COUNTRY}->{episode} \s*([0-9\/]+)/) && (! defined $episode))
+ 						{ $episode = $1; last SWITCH;}
  					if ((m/\s*(\d+) $WORDS{$COUNTRY}->{minute}/) && (! defined $minutes))
  						{ $minutes = $1; last SWITCH;}
***************
*** 1140,1149 ****
  				# part of \b
  
! 				if (($_) = $part =~ /^\s*(\S+):/) {
  					# remove the "jobname:" string
  					$part =~ s/^\s*(\S+):\s*//;
! 					t "is this a known job?: '$_'";		# e.g.: hu-job 
! 					if (defined($JOBMAP{$_})) {
! 						t "yes, this string is a jobname";
  						# this means, we should add our until now collected
  						# person to the credits, and begin to collect new 
--- 1225,1235 ----
  				# part of \b
  
! 				# bug #451 [line deleted]
! 				
! 				if (($_) = $part =~ /^\s*(\S+):/) {		# does the $line include a  ':'
  					# remove the "jobname:" string
  					$part =~ s/^\s*(\S+):\s*//;
! 					
! 					t "assuming string is a jobname";
  						# this means, we should add our until now collected
  						# person to the credits, and begin to collect new 
***************
*** 1152,1161 ****
  						add_person($job, $person, \%credits);
  
! 						if (length($JOBMAP{$_})) {
  							# newly readed part has a en-job (this is defined in DTD, so
  							# this will be the next used job for XML generation
  
! 							t "job known in DTD as: $JOBMAP{$_}";
! 							$job = $_;
  							$person = $part;
  						} #en-job
--- 1238,1248 ----
  						add_person($job, $person, \%credits);
  
! 					t "is this a known job?: '$_'";		# e.g.: hu-job 
! 					if (defined $JOBMAP{lc($_)} && length($JOBMAP{lc($_)})) {
  							# newly readed part has a en-job (this is defined in DTD, so
  							# this will be the next used job for XML generation
  
! 						t "job known in DTD as: $JOBMAP{lc($_)}";
! 						$job = lc($_);
  							$person = $part;
  						} #en-job
***************
*** 1167,1171 ****
  						} #hu-job
  						next;
- 					} #hu-job
  				} #: in the part
  
--- 1254,1257 ----
***************
*** 1201,1204 ****
--- 1287,1291 ----
  
  	t "CREDITS: " . d \%credits;
+ 	$prog->{q(credits)} = \%credits;
  
  	#$prog->{q(category)} = [[ $category, $COUNTRY ]]
***************
*** 1211,1227 ****
  		if defined $year ;
  
  	if(defined($episode)) {
  		if($episode =~ m#(\d+)/(\d+)#) {
  			# episode-num spec with the total number specified.
  			# however XMLTV counts from 0 on ...
! 			$prog->{q(episode-num)} = [[ sprintf('%d/%d', $1 - 1, $2), "xmltv_ns" ]];
! 		}
! 		else {
! 			$prog->{q(episode-num)} = [[ $episode, "onscreen" ]];
  		}
  	}
  
! 	$prog->{q(credits)} = \%credits;
! 	$tree->delete;
  }
  
--- 1298,1355 ----
  		if defined $year ;
  
+ 	$prog->{q(episode-num)} = extract_episode( $episode )
+ 		if defined $episode ;
+ 
+ 	$tree->delete;
+ }
+ 		
+ 
+ #-------------------------------------------------------------------------------
+ # extract_episode
+ #-------------------------------------------------------------------------------
+ # desc		: parse text containing the episode details 
+ # arguments	: 1- episode data
+ # returns	: xmltv episode-num definition
+ #-------------------------------------------------------------------------------
+ sub extract_episode( $ ) {
+ 	my $episode = shift;
+ 	my ($episode_num, $season);
+ 	
  	if(defined($episode)) {
  		if($episode =~ m#(\d+)/(\d+)#) {
  			# episode-num spec with the total number specified.
+ 			# swap numbers for port.hu, they have total/num
+ 			my ($num, $total) = ($1, $2);
+ 			($num, $total) = ($2, $1) if ($num > $total);		
  			# however XMLTV counts from 0 on ...
! 			$episode_num = [[ sprintf('. %d/%d .', $num - 1, $total), "xmltv_ns" ], [ $episode, "onscreen" ]];
! 			
! 		} elsif($episode =~ m#([IVX]+)\./(\d+)#) {
! 			# patch #80
! 			# port.hu style episode numbering: <serie_in_roman>./<episode_in_arabic>. e.g. V./3
! 			# episode-num spec with the total number specified.
! 			# decode season from roman numeral
! 			$season = arabic ($1);
! 			# however XMLTV counts from 0 on ...
! 			$episode_num = [[ sprintf('%d . %d .', $season - 1, $2 - 1), "xmltv_ns" ], [ $episode, "onscreen" ]];
! 		
! 		} elsif($episode =~ m#(\d+), ([IVX]+)#) {
! 			# episode-num spec with the total number specified.
! 			# decode season from roman numeral
! 			$season = arabic ($2);
! 			# however XMLTV counts from 0 on ...
! 			$episode_num = [[ sprintf('%d . %d .', $season - 1, $1 - 1), "xmltv_ns" ], [ $episode, "onscreen" ]];	
! 			
!  		} elsif($episode =~ m#(\d+)#) {
!  			# episode-num spec with just the episode number
!  			# however XMLTV counts from 0 on ...
! 			$episode_num = [[ sprintf('. %d .', $1 - 1), "xmltv_ns" ], [ $episode, "onscreen" ]];
! 			
!  		} else {
!  			$episode_num = [[ $episode, "onscreen" ]];
  		}
  	}
  
! 	return $episode_num;
  }
  
***************
*** 1242,1245 ****
--- 1370,1402 ----
  	my ($file, $iconurl);
  
+ 	# that $fetchurl no longer works for RO, so...
+ 	#test if url is valid
+ 	$XMLTV::Get_nice::FailOnError = 0;
+ 	my $image = get_nice($fetchurl);
+ 	if (!defined $image) {
+ 		# image url not valid, so we must get it from the programmes page. Ideally we would do that during the main grab but this is a Q&D fix
+ 		# and I don't want to change too much of this code
+ 		my $url = "http://www." . domain() . "/pls/w/tv.channel?i_ch=".$channelid."&i_date=".UnixDate('today','%Y-%m-%d')."&i_where=1";
+ 			
+ 		my $data=get_nice($url);
+ 		my $tree = HTML::TreeBuilder->new_from_content($data) or 
+ 			die "could not fetch/parse $url (grab_icon)\n";
+ 		worker("base-parsing");
+ 
+ 		my $body = $tree->look_down("_tag"=>"body");
+ 		my $container = $body->look_down("_tag" => "div", "class" => qr/main-container-100/);
+ 		if ($container) {
+ 			if (my $imgdiv = $container->look_down("_tag" => "div", "style" => qr/float\s*:\s*left/, sub { 
+ 												my $imgtag = $_[0]->look_down('_tag' => 'img');
+ 												return 0 unless $imgtag; 
+ 												return $imgtag->attr('src') =~ m/http:\/\/media/;
+ 												} ))
+ 			{
+ 				$fetchurl = $imgdiv->look_down('_tag' => 'img')->attr('src');
+ 			}
+ 		}
+ 	}
+     $XMLTV::Get_nice::FailOnError = 1;
+         
  	return $fetchurl if ($opt_icons && ! $opt_local_icons);
  
***************
*** 1265,1269 ****
  		t "fetching $fetchurl...";
  		$XMLTV::Get_nice::FailOnError = 0;
! 		if (my $image = get_nice($fetchurl)) {
  			t "icon for $channelid grabbed successfully";
  			print FILE $image;
--- 1422,1430 ----
  		t "fetching $fetchurl...";
  		$XMLTV::Get_nice::FailOnError = 0;
! 		#if (my $image = get_nice($fetchurl)) {     # now grabbed above
! 		if (!$image) { 
! 			$image = get_nice($fetchurl);
! 		}
! 		if ($image) {
  			t "icon for $channelid grabbed successfully";
  			print FILE $image;
***************
*** 1418,1424 ****
  		++ $line_num;
  		tr/\r//d;
- 		
  		s/#.*//;
  		next if m/^\s*$/;
  
  		$where = "$jobmap_file:$line_num";
--- 1579,1585 ----
  		++ $line_num;
  		tr/\r//d;
  		s/#.*//;
  		next if m/^\s*$/;
+ 		s/^\s+|\s+$//g;   # trim spaces
  
  		$where = "$jobmap_file:$line_num";
***************
*** 1445,1448 ****
--- 1606,1610 ----
  		s/#.*//;
  		next if m/^\s*$/;
+ 		s/^\s+|\s+$//g;   # trim spaces
  
  		$where = "$catmap_file:$line_num";
***************
*** 1678,1682 ****
  
  	# sets %CHANNELS
! 	get_channels();
  
  	worker("xml-writing");
--- 1840,1844 ----
  
  	# sets %CHANNELS
! 	get_channels($mode);
  
  	worker("xml-writing");

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees

_______________________________________________
xmltv-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltv-commit
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.