diff options
author | Othmar Gsenger <otti@wirdorange.org> | 2011-01-14 03:50:24 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@wirdorange.org> | 2011-01-14 03:50:24 +0000 |
commit | 389a32204546ce812f04cf990725c18ee5514ecc (patch) | |
tree | 99ccea390cad9bfedbcc5bfcc9ff01dfa8a9d13d /enqueue.pl | |
parent | added modules (diff) |
added database support
Diffstat (limited to 'enqueue.pl')
-rwxr-xr-x | enqueue.pl | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -2,21 +2,27 @@ use strict; use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; +use local::db; +use local::nzbget; +use local::user; +my $user = new local::user($ENV{REMOTE_USER}); +my $nzbget = new local::nzbget; -require RPC::XML; -require RPC::XML::Client; +my $cat = local::db::category->retrieve(name=>param('cat')); +die "Ungültige category" if not $cat; -my $cli = RPC::XML::Client->new('http://nzbget:tegbzn6789@127.0.0.1:6789/xmlrpc'); -my $resp = $cli->send_request('version') or die "Can't connect to nubget"; +my $category = $cat->name(); +my ($size) = param('description') =~ m/<b>(.*)<\/b>/; +$size = 0; +my $download = local::db::download->insert({owner=>$user->get_id(),name=>param('name'),category=>param('cat'),description=>param('title'),size=>$size}); use LWP::Simple; my $nzb = get(param('url')); die "Couldn't get ".param('url') unless defined $nzb; use MIME::Base64; $nzb = encode_base64($nzb); -my $category = param('cat') || 'test'; -$resp = $cli->send_request('append',RPC::XML::string->new(param('name')),RPC::XML::string->new($category),RPC::XML::boolean->new(0),RPC::XML::string->new($nzb)); +my $resp = $nzbget->send_request('append',RPC::XML::string->new($download->download_id()),RPC::XML::string->new($category),RPC::XML::boolean->new(0),RPC::XML::string->new($nzb)); if ($resp->value) { |