diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-09-26 20:40:24 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-09-26 20:40:24 (GMT) |
commit | 81531b51fe70fee446d22d3505d04709cd7b5b8a (patch) | |
tree | 782e0ebbc4ae0ec451219e8072aa0dbbe701b4e7 /rhimport-zffe | |
parent | eb3f9d2ca6675997311307308437c8bddde59a64 (diff) |
renamed rhimport to rhautoimport
Diffstat (limited to 'rhimport-zffe')
-rwxr-xr-x | rhimport-zffe | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/rhimport-zffe b/rhimport-zffe deleted file mode 100755 index a896551..0000000 --- a/rhimport-zffe +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/perl -w -# -# -# rhimport -# -# Copyright (C) 2009-2015 Christian Pointner <equinox@helsinki.at> -# -# This file is part of rhimport. -# -# rhimport is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# rhimport is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rhimport. If not, see <http://www.gnu.org/licenses/>. -# - -use strict; -use Switch; -use Date::Calc; -use Time::localtime; -use IO::Handle; -use IPC::Open3; -use File::Slurp; - -use lib '/usr/local/share/rhimport/'; -use rhimport; - -my $STAT_FILE = $ENV{'HOME'} . "/rhimport-zffe.stat"; -my $ZF_NOTE_FILE = $ENV{'HOME'} . "/rhimport-zf.last_note"; -my $ZF_NEW_FILE = $ENV{'HOME'} . "/rhimport-zf.is_new"; -my $FE_NOTE_FILE = $ENV{'HOME'} . "/rhimport-fe.last_note"; -my $FE_NEW_FILE = $ENV{'HOME'} . "/rhimport-fe.is_new"; -my $PV_ID = '359'; - -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 @today = Date::Calc::Today(); -my $dow = Date::Calc::Day_of_Week(@today); -my @tomorrow = Date::Calc::Add_Delta_Days($today[0], $today[1], $today[2], 1); - -my @tmp = Date::Calc::Standard_to_Business(@today); -$tmp[2] = 1; -my @this_mon = Date::Calc::Business_to_Standard(@tmp); -my @next_mon = Date::Calc::Add_Delta_Days($this_mon[0], $this_mon[1], $this_mon[2], 7); - -my @import_day = @tomorrow; -if ($dow == 5) { - @import_day = @next_mon; -} - -my $import_date = sprintf("%04d-%02d-%02d", @import_day); -my $current_date = `cat $STAT_FILE`; -if($current_date eq $import_date) { - print "Already created note of today\n"; - exit 0; -} - -unless(-e $ZF_NEW_FILE) { - print "zip-fm not yet imported - "; - if($#ARGV >= 0 && $ARGV[0] eq 'last') { - print "giving up, rebroadcasting last show"; - } else { - print "will retry later\n"; - exit 0, - } -} - -unless(-e $FE_NEW_FILE) { - print "focus europa not yet imported - "; - if($#ARGV >= 0 && $ARGV[0] eq 'last') { - print "giving up, rebroadcasting last show"; - } else { - print "will retry later\n"; - exit 0, - } -} - -sub get_note { - my ($file) = @_; - my @lines = read_file($file, binmode => ':utf8', err_mode => 'quiet'); - return "" unless ($lines[0]); - - chomp($lines[0]); - $lines[0] = "<p><strong>$lines[0]</strong></p>\n"; - return join('',@lines); -}; - -my $sum_title = "focus europa, zip-fm (WH)"; -my $sum_text = get_note($FE_NOTE_FILE) . "<br/>\n"; -$sum_text = $sum_text . "<br/>\n" . get_note($ZF_NOTE_FILE) . "<br/>\n"; -$sum_text = $sum_text . "<br/><br/>\n"; - -print "\nsummary:\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"); -print "\n"; - -unlink($STAT_FILE); -open(my $fhs, '>', $STAT_FILE); -print $fhs $import_date; -close($fhs); - -unlink($ZF_NEW_FILE); -unlink($FE_NEW_FILE); - -exit 0; |