line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::RTPG; |
2
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
25224
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1138
|
use common::sense 2.02; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
810
|
use parent 0.223 "Object::Event"; |
|
1
|
|
|
|
|
313
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
41248
|
use AnyEvent 5.202; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
509
|
use RTPG 0.3; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my $this = shift; |
13
|
|
|
|
|
|
|
my $class = ref($this) || $this; |
14
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
15
|
|
|
|
|
|
|
$self->{_rtpg} = RTPG->new(url=>$self->{url}); |
16
|
|
|
|
|
|
|
return $self |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _tick { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
my $list=$self->{_rtpg}->torrents_list; |
22
|
|
|
|
|
|
|
$self->event("refresh_status"=>\@$list); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub start { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
$self->{_tick_timer} = AE::timer(0, 10, sub { $self->_tick }); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub rpc_command { |
31
|
|
|
|
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
my ($result, $error)=$self->{_rtpg}->rpc_command(@_); |
33
|
|
|
|
|
|
|
my $cmd=shift; |
34
|
|
|
|
|
|
|
if ($cmd =~ /^d.erase$/) { |
35
|
|
|
|
|
|
|
my $hash=shift; |
36
|
|
|
|
|
|
|
print $cmd,$hash; |
37
|
|
|
|
|
|
|
$self->event("rtorrent_remove_torrent"=>$hash); |
38
|
|
|
|
|
|
|
}else{ |
39
|
|
|
|
|
|
|
$self->_tick; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
AnyEvent::RTPG - A RTPG interface for AE |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Add "scgi_port = localhost:5000" to your ~/.rtorrent.rc first |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $rtorrent = AnyEvent::RTPG->new(url => "localhost:5000"); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$rtorrent->reg_cb( |
56
|
|
|
|
|
|
|
refresh_status => sub { |
57
|
|
|
|
|
|
|
my ($rtorrent, $lists) = @_; |
58
|
|
|
|
|
|
|
... |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
rtorrent_remove_torrent => sub { |
61
|
|
|
|
|
|
|
my ($rtorrent, $torrent_hash) = @_; |
62
|
|
|
|
|
|
|
... |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$rtorrent->start; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item new(url => "localhost:5000") |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item reg_cb(event_name => $cb, ...) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item start |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 EVENTS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item refresh_status |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item rtorrent_remove_torrent |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Tka Lu C<< >>, Kang-min Liu C<< >> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright (c) 2009, Tka Lu C<< >>, Kang-min Liu C<< >> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is free software, licensed under: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The MIT (X11) License |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
105
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
106
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
107
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
108
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
109
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
110
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
111
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
112
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
115
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
116
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
117
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
118
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
119
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
120
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
121
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
122
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
123
|
|
|
|
|
|
|
SUCH DAMAGES. |