diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-03-12 05:17:14 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-03-12 05:17:14 (GMT) |
commit | 909b01375b6f90aa365e6085d81a58dbae98d9d4 (patch) | |
tree | 006b83bdb414f05c2cd65330250adb5e4863cf5a /rhautoimport-dn | |
parent | c29dcdf834efd8623ab20f34fd47e1e24ab619b2 (diff) |
some cleanups and syntactic improvements
Diffstat (limited to 'rhautoimport-dn')
-rwxr-xr-x | rhautoimport-dn | 53 |
1 files changed, 17 insertions, 36 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"; |