summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrhautoimport-btl7
-rwxr-xr-xrhautoimport-dn14
-rwxr-xr-xrhautoimport-nw7
-rwxr-xr-xrhautoimport-oi7
-rwxr-xr-xrhautoimport-ra7
-rwxr-xr-xrhautoimport-rs7
-rwxr-xr-xrhautoimport-tr7
-rw-r--r--rhautoimport.pm7
8 files changed, 43 insertions, 20 deletions
diff --git a/rhautoimport-btl b/rhautoimport-btl
index a70ec83..300027c 100755
--- a/rhautoimport-btl
+++ b/rhautoimport-btl
@@ -91,8 +91,11 @@ 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 = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
diff --git a/rhautoimport-dn b/rhautoimport-dn
index a8b9cbe..5b1bc63 100755
--- a/rhautoimport-dn
+++ b/rhautoimport-dn
@@ -94,8 +94,11 @@ 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 = rhautoimport::fetch_parse_rss($FILES_RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($files_feed, $errstr) = rhautoimport::fetch_parse_rss($FILES_RSS_URL);
+unless (defined $files_feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
@@ -139,8 +142,11 @@ if($uri eq "") {
print "\nlooking for headlines from date $y in RSS Feed\n";
print " -> $HEADLINES_RSS_URL\n";
-my $headlines_feed = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($headlines_feed, $errstr) = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL);
+unless (defined $headlines_feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
for my $entry ($headlines_feed->entries) {
if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
diff --git a/rhautoimport-nw b/rhautoimport-nw
index 385a519..24350a9 100755
--- a/rhautoimport-nw
+++ b/rhautoimport-nw
@@ -84,8 +84,11 @@ 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 = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
diff --git a/rhautoimport-oi b/rhautoimport-oi
index dc32cb9..40b9059 100755
--- a/rhautoimport-oi
+++ b/rhautoimport-oi
@@ -97,8 +97,11 @@ if($current_id eq $id) {
print "looking for files like '$bdfile' in RSS Feed\n";
print " -> $RSS_URL\n";
-my $feed = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
diff --git a/rhautoimport-ra b/rhautoimport-ra
index 6231a67..2464614 100755
--- a/rhautoimport-ra
+++ b/rhautoimport-ra
@@ -82,8 +82,11 @@ my $bd = sprintf("%04d-%02d-%02d", @broadcast_day);
print "looking for files from $bd in RSS Feed\n";
print " -> $RSS_URL\n";
-my $feed = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $bdexp = sprintf("^(\\d+)\\..*\\s*0?%d\\s*[.,]\\s*0?%d\\s*[.,]\\s*%4d", $broadcast_day[2], $broadcast_day[1], $broadcast_day[0]);
diff --git a/rhautoimport-rs b/rhautoimport-rs
index 843d339..e33a955 100755
--- a/rhautoimport-rs
+++ b/rhautoimport-rs
@@ -129,8 +129,11 @@ 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 = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
diff --git a/rhautoimport-tr b/rhautoimport-tr
index b356a01..df848a5 100755
--- a/rhautoimport-tr
+++ b/rhautoimport-tr
@@ -84,8 +84,11 @@ my $bdfile = sprintf("^%04d-?%02d-?%02d", @broadcast_day);
print "looking for files from $bd in RSS Feed\n";
print " -> $RSS_URL\n";
-my $feed = rhautoimport::fetch_parse_rss($RSS_URL)
- or die "Error fetching feed: " . XML::Feed->errstr;
+my ($feed, $errstr) = rhautoimport::fetch_parse_rss($RSS_URL);
+unless (defined $feed) {
+ print "Error fetching feed: $errstr\n";
+ exit 1;
+}
my $uri = "";
my $file = "";
diff --git a/rhautoimport.pm b/rhautoimport.pm
index f2e24cc..bb0c015 100644
--- a/rhautoimport.pm
+++ b/rhautoimport.pm
@@ -67,10 +67,9 @@ sub fetch_parse_rss
my $ua = LWP::UserAgent->new;
$ua->agent($ua_str);
$ua->env_proxy;
- my $res = URI::Fetch->fetch($uri, UserAgent => $ua)
- or die URI::Fetch->errstr;
- die "This feed has been permanently removed"
- if $res->status == URI::Fetch::URI_GONE();
+ 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();
my $xml = $res->content;