summaryrefslogtreecommitdiff
path: root/local/nzbindex.pm
diff options
context:
space:
mode:
Diffstat (limited to 'local/nzbindex.pm')
-rwxr-xr-xlocal/nzbindex.pm46
1 files changed, 46 insertions, 0 deletions
diff --git a/local/nzbindex.pm b/local/nzbindex.pm
new file mode 100755
index 0000000..8352a5d
--- /dev/null
+++ b/local/nzbindex.pm
@@ -0,0 +1,46 @@
+package local::nzbget;
+require Exporter;
+use strict;
+use base "Exporter";
+use URI::Escape;
+use XML::Parser;
+use XML::SimpleObject;
+use LWP::Simple;
+
+sub new
+{
+ my $invocant = shift;
+ my $class = ref($invocant) || $invocant;
+ # my $self = $class->SUPER::new(@_);
+ my $self=bless {@_}, $class;
+ return $self;
+}
+
+sub search
+{
+ my $self=shift;
+ my %params=@_;
+ my @result;
+ my $request='';
+ for my $key (keys %params) {
+ $request.= uri_escape($key)."=".$params{$key}.'&';
+ }
+ $request =~ s/\&$//;
+ 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));
+ if ($xso->child('rss')->child('channel'))
+ {
+ print CGI::start_table();
+ foreach my $item ($xso->child('rss')->child('channel')->children('item')) {
+ next if not $item;
+ my $title = $item->child('title')->value;
+ my $description = $item->child('description')->value;
+ my $nzburl = $item->child('enclosure')->attribute("url");
+ push @result,{url=>$nzburl,title=>$title,description=>$description};
+ }
+ }
+ return @result;
+}
+