line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Search::Torrentz; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
819925
|
use 5.014000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
6
|
1
|
|
|
1
|
|
5
|
no if $] >= 5.018, warnings => 'experimental::smartmatch'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
512
|
use parent qw/WWW::Search/; |
|
1
|
|
|
|
|
323
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
68
|
use re '/s'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
88
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.001003'; |
11
|
|
|
|
|
|
|
our $MAINTAINER = 'Marius Gavrilescu '; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
396
|
use WWW::Search::Torrentz::Result; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
764
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
0
|
0
|
sub debug { say STDERR @_ } ## no critic (RequireCheckedSyscalls) |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
0
|
sub gui_query{ shift->native_query(@_) } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _native_setup_search{ ## no critic (ProhibitUnusedPrivateSubroutines) |
20
|
2
|
|
|
2
|
|
2023690
|
my ($self, $native_query, $options) = @_; |
21
|
2
|
|
|
|
|
12
|
$self->agent_email('marius@ieval.ro'); |
22
|
2
|
|
50
|
|
|
24
|
$options //= {}; |
23
|
2
|
|
50
|
|
|
13
|
my $base_url = $options->{search_url} // 'https://torrentz.eu/search'; |
24
|
2
|
|
|
|
|
5
|
$self->{search_debug} = $options->{search_debug}; |
25
|
2
|
|
|
|
|
8
|
$self->{_next_url} = "$base_url?f=$native_query"; |
26
|
2
|
|
|
|
|
12
|
$self->user_agent->delay(2/60); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
|
sub fullint ($) { int (shift =~ y/0-9//cdr) } ## no critic (ProhibitSubroutinePrototypes) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _parse_tree{ ## no critic (ProhibitUnusedPrivateSubroutines) |
32
|
0
|
|
|
0
|
|
|
my ($self, $tree) = @_; |
33
|
0
|
|
|
|
|
|
my $found = 0; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @potential_results = $tree->find('dl'); |
36
|
0
|
|
|
|
|
|
my $result_count = $tree->find('h2')->as_text; |
37
|
0
|
0
|
0
|
|
|
|
if (defined $result_count && $result_count ne 'No Torrents Found') { |
38
|
0
|
|
|
|
|
|
$result_count =~ s/orrents.*//; |
39
|
0
|
|
|
|
|
|
$self->approximate_result_count(fullint $result_count); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
for my $node (@potential_results) { |
43
|
0
|
|
|
|
|
|
my $a = $node->find('a'); |
44
|
0
|
0
|
|
|
|
|
next unless defined $a; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $infohash = substr $a->attr('href'), 1; |
47
|
0
|
0
|
|
|
|
|
next unless $infohash =~ /^[a-f0-9]{40}$/; |
48
|
0
|
|
|
|
|
|
my $title = $a->as_text; |
49
|
0
|
|
|
|
|
|
my ($verified, $age, $size, $seeders, $leechers); |
50
|
0
|
|
|
|
|
|
$verified = 0; |
51
|
0
|
|
|
|
|
|
for my $span ($node->find('span')) { |
52
|
0
|
|
|
|
|
|
given($span->attr('class')){ |
53
|
0
|
|
|
|
|
|
$verified = int ($span->as_text =~ /^\d+/) when 'v'; |
54
|
0
|
|
|
|
|
|
$age = $span->as_text when 'a'; |
55
|
0
|
|
|
|
|
|
$size = $span->as_text when 's'; |
56
|
0
|
|
|
|
|
|
$seeders = fullint $span->as_text when 'u'; |
57
|
0
|
|
|
|
|
|
$leechers = fullint $span->as_text when 'd'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
push @{$self->{cache}}, WWW::Search::Torrentz::Result->new(infohash => $infohash, title => $title, verified => $verified, age => $age, size => $size, seeders => $seeders, leechers => $leechers, ua => $self->user_agent); |
|
0
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
debug "infohash => $infohash, title => $title, verified => $verified, age => $age, size => $size, seeders => $seeders, leechers => $leechers" if $self->{search_debug}; |
63
|
0
|
|
|
|
|
|
$found++; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $url = $tree->look_down(rel => 'next'); |
67
|
0
|
0
|
|
|
|
|
if (defined $url) { |
68
|
0
|
|
|
|
|
|
my $prev = $self->{_prev_url} =~ s{/[^/]+$}{}r; |
69
|
0
|
|
|
|
|
|
$self->{_next_url} = $prev . $url->attr('href') |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
debug "Found: $found" if $self->{search_debug}; |
72
|
0
|
|
|
|
|
|
return $found; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |