line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Opentracker::Stats::Mode::Torr; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
49829
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
5
|
use parent qw/ |
7
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode |
8
|
|
|
|
|
|
|
Class::Accessor::Fast |
9
|
1
|
|
|
1
|
|
1020
|
/; |
|
1
|
|
|
|
|
292
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->_format('txt'); |
13
|
|
|
|
|
|
|
__PACKAGE__->_mode('torr'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/_stats/); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode::Torr |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Parses the torr 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 torr statistics of opentracker. |
33
|
|
|
|
|
|
|
Only the number of torrents is available from this statistics. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The payload looks like this (no indentation): |
36
|
|
|
|
|
|
|
2 |
37
|
|
|
|
|
|
|
0 |
38
|
|
|
|
|
|
|
opentracker serving 2 torrents |
39
|
|
|
|
|
|
|
opentracker |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parse_stats { |
44
|
2
|
|
|
2
|
1
|
4
|
my ($self, $payload) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# To support thousand delimiters |
47
|
2
|
50
|
|
|
|
19
|
my ($raw_torrents, undef, undef) = $payload =~ m{\A |
48
|
|
|
|
|
|
|
([\d\'\.]+) \s |
49
|
|
|
|
|
|
|
([\d\'\.]+) \s |
50
|
|
|
|
|
|
|
opentracker \s serving \s ([\d\'\.]+) \s torrents \s |
51
|
|
|
|
|
|
|
opentracker |
52
|
|
|
|
|
|
|
}xms |
53
|
|
|
|
|
|
|
or die "Unable to parse payload: $payload"; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
15
|
my %stats = ( |
56
|
|
|
|
|
|
|
'torrents' => $self->parse_thousands($raw_torrents), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
14
|
return \%stats; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SEE ALSO |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
L |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Knut-Olav Hoven, Eknutolav@gmail.comE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Copyright (C) 2009 by Knut-Olav Hoven |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
76
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
77
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|