diff options
author | Christian Pointner <equinox@helsinki.at> | 2012-01-20 23:17:45 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2012-01-20 23:17:45 (GMT) |
commit | 1dba2c5177db50e79437e221076b3c0153e10c86 (patch) | |
tree | dd55b9407548da9ea976ef87580c6310d0e52a42 | |
parent | 5c15154a15840173ca8167bb0bbb3db32290ce41 (diff) |
simpler interface to pv_add_note
-rwxr-xr-x | rhimport-dn | 6 | ||||
-rwxr-xr-x | rhimport-rs | 10 | ||||
-rwxr-xr-x | rhimport-wl | 6 | ||||
-rw-r--r-- | rhimport.pm | 8 |
4 files changed, 12 insertions, 18 deletions
diff --git a/rhimport-dn b/rhimport-dn index d712c9b..fa7607f 100755 --- a/rhimport-dn +++ b/rhimport-dn @@ -43,7 +43,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 @PV_SCRIPT = ('/usr/bin/ssh', 'root@intranet', 'addnote', '111'); +my $PV_ID = '111'; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); @@ -132,9 +132,7 @@ for my $entry ($headlines_feed->entries) { next if($y ne $1); print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; - - push(@PV_SCRIPT, sprintf("%04d-%02d-%02d", $today[0], $today[1], $today[2])); - rhimport::pv_add_note($sum_title, $sum_text, @PV_SCRIPT); + rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $today[0], $today[1], $today[2])); print "\n"; } } diff --git a/rhimport-rs b/rhimport-rs index 13ea5a3..4e5f87f 100755 --- a/rhimport-rs +++ b/rhimport-rs @@ -42,8 +42,7 @@ my $DB = "rivendell"; my $STAT_FILE = $ENV{'HOME'} . "/rhimport-rs.stat"; my $RSS_URL = "http://cba.fro.at/seriesrss/197"; -my @PV_SCRIPT = ('/usr/bin/ssh', 'root@intranet', 'addnote', '75'); -my @PV_SCRIPT_REB = ('/usr/bin/ssh', 'root@intranet', 'addnote', '75'); +my $PV_ID = '75'; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); @@ -114,12 +113,9 @@ for my $entry ($feed->entries) { print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; - push(@PV_SCRIPT, sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2])); - rhimport::pv_add_note($sum_title, $sum_text, @PV_SCRIPT); + rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2]), 'n'); print "\n"; - - push(@PV_SCRIPT_REB, sprintf("%04d-%02d-%02d", $import_date_reb[0], $import_date_reb[1], $import_date_reb[2])); - rhimport::pv_add_note($sum_title, $sum_text, @PV_SCRIPT_REB); + rhimport::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]), 'r'); print "\n"; last; diff --git a/rhimport-wl b/rhimport-wl index 6c2d314..492460d 100755 --- a/rhimport-wl +++ b/rhimport-wl @@ -42,7 +42,7 @@ my $DB = "rivendell"; my $STAT_FILE = $ENV{'HOME'} . "/rhimport-wl.stat"; my $RSS_URL = "http://www.radiowienerlied.at/rss/podcast.xml"; -my @PV_SCRIPT = ('/usr/bin/ssh', 'root@intranet', 'addnote', '82'); +my @PV_ID = '82'; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); @@ -97,10 +97,8 @@ for my $entry ($feed->entries) { print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; - my @tomorrow = Date::Calc::Add_Delta_Days($today[0], $today[1], $today[2], 1); - push(@PV_SCRIPT, sprintf("%04d-%02d-%02d", $tomorrow[0], $tomorrow[1], $tomorrow[2])); - rhimport::pv_add_note($sum_title, $sum_text, @PV_SCRIPT); + rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $tomorrow[0], $tomorrow[1], $tomorrow[2])); print "\n"; } } diff --git a/rhimport.pm b/rhimport.pm index 6e125d2..fbecbc1 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -329,9 +329,11 @@ sub delete_file sub pv_add_note { - my $title = shift; - my $text = shift; - my @script = @_; + my ( $title, $text, $id, $date, $type ) = @_; + $type = 'n' unless $type; + + # TODO: implement type as soon pv supports this + my @script = ('/usr/bin/ssh', 'root@intranet', 'addnote', $id, $date); my ($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); $writer->autoflush(1); |