]> iEval git - webservice-strike.git/blobdiff - lib/WebService/Strike/Torrent.pm
Bump version and update Changes
[webservice-strike.git] / lib / WebService / Strike / Torrent.pm
index 517020850a82aa33b2d098ddf4466573ac2ae7e4..0ac15da98ab7571ed27bde46d2dc4e29664ad8f7 100644 (file)
@@ -5,14 +5,14 @@ use strict;
 use warnings;
 use parent qw/Class::Accessor::Fast/;
 
 use warnings;
 use parent qw/Class::Accessor::Fast/;
 
-our $VERSION = '0.003';
+our $VERSION = '0.004002';
 
 use Date::Parse qw/str2time/;
 use JSON::MaybeXS qw/decode_json/;
 use MIME::Base64;
 use WebService::Strike;
 
 
 use Date::Parse qw/str2time/;
 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;
 
 BEGIN {
        *hash     = *torrent_hash;
@@ -35,12 +35,13 @@ sub new{
                $self->{file_names} = $self->file_info->{file_names};
                $self->{file_lengths} = $self->file_info->{file_lengths};
        }
                $self->{file_names} = $self->file_info->{file_names};
                $self->{file_lengths} = $self->file_info->{file_lengths};
        }
+       $self->{imdb_id} = $self->{imdbid} if $self->{imdbid};
        $self
 }
 
 sub torrent{
        my ($self, $file) = @_;
        $self
 }
 
 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};
        my $ht = WebService::Strike::_ht(); ## no critic (ProtectPrivate)
        my $response = $ht->get($url);
        return unless $response->{success};
@@ -59,13 +60,19 @@ sub torrent{
 sub description{
        my ($self) = @_;
        return $self->{description} if $self->{description};
 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}
 }
 
        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__
 
 1;
 __END__
 
@@ -96,6 +103,13 @@ WebService::Strike::Torrent - Class representing information about a torrent
   $t->torrent('x.torrent'); # Download torrent file to x.torrent
   say $t->description;      # <HTML fragment describing Arch Linux>
 
   $t->torrent('x.torrent'); # Download torrent file to x.torrent
   say $t->description;      # <HTML fragment describing Arch Linux>
 
+  $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
 =head1 DESCRIPTION
 
 WebService::Strike::Torrent is a class that represents information
@@ -170,6 +184,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.
 
 The description of the torrent. This method sends an extra request to
 Strike. Successful responses are cached.
 
+=item B<imdb_id>
+
+The IMDB ID of the torrent, or undef if the torrent has no associated
+IMDB ID.
+
+=item B<imdb>
+
+Calls B<strike_imdb> from L<WebService::Strike> on B<imdb_id>. Caches
+the response. Returns undef if the torrent has no associated IMDB ID.
+
 =back
 
 =head1 SEE ALSO
 =back
 
 =head1 SEE ALSO
This page took 0.032587 seconds and 4 git commands to generate.