summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-03-12 05:17:14 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-03-12 05:17:14 (GMT)
commit909b01375b6f90aa365e6085d81a58dbae98d9d4 (patch)
tree006b83bdb414f05c2cd65330250adb5e4863cf5a
parentc29dcdf834efd8623ab20f34fd47e1e24ab619b2 (diff)
some cleanups and syntactic improvements
-rwxr-xr-xrhautoimport-dn53
-rwxr-xr-xrhautoimport-ra8
-rwxr-xr-xrhautoimport-rs8
-rwxr-xr-xrhautoimport-tr4
4 files changed, 27 insertions, 46 deletions
diff --git a/rhautoimport-dn b/rhautoimport-dn
index a791cee..4cf7eb0 100755
--- a/rhautoimport-dn
+++ b/rhautoimport-dn
@@ -36,7 +36,6 @@ use rhautoimport;
my $STAT_FILE = $ENV{'HOME'} . "/rhautoimport-dn.stat";
my $FILES_RSS_URL = "http://www.democracynow.org/podcast-stations.xml";
my $HEADLINES_RSS_URL = "http://www.democracynow.org/podcast.xml";
-my $IGNORE_HEADLINE = 0;
my $RD_GROUP = "democracyn";
my $PV_ID = '111';
@@ -44,14 +43,9 @@ if($#ARGV >= 0 && $ARGV[0] eq 'last') {
print "!!!This is the last attempt, there won't be a retry on error!!!\n"
}
-if($#ARGV >= 0 && $ARGV[0] eq 'noheadline') {
- $IGNORE_HEADLINE = 1;
- $STAT_FILE = $ENV{'HOME'} . "/rhautoimport-dn-noheadline.stat";
-}
-
my @today = Date::Calc::Today();
-my @yesterday = Date::Calc::Add_Delta_Days($today[0], $today[1], $today[2], -1);
-my @tomorrow = Date::Calc::Add_Delta_Days($today[0], $today[1], $today[2], 1);
+my @yesterday = Date::Calc::Add_Delta_Days(@today, -1);
+my @tomorrow = Date::Calc::Add_Delta_Days(@today, 1);
my @broadcast_day = @yesterday;
my @import_day = @today;
@@ -88,8 +82,8 @@ if($show_id < 0) {
exit 0;
}
-my $y = sprintf("%04d-%02d-%02d", $broadcast_day[0], $broadcast_day[1], $broadcast_day[2]);
-my $yc = sprintf("%04d-%02d%02d", $broadcast_day[0], $broadcast_day[1], $broadcast_day[2]);
+my $y = sprintf("%04d-%02d-%02d", @broadcast_day);
+my $yc = sprintf("%04d-%02d%02d", @broadcast_day);
print "looking for files from date $y in RSS Feed\n";
print " -> $FILES_RSS_URL\n";
@@ -133,39 +127,26 @@ if($uri eq "") {
}
-unless($IGNORE_HEADLINE) {
- print "\nlooking for headlines from date $y in RSS Feed\n";
- print " -> $HEADLINES_RSS_URL\n";
+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 = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL)
+ or die "Error fetching feed: " . XML::Feed->errstr;
- for my $entry ($headlines_feed->entries) {
- if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
- my $sum_title = $entry->title;
- my $sum_text = $entry->summary->body . "\n<br />\n<a href=\"" . $entry->link . "\">" . $entry->link . "</a>\n";
+for my $entry ($headlines_feed->entries) {
+ if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
+ my $sum_title = $entry->title;
+ my $sum_text = $entry->summary->body . "\n<br />\n<a href=\"" . $entry->link . "\">" . $entry->link . "</a>\n";
- if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3podcast\/[^\/]+/) {
- next if($y ne $1);
+ if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3podcast\/[^\/]+/) {
+ next if($y ne $1);
- print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 0);
- print "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 1);
- print "\n";
+ print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
+ rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 0);
- last;
- }
+ last;
}
}
-} else {
- print "\nignoring headlines for they are not available by now\n";
- my $dow_string = Date::Calc::Day_of_Week_to_Text(Date::Calc::Day_of_Week(@broadcast_day));
- my $sum_title = sprintf("Democracy Now! %04d-%02d-%02d %s", @broadcast_day, $dow_string);
- my $sum_text = "";
- print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @broadcast_day), "1", 2);
- print "\n";
}
print "will import '$uri' to show $show_id, $show_title\n\n";
diff --git a/rhautoimport-ra b/rhautoimport-ra
index a531458..aaa1e0a 100755
--- a/rhautoimport-ra
+++ b/rhautoimport-ra
@@ -67,12 +67,12 @@ $today[2] = 1;
my @broadcast_day = Date::Calc::Business_to_Standard(@today);
$today[2] = 3;
my @import_date = Date::Calc::Business_to_Standard(@today);
-my @import_date_reb = Date::Calc::Add_Delta_Days($import_date[0], $import_date[1], $import_date[2], 3);
+my @import_date_reb = Date::Calc::Add_Delta_Days(@import_date, 3);
print "day of original broadcast: " . Date::Calc::Date_to_Text(@broadcast_day) . "\n";
print "day of Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n";
print "day of Radio Helsinki rebroadcast: " . Date::Calc::Date_to_Text(@import_date_reb) . "\n";
-my $bd = sprintf("%04d-%02d-%02d", $broadcast_day[0], $broadcast_day[1], $broadcast_day[2]);
+my $bd = sprintf("%04d-%02d-%02d", @broadcast_day);
print "looking for files from $bd in RSS Feed\n";
print " -> $RSS_URL\n";
@@ -118,9 +118,9 @@ for my $entry ($feed->entries) {
my $sum_text = decode_entities($entry->content->body);
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2]), "1");
+ rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date), "1");
print "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_date_reb[0], $import_date_reb[1], $import_date_reb[2]), "2");
+ rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date_reb), "2");
print "\n";
last;
diff --git a/rhautoimport-rs b/rhautoimport-rs
index 9617bcb..576f213 100755
--- a/rhautoimport-rs
+++ b/rhautoimport-rs
@@ -77,7 +77,7 @@ my @import_date = Date::Calc::Standard_to_Business(@today);
if($dow <= $week_table{$curweek}) {
print "We are in week $curweek - broadcast is on " . Date::Calc::Day_of_Week_to_Text($week_table{$curweek}) . "\n";
$import_date[2] = $week_table{$curweek};
- @import_date = Date::Calc::Business_to_Standard($import_date[0], $import_date[1], $import_date[2]);
+ @import_date = Date::Calc::Business_to_Standard(@import_date);
} else {
print "We are in week $curweek - broadcast was on " . Date::Calc::Day_of_Week_to_Text($week_table{$curweek}) . "\n";
print " next week is $nextweek - broadcast is on " . Date::Calc::Day_of_Week_to_Text($week_table{$nextweek}) . "\n";
@@ -104,9 +104,9 @@ if(Date::Calc::Delta_Days(@broadcast_date, @today) <= 0) {
exit 0;
}
-my $id = sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2]);
-my $bd = sprintf("%04d-%02d-%02d", $broadcast_date[0], $broadcast_date[1], $broadcast_date[2]);
-my $bdfile = sprintf("RAST%04d%02d%02d(CBA)?(.*)\.MP3", $broadcast_date[0], $broadcast_date[1], $broadcast_date[2]);
+my $id = sprintf("%04d-%02d-%02d", @import_date);
+my $bd = sprintf("%04d-%02d-%02d", @broadcast_date);
+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";
diff --git a/rhautoimport-tr b/rhautoimport-tr
index 2de6c42..263cc0f 100755
--- a/rhautoimport-tr
+++ b/rhautoimport-tr
@@ -64,9 +64,9 @@ if($today[2] == 5) {
}
my @broadcast_day = Date::Calc::Business_to_Standard($today[0], $today[1], 5);
if($today[2] < 5) {
- @broadcast_day = Date::Calc::Add_Delta_Days($broadcast_day[0], $broadcast_day[1], $broadcast_day[2], -7);
+ @broadcast_day = Date::Calc::Add_Delta_Days(@broadcast_day, -7);
}
-my @import_date = Date::Calc::Add_Delta_Days($broadcast_day[0], $broadcast_day[1], $broadcast_day[2], 7);
+my @import_date = Date::Calc::Add_Delta_Days(@broadcast_day, 7);
print "day of original broadcast: " . Date::Calc::Date_to_Text(@broadcast_day) . "\n";
print "day of Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n";