diff options
Diffstat (limited to 'rhautoimport-rs')
-rwxr-xr-x | rhautoimport-rs | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/rhautoimport-rs b/rhautoimport-rs index 75eac79..8143977 100755 --- a/rhautoimport-rs +++ b/rhautoimport-rs @@ -59,27 +59,6 @@ if($#ARGV >= 0) { } } - -my @allowed_dbs = rhautoimport::get_dropboxes($RD_GROUP); -if(!defined $allowed_dbs[0] && defined $allowed_dbs[1]) { - print "$allowed_dbs[1]\n"; - exit 1; -} - -my $show_id = -1; -my $show_title = ""; -foreach(@allowed_dbs) { - if($_->{'NAME'} =~ /^autoimport/) { # TODO: this needs to be done differently!!! - $show_id = $_->{'SHOWID'}; - $show_title = $_->{'SHOWTITLE'}; - } -} -if($show_id < 0) { - print "no dropbox found!\n"; - exit 1; -} - - my @today = Date::Calc::Today(); print "today: " . Date::Calc::Date_to_Text(@today) . "\n"; @@ -90,15 +69,38 @@ if($dow <= $week_table{$curweek}) { print "We are in week $curweek - broadcast is on " . Date::Calc::Day_of_Week_to_Text($week_table{$curweek}) . "\n"; $import_date[2] = $week_table{$curweek}; @import_date = Date::Calc::Business_to_Standard(@import_date); + $dow = $week_table{$curweek}; } else { print "We are in week $curweek - broadcast was on " . Date::Calc::Day_of_Week_to_Text($week_table{$curweek}) . "\n"; print " next week is $nextweek - broadcast is on " . Date::Calc::Day_of_Week_to_Text($week_table{$nextweek}) . "\n"; $import_date[2] = $week_table{$nextweek}; @import_date = Date::Calc::Business_to_Standard(@import_date); @import_date = Date::Calc::Add_Delta_Days(@import_date, 7); + $dow = $week_table{$curweek}; } print "day of next Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n"; + +my @allowed_dbs = rhautoimport::get_dropboxes($RD_GROUP); +if(!defined $allowed_dbs[0] && defined $allowed_dbs[1]) { + print "$allowed_dbs[1]\n"; + exit 1; +} + +my $show_id = -1; +my $show_title = ""; +foreach(@allowed_dbs) { + if($_->{'SHOWDOW'} == $dow) { + $show_id = $_->{'SHOWID'}; + $show_title = $_->{'SHOWTITLE'}; + last + } +} +if($show_id < 0) { + print "no dropbox found!\n"; + exit 1; +} + my @broadcast_date = Date::Calc::Nth_Weekday_of_Month_Year($import_date[0], $import_date[1], 2, 1); if(Date::Calc::Delta_Days(@broadcast_date, @import_date) > 0) { my @tmp_date = Date::Calc::Nth_Weekday_of_Month_Year($import_date[0], $import_date[1], 2, 3); @@ -193,6 +195,7 @@ if($ret) { } print "\nImport Success:\n\n"; print $log; +print "\n"; rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1"); unlink($STAT_FILE); |