X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FWebService%2FStrike%2FTorrent.pm;fp=lib%2FWebService%2FStrike%2FTorrent.pm;h=655efed730701574145e57263c6c870bc32f2156;hb=0eff1663d01977542009b247f9632a891d8a6a87;hp=517020850a82aa33b2d098ddf4466573ac2ae7e4;hpb=d932afd835dfedc68511a0b80cc84d5fd0eac91d;p=webservice-strike.git diff --git a/lib/WebService/Strike/Torrent.pm b/lib/WebService/Strike/Torrent.pm index 5170208..655efed 100644 --- a/lib/WebService/Strike/Torrent.pm +++ b/lib/WebService/Strike/Torrent.pm @@ -12,7 +12,7 @@ use JSON::MaybeXS qw/decode_json/; use MIME::Base64; use WebService::Strike; -__PACKAGE__->mk_ro_accessors(qw/torrent_hash torrent_title torrent_category sub_category seeds leeches file_count size upload_date uploader_username file_info file_names file_lengths magnet_uri/); +__PACKAGE__->mk_ro_accessors(qw/torrent_hash torrent_title torrent_category sub_category seeds leeches file_count size upload_date uploader_username file_info file_names file_lengths magnet_uri imdb_id/); BEGIN { *hash = *torrent_hash; @@ -40,7 +40,7 @@ sub new{ sub torrent{ my ($self, $file) = @_; - my $url = $WebService::Strike::BASE_URL . '/download/?hash=' . $self->hash; + my $url = $WebService::Strike::BASE_URL . '/torrents/download/?hash=' . $self->hash; my $ht = WebService::Strike::_ht(); ## no critic (ProtectPrivate) my $response = $ht->get($url); return unless $response->{success}; @@ -59,13 +59,19 @@ sub torrent{ sub description{ my ($self) = @_; return $self->{description} if $self->{description}; - my $url = $WebService::Strike::BASE_URL . '/descriptions/?hash=' . $self->hash; + my $url = $WebService::Strike::BASE_URL . '/torrents/descriptions/?hash=' . $self->hash; my $ht = WebService::Strike::_ht(); ## no critic (ProtectPrivate) my $response = $ht->get($url); return unless $response->{success}; $self->{description} = decode_base64 $response->{content} } +sub imdb { + my ($self) = @_; + return unless $self->imdb_id; + $self->{imdb} //= WebService::Strike::strike_imdb ($self->imdb_id) +} + 1; __END__ @@ -96,6 +102,13 @@ WebService::Strike::Torrent - Class representing information about a torrent $t->torrent('x.torrent'); # Download torrent file to x.torrent say $t->description; # + $t = strike 'ED70C185E3E3246F30B2FDB08D504EABED5EEA3F'; + say $t->title; # The Walking Dead S04E15 HDTV x264-2HD + say $t->imdb_id; # tt1520211 + my $i = $t->imdb; + say $i->{title}, ' (', $i->{year}, ')'; # The Walking Dead (2010) + say $i->{genre}; # Drama, Horror, Thriller + =head1 DESCRIPTION WebService::Strike::Torrent is a class that represents information @@ -170,6 +183,16 @@ Both forms return a true value for success and false for failure. The description of the torrent. This method sends an extra request to Strike. Successful responses are cached. +=item B + +The IMDB ID of the torrent, or undef if the torrent has no associated +IMDB ID. + +=item B + +Calls B from L on B. Caches +the response. Returns undef if the torrent has no associated IMDB ID. + =back =head1 SEE ALSO