Permalink
Browse files

added ReverseHTTP Script for using Red Laser - iPhone App

  • Loading branch information...
JEEN
JEEN committed Jan 18, 2010
1 parent 3fdddc0 commit 70ab3fa58e57a44ebf5e5e8c25d8e197fa6b01e7
Showing with 31 additions and 0 deletions.
  1. +31 −0 bin/ptth.pl
View
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use AnyEvent::ReverseHTTP;
+use DL2::Controller;
+use Data::Dumper;
+my $name = $ARGV[0];
+
+my $guard = AnyEvent::ReverseHTTP->new(
+ label => $name,
+ token => '-',
+ on_request => \&handle_request,
+)->connect;
+
+AnyEvent->condvar->recv;
+
+sub handle_request {
+ my $req = shift;
+
+ my $uri = $req->uri;
+ my ($code) = $uri =~ /q=(.+)$/;
+
+ if ($code) {
+ my $res = DL2::Controller->new({ keyword => $code });
+ $res->update;
+ if (!$res->is_error) {
+ printf("%s => %s\n", $code, $res->get_item->{title});
+ }
+ }
+}

0 comments on commit 70ab3fa

Please sign in to comment.