From d7326108c2a53762bd394b6a53cbc3c48fb0a231 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 7 Aug 2014 12:43:18 +0000 Subject: extendend importer for democracy now! 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
\nlink . "\">" . $entry->link . "\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
\nlink . "\">" . $entry->link . "\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"; -- cgit v0.10.2