From 9373c383b78f0ed647ca6cade3c2c6d44b98b488 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 2 Jun 2016 13:45:38 +0200 Subject: fixed last-run warning, not importing notes in legacy importer... diff --git a/rhimport-er b/rhimport-er index 7b1e52f..a91cf04 100755 --- a/rhimport-er +++ b/rhimport-er @@ -45,13 +45,19 @@ my $STAT_FILE = $ENV{'HOME'} . "/rhimport-er.stat"; my $LAST_FILE = $ENV{'HOME'} . "/rhimport-er.last"; my $RSS_URL = "https://cba.fro.at/series/ergo/feed?c=Kfs2IoV2Wmd"; my $PV_ID = '569'; +my $LAST_RUN = 0; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); -if($#ARGV >= 0 && $ARGV[0] eq 'last') { - print "!!!This is the last attempt, there won't be a retry on error!!!\n" +my $curweek = rhimport::get_rd_week(); + +if($curweek == 1 || $curweek == 3) { + if($#ARGV >= 0 && $ARGV[0] eq 'last') { + print "!!!This is the last attempt, there won't be a retry on error!!!\n"; + $LAST_RUN = 1; + } } my $user = `/usr/bin/id -un`; @@ -69,8 +75,6 @@ if(scalar(@allowed_dbs) != 1) { my $dropbox = $allowed_dbs[0]->{'PATH'}; my $to_cart = $allowed_dbs[0]->{'TO_CART'}; -my $curweek = rhimport::get_rd_week(); - my @today = Date::Calc::Today(); my @import_date = Date::Calc::Standard_to_Business(@today); $import_date[2] = 5; @@ -127,7 +131,6 @@ for my $entry ($feed->entries) { my $sum_title = decode_entities($entry->title); next unless $sum_title =~ /$bdnumexp/; - my $sum_text = decode_entities($entry->content->body); if($max_broadcast_num < $1) { $max_broadcast_num = $1; @@ -150,11 +153,6 @@ for my $entry ($feed->entries) { die "wget returned with error: " . $!; } print "ok\n"; - - print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; - - rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1"); - last; } } @@ -162,7 +160,7 @@ for my $entry ($feed->entries) { } if($file eq "" || !(-e "$file")) { print "No Entry found for #$broadcast_num or download error - "; - if($#ARGV >= 0 && $ARGV[0] eq 'last') { + if($LAST_RUN) { print "giving up, manual import necessary!!!\n"; } else { print "will retry later\n"; diff --git a/rhimport-wr b/rhimport-wr index 89c0b54..2fd1089 100755 --- a/rhimport-wr +++ b/rhimport-wr @@ -47,13 +47,20 @@ my $STAT_FILE = $ENV{'HOME'} . "/rhimport-wr.stat"; my $RSS_URL = "https://cba.fro.at/series/werkstatt-radio/feed?c=Kfs2IoV2Wmd"; $XML::Feed::MULTIPLE_ENCLOSURES=1; my $PV_ID = '567'; +my $LAST_RUN = 0; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); -if($#ARGV >= 0 && $ARGV[0] eq 'last') { - print "!!!This is the last attempt, there won't be a retry on error!!!\n" + +my $curweek = rhimport::get_rd_week(); + +if($curweek == 1 || $curweek == 3) { + if($#ARGV >= 0 && $ARGV[0] eq 'last') { + print "!!!This is the last attempt, there won't be a retry on error!!!\n"; + $LAST_RUN = 1; + } } my $user = `/usr/bin/id -un`; @@ -72,7 +79,6 @@ if(scalar(@allowed_dbs) != 1) { my $dropbox = $allowed_dbs[$idx]->{'PATH'}; my $to_cart = $allowed_dbs[$idx]->{'TO_CART'}; -my $curweek = rhimport::get_rd_week(); my @today = Date::Calc::Today(); print "today: " . Date::Calc::Date_to_Text(@today) . " (Week: " . $curweek . ")\n"; @@ -137,9 +143,6 @@ for my $entry ($feed->entries) { my $url = new URI::URL($fetchurl); my @path = $url->path_components; - my $sum_title = decode_entities($entry->title); - my $sum_text = decode_entities($entry->content->body); - my $current_stat = `cat $STAT_FILE`; my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/; if($current_id eq $id && $current_file eq $path[-1]) { @@ -162,11 +165,6 @@ for my $entry ($feed->entries) { } print "ok\n"; - print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; - - rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1"); - print "\n"; - last; } } @@ -175,7 +173,7 @@ for my $entry ($feed->entries) { if($file eq "" || !(-e "$file")) { print "No Entry found from $bd or download error - "; - if($#ARGV >= 0 && $ARGV[0] eq 'last') { + if($LAST_RUN) { print "giving up, manual import necessary!!!\n"; } else { print "will retry later\n"; -- cgit v0.10.2