line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Opentracker::Stats::Mode::Top10; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
72728
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
7
|
use parent qw/ |
7
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode |
8
|
|
|
|
|
|
|
Class::Accessor::Fast |
9
|
1
|
|
|
1
|
|
2855
|
/; |
|
1
|
|
|
|
|
382
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->_format('txt'); |
13
|
|
|
|
|
|
|
__PACKAGE__->_mode('top10'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/_stats/); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode::Top10 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Parses the top 10 statistics from opentracker. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 parse_stats |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Args: $self, $payload |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Decodes the plain text data retrieved from the top 10 statistics of |
33
|
|
|
|
|
|
|
opentracker. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The payload looks like this (no indentation): |
36
|
|
|
|
|
|
|
Top 10 torrents by peers: |
37
|
|
|
|
|
|
|
44 8C18F57626C3D514E5CFD9B991EF0D723059D0E0 |
38
|
|
|
|
|
|
|
36 644AA544E92C6C4F498437FCD0A08D8401F55A55 |
39
|
|
|
|
|
|
|
11 9CAD13D1C771069F36634682F02233018A582B8B |
40
|
|
|
|
|
|
|
11 BE4C3155BB0709DFE5475BC938CE15BF5D6E9EC8 |
41
|
|
|
|
|
|
|
10 0EAA0651DFBA2DF49C8E96E252527FC79F648A1E |
42
|
|
|
|
|
|
|
10 6DD48BFFD481D905E33F331689CE13B27DD42FFD |
43
|
|
|
|
|
|
|
10 BEE8EDA4916BCD7A7ABB6AACADC4EA18F4855B3D |
44
|
|
|
|
|
|
|
9 C407ECB3D0ACF0D0E01488960005B844BFCF2F03 |
45
|
|
|
|
|
|
|
Top 10 torrents by seeds: |
46
|
|
|
|
|
|
|
44 8C18F57626C3D514E5CFD9B991EF0D723059D0E0 |
47
|
|
|
|
|
|
|
36 644AA544E92C6C4F498437FCD0A08D8401F55A55 |
48
|
|
|
|
|
|
|
11 9CAD13D1C771069F36634682F02233018A582B8B |
49
|
|
|
|
|
|
|
11 BE4C3155BB0709DFE5475BC938CE15BF5D6E9EC8 |
50
|
|
|
|
|
|
|
10 0EAA0651DFBA2DF49C8E96E252527FC79F648A1E |
51
|
|
|
|
|
|
|
10 6DD48BFFD481D905E33F331689CE13B27DD42FFD |
52
|
|
|
|
|
|
|
10 BEE8EDA4916BCD7A7ABB6AACADC4EA18F4855B3D |
53
|
|
|
|
|
|
|
9 C407ECB3D0ACF0D0E01488960005B844BFCF2F03 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parse_stats { |
58
|
1
|
|
|
1
|
1
|
3
|
my ($self, $payload) = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
3
|
my @bypeers = (); |
61
|
1
|
|
|
|
|
2
|
my @byseeds = (); |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
my $current = undef; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
8
|
for my $line (split "\n", $payload) { |
66
|
7
|
|
|
|
|
8
|
chomp $line; |
67
|
|
|
|
|
|
|
|
68
|
7
|
100
|
|
|
|
23
|
if ($line =~ m{^Top .* peers}) { |
69
|
1
|
|
|
|
|
3
|
$current = 'peers'; |
70
|
1
|
|
|
|
|
2
|
next; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
6
|
100
|
|
|
|
17
|
if ($line =~ m{^Top .* seeds}) { |
74
|
1
|
|
|
|
|
2
|
$current = 'seeds'; |
75
|
1
|
|
|
|
|
2
|
next; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
5
|
50
|
|
|
|
10
|
die "Unable to group torrent statistics" unless $current; |
79
|
|
|
|
|
|
|
|
80
|
5
|
50
|
|
|
|
31
|
my ($count, $infohash) |
81
|
|
|
|
|
|
|
= $line =~ m{\A |
82
|
|
|
|
|
|
|
\s+ (\d+) \s+ ([A-Fa-f0-9]{40}) |
83
|
|
|
|
|
|
|
}xms |
84
|
|
|
|
|
|
|
or die "Failed to parse line of payload for $current: $line"; |
85
|
|
|
|
|
|
|
|
86
|
5
|
|
|
|
|
15
|
my %torrent = ( |
87
|
|
|
|
|
|
|
'torrent' => $infohash, |
88
|
|
|
|
|
|
|
'count' => $count, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
5
|
100
|
|
|
|
14
|
push @bypeers, \%torrent if 'peers' eq $current; |
92
|
5
|
100
|
|
|
|
16
|
push @byseeds, \%torrent if 'seeds' eq $current; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
6
|
my %stats = ( |
96
|
|
|
|
|
|
|
'peers' => \@bypeers, |
97
|
|
|
|
|
|
|
'seeds' => \@byseeds, |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
27
|
return \%stats; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Knut-Olav Hoven, Eknutolav@gmail.comE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright (C) 2009 by Knut-Olav Hoven |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
117
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
118
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|