From 2fbd4bc628b28c88a45026a1ec4a324ca2bda417 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 25 May 2016 16:15:22 +0200 Subject: make interface of fetch_parse_rss the same as fetch_parse_json from rhrdlibs diff --git a/rhautoimport-btl b/rhautoimport-btl index 300027c..2144053 100755 --- a/rhautoimport-btl +++ b/rhautoimport-btl @@ -91,9 +91,9 @@ my $bdfile = sprintf("%02d%02d%02d-btlv128\.mp3", $broadcast_date[0]%100, $broad print "looking for files like '$bdfile' in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport-dn b/rhautoimport-dn index 80ffec3..b843e84 100755 --- a/rhautoimport-dn +++ b/rhautoimport-dn @@ -94,9 +94,9 @@ my $yc = sprintf("%04d-%02d%02d", @broadcast_day); print "looking for files from date $y in RSS Feed\n"; print " -> $FILES_RSS_URL\n"; -my ($files_feed, $errstr) = rhautoimport::fetch_parse_rss($FILES_RSS_URL); -unless (defined $files_feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $files_feed) = rhautoimport::fetch_parse_rss($FILES_RSS_URL); +unless ($result) { + print "Error fetching feed: $files_feed\n"; exit 1; } @@ -142,9 +142,10 @@ if($uri eq "") { print "\nlooking for headlines from date $y in RSS Feed\n"; print " -> $HEADLINES_RSS_URL\n"; -(my $headlines_feed, $errstr) = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL); -unless (defined $headlines_feed) { - print "Error fetching feed: $errstr\n"; + +my ($result, $headlines_feed) = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL); +unless ($result) { + print "Error fetching feed: $headlines_feed\n"; exit 1; } diff --git a/rhautoimport-nw b/rhautoimport-nw index 24350a9..697b003 100755 --- a/rhautoimport-nw +++ b/rhautoimport-nw @@ -84,9 +84,9 @@ my $bdfile = sprintf("NETWATCHER[-_]?%04d%02d%02d(.*)\.MP3", @broadcast_day); print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport-oi b/rhautoimport-oi index 40b9059..0f5b9b4 100755 --- a/rhautoimport-oi +++ b/rhautoimport-oi @@ -97,9 +97,9 @@ if($current_id eq $id) { print "looking for files like '$bdfile' in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport-ra b/rhautoimport-ra index 2464614..3544d10 100755 --- a/rhautoimport-ra +++ b/rhautoimport-ra @@ -82,9 +82,9 @@ my $bd = sprintf("%04d-%02d-%02d", @broadcast_day); print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport-rs b/rhautoimport-rs index e33a955..fbcae5e 100755 --- a/rhautoimport-rs +++ b/rhautoimport-rs @@ -129,9 +129,9 @@ my $bdfile = sprintf("RAST%04d%02d%02d(CBA)?(.*)\.MP3", @broadcast_date); print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport-tr b/rhautoimport-tr index df848a5..7b88c6d 100755 --- a/rhautoimport-tr +++ b/rhautoimport-tr @@ -84,9 +84,9 @@ my $bdfile = sprintf("^%04d-?%02d-?%02d", @broadcast_day); print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/rhautoimport.pm b/rhautoimport.pm index c9f577c..4ea0808 100644 --- a/rhautoimport.pm +++ b/rhautoimport.pm @@ -68,12 +68,12 @@ sub fetch_parse_rss $ua->agent($ua_str); $ua->env_proxy; my $res = URI::Fetch->fetch($uri, UserAgent => $ua); - return (undef, URI::Fetch->errstr) unless $res; - return (undef, "This feed has been permanently removed") if $res->status == URI::Fetch::URI_GONE(); + return (0, URI::Fetch->errstr) unless $res; + return (0, "This feed has been permanently removed") if $res->status == URI::Fetch::URI_GONE(); my $xml = $res->content; - return XML::Feed->parse(\$xml); + return (1, XML::Feed->parse(\$xml)); } sub check_file_extension diff --git a/test/cba-inspect b/test/cba-inspect index b8546bd..f998d43 100755 --- a/test/cba-inspect +++ b/test/cba-inspect @@ -49,9 +49,9 @@ binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } diff --git a/test/rss-inspect b/test/rss-inspect index 3494e7c..1859ed7 100755 --- a/test/rss-inspect +++ b/test/rss-inspect @@ -49,9 +49,9 @@ binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); -my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL); -unless (defined $feed) { - print "Error fetching feed: $errstr\n"; +my ($result, $feed) = rhautoimport::fetch_parse_rss($RSS_URL); +unless ($result) { + print "Error fetching feed: $feed\n"; exit 1; } -- cgit v0.10.2