X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FWebService%2FStrike.pm;fp=lib%2FWebService%2FStrike.pm;h=001972de9a8c71542ab90c48b40b81860703d34d;hb=0eff1663d01977542009b247f9632a891d8a6a87;hp=74a8c2b30ab05bc82315d92c245944b0bcce6614;hpb=d932afd835dfedc68511a0b80cc84d5fd0eac91d;p=webservice-strike.git diff --git a/lib/WebService/Strike.pm b/lib/WebService/Strike.pm index 74a8c2b..001972d 100644 --- a/lib/WebService/Strike.pm +++ b/lib/WebService/Strike.pm @@ -5,10 +5,10 @@ use strict; use warnings; use parent qw/Exporter/; -our @EXPORT = qw/strike strike_search/; ## no critic (ProhibitAutomaticExportation) -our @EXPORT_OK = qw/strike_query strike strike_search/; +our @EXPORT = qw/strike strike_search strike_imdb/; ## no critic (ProhibitAutomaticExportation) +our @EXPORT_OK = (@EXPORT, 'strike_query'); our $VERSION = '0.003'; -our $BASE_URL = 'https://getstrike.net/api/v2/torrents'; +our $BASE_URL = 'https://getstrike.net/api/v2'; use JSON::MaybeXS qw/decode_json/; use HTTP::Tiny; @@ -33,7 +33,7 @@ sub strike_query { if (@hashes > 50) { return strike_query (@hashes[0 .. 49]), strike_query (@hashes[50 .. $#hashes]); } - my $url = "$BASE_URL/info/?hashes=" . join ',', map { uc } @hashes; + my $url = "$BASE_URL/torrents/info/?hashes=" . join ',', map { uc } @hashes; my $sorter = sbe(\@hashes, {xform => sub { $_[0]->hash }}); my @torrents = $sorter->(_query $url); @@ -43,7 +43,7 @@ sub strike_query { sub strike_search { my ($query, $full, %args) = @_; $args{phrase} = $query; - my $url = "$BASE_URL/search/?" . HTTP::Tiny->www_form_urlencode(\%args); + my $url = "$BASE_URL/torrents/search/?" . HTTP::Tiny->www_form_urlencode(\%args); my @torrents = _query $url; @torrents = $torrents[0] unless wantarray; @@ -51,6 +51,14 @@ sub strike_search { wantarray ? @torrents : $torrents[0] } +sub strike_imdb { + my ($id) = @_; + my $url = "$BASE_URL/media/imdb/?imdbid=$id"; + my $response = _ht->get($url); + return unless $response->{success}; + decode_json $response->{content} +} + BEGIN { *strike = \&strike_query } 1; @@ -79,6 +87,10 @@ WebService::Strike - Get torrent info from getstrike.net API say 'Torrent has ' . $mp->count . ' files. They are:'; say join ' ', @{$mp->file_names}; + my $info = strike_imdb 'tt1520211'; + say 'IMDB ID ', $info->{imdbID}, ' is ', $info->{title}, ' (', $info->{year}, ')'; + say 'Plot (short): ', $info->{shortPlot}; + =head1 DESCRIPTION Strike API is a service for getting information about a torrent given @@ -114,6 +126,11 @@ For example: strike_search 'windows', 0, category => 'Applications', sub_category => 'Windows'; +=item B(I<$imdb_id>) + +Get informaton about a movie from IMDB. Takes an IMDB ID and returns a +hashef of unspecified format. + =back =head1 SEE ALSO