summaryrefslogtreecommitdiff
path: root/rhimport-dn
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2014-08-07 12:43:18 (GMT)
committerChristian Pointner <equinox@helsinki.at>2014-08-07 12:43:18 (GMT)
commitd7326108c2a53762bd394b6a53cbc3c48fb0a231 (patch)
treeee1adc0f88259192f4cedbdc746f7423b1d05d1d /rhimport-dn
parentb542076b90ce83c568478c4e4b14a89d9f1e78a9 (diff)
extendend importer for democracy now!
Diffstat (limited to 'rhimport-dn')
-rwxr-xr-xrhimport-dn46
1 files changed, 32 insertions, 14 deletions
diff --git a/rhimport-dn b/rhimport-dn
index a23d32b..0c5fb8e 100755
--- a/rhimport-dn
+++ b/rhimport-dn
@@ -44,6 +44,7 @@ my $DB = "rivendell";
my $STAT_FILE = $ENV{'HOME'} . "/rhimport-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 $PV_ID = '111';
binmode(STDIN, ":utf8");
@@ -54,6 +55,11 @@ 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'} . "/rhimport-dn-noheadline.stat";
+}
+
my $user = `/usr/bin/id -un`;
$user =~ s/\n//;
my $group = "democracyn";
@@ -150,27 +156,39 @@ if($file eq "" || !(-e "$file")) {
}
-print "\nlooking for headlines from date $y in RSS Feed\n";
-print " -> $HEADLINES_RSS_URL\n";
+unless($IGNORE_HEADLINE) {
+ print "\nlooking for headlines from date $y in RSS Feed\n";
+ print " -> $HEADLINES_RSS_URL\n";
-my $headlines_feed = XML::Feed->parse(URI->new($HEADLINES_RSS_URL))
- or die "Error fetching feed: " . XML::Feed->errstr;
+ my $headlines_feed = XML::Feed->parse(URI->new($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\/mp3download\/[^\/]+/) {
- next if($y ne $1);
+ if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3download\/[^\/]+/) {
+ next if($y ne $1);
- print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_day[0], $import_day[1], $import_day[2]), "1");
- print "\n";
+ print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
+ rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 0);
+ print "\n";
+ rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 1);
+ print "\n";
- 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";
+ rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @broadcast_day), "1", 2);
+ print "\n";
}
print "will import $file to dropbox $dropbox (cart=$to_cart)\n\n";