[PATCH] Avoid runtime error when a brand has only one episode.

Mike Crowe mac at mcrowe.com
Wed Jan 5 08:38:38 EST 2011


Before applying this fix I quite often saw errors like:

 Not an ARRAY reference at ./get_iplayer line 5611.

(for example when using --pvr having added a recursive PID of
b00lv1k1.)
---
 get_iplayer |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

You may not want to apply this patch as it is but hopefully it should
point out what appeared to me to be causing the problem.

Thanks.

Mike.

diff --git a/get_iplayer b/get_iplayer
index c746df0..c48a2cc 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -5608,8 +5608,16 @@ sub parse_rdf_brand {
 		main::logger "INFO: With Series pid '".$series_element->{'rdf:resource'}."'\n" if $opt->{debug};
 		push @pids, parse_rdf_series( $ua, $series_element->{'rdf:resource'} );
 	}
-	main::logger "INFO:    Series: <None>\n" if $#{ $rdf->{'po:Brand'}->{'po:episode'} };
-	for my $episode_element ( @{ $rdf->{'po:Brand'}->{'po:episode'} } ) {
+	if (ref$rdf->{'po:Brand'}->{'po:episode'} eq 'ARRAY') {
+		main::logger "INFO:    Series: <None>\n" if $#{ $rdf->{'po:Brand'}->{'po:episode'} };
+		for my $episode_element ( @{ $rdf->{'po:Brand'}->{'po:episode'} } ) {
+			main::logger "INFO:      Episode pid: ".$episode_element->{'rdf:resource'}."\n" if $opt->{debug};
+			push @pids, extract_pid( $episode_element->{'rdf:resource'} );
+			parse_rdf_episode( $ua, $episode_element->{'rdf:resource'} );
+		}
+	} else {
+		main::logger "INFO:    Series: <None>\n";
+		my $episode_element = $rdf->{'po:Brand'}->{'po:episode'};
 		main::logger "INFO:      Episode pid: ".$episode_element->{'rdf:resource'}."\n" if $opt->{debug};
 		push @pids, extract_pid( $episode_element->{'rdf:resource'} );
 		parse_rdf_episode( $ua, $episode_element->{'rdf:resource'} );
-- 
1.5.6.5



More information about the get_iplayer mailing list