| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Strike::Torrent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
19319
|
use 5.014000; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
77
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
99
|
|
|
5
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
95
|
|
|
6
|
2
|
|
|
2
|
|
641
|
use parent qw/Class::Accessor::Fast/; |
|
|
2
|
|
|
|
|
271
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.004002'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
7364
|
use Date::Parse qw/str2time/; |
|
|
2
|
|
|
|
|
13818
|
|
|
|
2
|
|
|
|
|
348
|
|
|
11
|
2
|
|
|
2
|
|
652
|
use JSON::MaybeXS qw/decode_json/; |
|
|
2
|
|
|
|
|
8030
|
|
|
|
2
|
|
|
|
|
111
|
|
|
12
|
2
|
|
|
2
|
|
1068
|
use MIME::Base64; |
|
|
2
|
|
|
|
|
1170
|
|
|
|
2
|
|
|
|
|
128
|
|
|
13
|
2
|
|
|
2
|
|
496
|
use WebService::Strike; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
232
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__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/); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
|
18
|
2
|
|
|
2
|
|
7
|
*hash = *torrent_hash; |
|
19
|
2
|
|
|
|
|
3
|
*title = *torrent_title; |
|
20
|
2
|
|
|
|
|
2
|
*category = *torrent_category; |
|
21
|
2
|
|
|
|
|
2
|
*count = *file_count; |
|
22
|
2
|
|
|
|
|
2
|
*date = *upload_date; |
|
23
|
2
|
|
|
|
|
3
|
*uploader = *uploader_username; |
|
24
|
2
|
|
|
|
|
2
|
*names = *file_names; |
|
25
|
2
|
|
|
|
|
2
|
*lengths = *file_lengths; |
|
26
|
2
|
|
|
|
|
698
|
*magnet = *magnet_uri; |
|
27
|
|
|
|
|
|
|
}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new{ |
|
30
|
206
|
|
|
206
|
1
|
359
|
my ($self, @args) = @_; |
|
31
|
206
|
|
|
|
|
653
|
$self = $self->SUPER::new(@args); |
|
32
|
206
|
|
|
|
|
3644
|
$self->{torrent_hash} = uc $self->hash; |
|
33
|
206
|
|
|
|
|
1214
|
$self->{upload_date} = str2time $self->date, 'UTC'; |
|
34
|
206
|
100
|
|
|
|
42690
|
if ($self->file_info) { |
|
35
|
6
|
|
|
|
|
41
|
$self->{file_names} = $self->file_info->{file_names}; |
|
36
|
6
|
|
|
|
|
29
|
$self->{file_lengths} = $self->file_info->{file_lengths}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
206
|
100
|
|
|
|
1248
|
$self->{imdb_id} = $self->{imdbid} if $self->{imdbid}; |
|
39
|
206
|
|
|
|
|
710
|
$self |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub torrent{ |
|
43
|
1
|
|
|
1
|
1
|
6513
|
my ($self, $file) = @_; |
|
44
|
1
|
|
|
|
|
6
|
my $url = $WebService::Strike::BASE_URL . '/torrents/download/?hash=' . $self->hash; |
|
45
|
1
|
|
|
|
|
9
|
my $ht = WebService::Strike::_ht(); ## no critic (ProtectPrivate) |
|
46
|
1
|
|
|
|
|
252
|
my $response = $ht->get($url); |
|
47
|
1
|
50
|
|
|
|
128194
|
return unless $response->{success}; |
|
48
|
1
|
|
|
|
|
17
|
$response = decode_json $response->{content}; |
|
49
|
1
|
|
|
|
|
8
|
$url = $response->{message}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
6
|
if (defined $file) { |
|
52
|
0
|
|
|
|
|
0
|
$response = $ht->mirror($url, $file); |
|
53
|
0
|
|
|
|
|
0
|
return $response->{success} |
|
54
|
|
|
|
|
|
|
} else { |
|
55
|
1
|
|
|
|
|
69
|
$response = $ht->get($url); |
|
56
|
1
|
|
33
|
|
|
17517
|
return $response->{success} && $response->{content} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub description{ |
|
61
|
1
|
|
|
1
|
1
|
3768
|
my ($self) = @_; |
|
62
|
1
|
50
|
|
|
|
7
|
return $self->{description} if $self->{description}; |
|
63
|
1
|
|
|
|
|
12
|
my $url = $WebService::Strike::BASE_URL . '/torrents/descriptions/?hash=' . $self->hash; |
|
64
|
1
|
|
|
|
|
15
|
my $ht = WebService::Strike::_ht(); ## no critic (ProtectPrivate) |
|
65
|
1
|
|
|
|
|
150
|
my $response = $ht->get($url); |
|
66
|
1
|
50
|
|
|
|
289314
|
return unless $response->{success}; |
|
67
|
1
|
|
|
|
|
40
|
$self->{description} = decode_base64 $response->{content} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub imdb { |
|
71
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
|
72
|
1
|
50
|
|
|
|
4
|
return unless $self->imdb_id; |
|
73
|
1
|
|
33
|
|
|
13
|
$self->{imdb} //= WebService::Strike::strike_imdb ($self->imdb_id) |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
__END__ |