summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2011-01-13 23:46:16 +0000
committerOthmar Gsenger <otti@wirdorange.org>2011-01-13 23:46:16 +0000
commit68f34d6c8f62086510286960e82ca1bbff2edd6a (patch)
tree954106bec3992733b0102aec4e6b1351ad0a20c9
parentadded inital svn dirs (diff)
da files
-rwxr-xr-xenqueue.pl30
-rw-r--r--header9
-rwxr-xr-xhistory.pl32
-rwxr-xr-xlog.pl36
-rwxr-xr-xsearch.pl60
-rwxr-xr-xstatus.pl23
6 files changed, 190 insertions, 0 deletions
diff --git a/enqueue.pl b/enqueue.pl
new file mode 100755
index 0000000..5d53a28
--- /dev/null
+++ b/enqueue.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use strict;
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+
+
+require RPC::XML;
+require RPC::XML::Client;
+
+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";
+
+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));
+
+if ($resp->value)
+{
+ print CGI::redirect('/');
+} else {
+ print header;
+ print start_html('nzbget enqueue error');
+ print 'Error';
+ print end_html();
+}
+
diff --git a/header b/header
new file mode 100644
index 0000000..c4433ca
--- /dev/null
+++ b/header
@@ -0,0 +1,9 @@
+ _ ___ ___ _
+ ( ) /'___)/'___) ( )_
+ ___ | |__ _ _ _ __ __ | (__ | (__ __ _ __ _ _ ____ ___ __ | ,_)
+/',__)| _ `\ /'_` )( '__)/'__`\ | ,__)| ,__)/'_ `\( '__)/'_` )(_ ,) /' _ `\ /'__`\| |
+\__, \| | | |( (_| || | ( ___/ _ | | | | ( (_) || | ( (_| | /'/_ _ | ( ) |( ___/| |_
+(____/(_) (_)`\__,_)(_) `\____)(_)(_) (_) `\__ |(_) `\__,_)(____)(_)(_) (_)`\____)`\__)
+ ( )_) |
+ \___/'
+
diff --git a/history.pl b/history.pl
new file mode 100755
index 0000000..204329e
--- /dev/null
+++ b/history.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+use strict;
+
+require RPC::XML;
+require RPC::XML::Client;
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+use URI::Escape;
+
+print header;
+print CGI::start_html('nzbget status');
+
+my $cli = RPC::XML::Client->new('http://nzbget:tegbzn6789@127.0.0.1:6789/xmlrpc');
+my $resp = $cli->send_request('history') or die "Can't connect to nubget";
+my $i=0;
+print CGI::start_table();
+foreach my $row (@{ $resp->value})
+{
+ $i++;
+ foreach my $key (keys %$row)
+ {
+ if (ref $row->{$key} eq 'ARRAY')
+ {
+ print Tr(td([$key,(join ',',@{$row->{$key}})]));
+ } else {
+ print Tr(td([$key,$row->{$key}]));
+ }
+ }
+}
+print CGI::end_table();
+;
+print end_html;
diff --git a/log.pl b/log.pl
new file mode 100755
index 0000000..7d7c3f0
--- /dev/null
+++ b/log.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+use strict;
+
+require RPC::XML;
+require RPC::XML::Client;
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+use URI::Escape;
+
+print header;
+print start_html('nzbget status');
+
+print hr();
+my $cli = RPC::XML::Client->new('http://nzbget:tegbzn6789@127.0.0.1:6789/xmlrpc');
+print CGI::start_table();
+my $status = $cli->send_request('status') or die "Can't connect to nubget";
+print Tr(td['download speed', 'cur', int($status->{DownloadRate}->value/(1024*1024)).'MB/s','average',int($status->{AverageDownloadRate}->value/(1024*1024)).'MB/s']);
+print CGI::end_table();
+print hr();
+print CGI::start_table();
+my $resp = $cli->send_request('log',0,10) or die "Can't connect to nubget";
+foreach my $row (@{ $resp->value})
+{
+ print Tr(td[$row->{Text}]);
+# foreach my $key (keys %$row)
+# {
+# if (ref $row->{$key} eq 'ARRAY')
+# {
+# print Tr(td([$key,join(',',@{$row->{$key}})]));
+# } else {
+# print Tr(td([$key,$row->{$key}]));
+# }
+# }
+}
+print CGI::end_table();
+print end_html;
diff --git a/search.pl b/search.pl
new file mode 100755
index 0000000..8087d3e
--- /dev/null
+++ b/search.pl
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+use strict;
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+use URI::Escape;
+
+print header;
+print start_html('nzbget status');
+
+use XML::Parser;
+use XML::SimpleObject;
+print CGI::start_table();
+
+print CGI::start_form(-action=>'/cgi-bin/nzbget/search.pl');
+print table(
+ Tr(td(['Search',textfield('q'),])),
+ Tr(td(['min Size',textfield('minsize')])),
+ Tr(td(['max Size',textfield('maxsize').hidden('more',1)])),
+ Tr(td(['results',CGI::popup_menu(
+ -name => 'max',
+ -values => ['25','100','500'],
+ -default => '25',
+ -labels => {25=>'25',100=>'100',500=>500}
+ ) ])),
+ Tr(td([submit()])),
+);
+print CGI::end_form;
+if (param())
+{
+ my $request='';
+ for my $key (param) {
+ $request.= "$key=".param($key).'&';
+ }
+ $request =~ s/\&$//;
+ use LWP::Simple;
+ my $feed = get('http://nzbindex.com/rss/?'.$request);
+ die "Couldn't get connect to search site" unless defined $feed;
+ my $p1 = new XML::Parser(Style => 'Tree');
+ my $xso = XML::SimpleObject->new($p1->parse($feed));
+ my $i=0;
+ if ($xso->child('rss')->child('channel'))
+ {
+ print CGI::start_table();
+ foreach my $item ($xso->child('rss')->child('channel')->children('item')) {
+ next if not $item;
+ $i++;
+ my $title = $item->child('title')->value;
+ my $description = $item->child('description')->value;
+ my $nzburl = $item->child('enclosure')->attribute("url");
+ print Tr(td([
+ a({href=>"./enqueue.pl?url=".uri_escape($nzburl)."&name=".uri_escape(param('q'))},$title).' '.
+ a({href=>"./enqueue.pl?url=".uri_escape($nzburl)."&name=".uri_escape(param('q'))."&cat=music"},'Music').
+ $description]));
+ }
+ print CGI::end_table();
+ }
+ print hr().'nothing found' if not $i;
+}
+print end_html;
+
diff --git a/status.pl b/status.pl
new file mode 100755
index 0000000..3877f4b
--- /dev/null
+++ b/status.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+use strict;
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+print header;
+print start_html('nzbget status');
+
+require RPC::XML;
+require RPC::XML::Client;
+
+my $cli = RPC::XML::Client->new('http://nzbget:tegbzn6789@127.0.0.1:6789/xmlrpc');
+my $row = $cli->send_request('status') or die "Can't connect to nubget";
+
+print CGI::start_table();
+foreach my $key (keys %$row)
+{
+ print Tr(td([$key,$row->{$key}->value]));
+}
+;
+print CGI::end_table();
+
+print end_html;
+