diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-24 19:01:55 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-24 19:01:55 (GMT) |
commit | 6761a44cfb25af3f923a53375f05e75e8570403d (patch) | |
tree | 5bb59562bae08a0edf8ea71c62d89f635b6213a7 /rhimport-sm | |
parent | d9df4264e66e6091538ab24c41fad20131526460 (diff) |
switch to use systemwide RHRD perl module
Diffstat (limited to 'rhimport-sm')
-rwxr-xr-x | rhimport-sm | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/rhimport-sm b/rhimport-sm index 9c3f475..252d72e 100755 --- a/rhimport-sm +++ b/rhimport-sm @@ -32,6 +32,7 @@ use IO::Handle; use IPC::Open3; use HTML::Entities; use LWP::Simple; +use RHRD::rddb; use lib '/usr/local/share/rhimport/'; use rhimport; @@ -53,16 +54,20 @@ my $user = `/usr/bin/id -un`; $user =~ s/\n//; my $group = "soundsmove"; -my ($dbh, $errorstring) = rhimport::opendb(); +my ($dbh, $errorstring) = RHRD::rddb::opendb(); if(!defined $dbh) { print "$errorstring\n"; exit 1; } -my @allowed_dbs = rhimport::get_dropboxes($dbh, $user, $group); +my @allowed_dbs = RHRD::rddb::get_dropboxes($dbh, $user, $group); +if(!defined $allowed_dbs[0] && defined $allowed_dbs[2]) { + print "$allowed_dbs[2]\n"; + exit 1; +} if(scalar(@allowed_dbs) != 1) { print "found more or less than one Dropbox for this group?!\n"; - rhimport::closedb($dbh); + RHRD::rddb::closedb($dbh); exit 1; } my $dropbox = $allowed_dbs[0]->{'PATH'}; @@ -76,7 +81,7 @@ if(($curweek != 1 && $curweek != 4) || ($curweek == 1 && $dow > 3) || ($curweek == 4 && $dow <= 3)) { print "File won't be available by now!\n"; - rhimport::closedb($dbh); + RHRD::rddb::closedb($dbh); exit 0; } print "today: " . Date::Calc::Date_to_Text(@today) . "\n"; @@ -98,7 +103,7 @@ print "day of latest original broadcast before next Radio Helsinki broadcast: " if(Date::Calc::Delta_Days(@broadcast_date, @today) <= 0) { print "File won't be available by now!\n"; - rhimport::closedb($dbh); + RHRD::rddb::closedb($dbh); exit 0; } @@ -138,13 +143,13 @@ for my $entry ($feed->entries) { my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/; if($current_id eq $id && $current_file eq $ff->output_file) { print "Already downloaded file of today\n"; - rhimport::closedb($dbh); + RHRD::rddb::closedb($dbh); exit 0; } $out_file = $ff->output_file; if(!rhimport::check_file_extension($out_file)) { print "\n\nThe extension of the matching file '". $out_file . "' seems to be wrong - manual import necessary!!!\n"; - rhimport::closedb($dbh); + RHRD::rddb::closedb($dbh); exit 1; } @@ -190,7 +195,7 @@ my $import_log; ($ret, $import_log) = rhimport::import_single($file, $dropbox, $user, 0, $error_cb); $log .= $import_log; -rhimport::closedb($dbh); +RHRD::rddb::closedb($dbh); unlink $file; |