git://git.camperquake.de
/
xmlrtorrent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- Add authentication support
[xmlrtorrent.git]
/
xmlrtorrent.pl
diff --git
a/xmlrtorrent.pl
b/xmlrtorrent.pl
index
2089ce8
..
3adbe27
100644
(file)
--- a/
xmlrtorrent.pl
+++ b/
xmlrtorrent.pl
@@
-23,6
+23,8
@@
my @outputstack = (undef);
my $PARAMS = {
'XMLURL' => 'http://localhost/RPC2',
my $PARAMS = {
'XMLURL' => 'http://localhost/RPC2',
+ 'USERNAME' => '',
+ 'PASSWORD' => '',
};
# activate debug here
};
# activate debug here
@@
-86,7
+88,7
@@
sub write_irssi {
my @text = @_;
my $output = $outputstack[0];
my @text = @_;
my $output = $outputstack[0];
- $text[0] = '
xmlrtorrent:
' . $text[0];
+ $text[0] = '
%%mxmlrtorrent: %%n
' . $text[0];
if (defined($output) and ref($output)) {
$output->print(sprintf(shift(@text), @text), MSGLEVEL_CLIENTCRAP);
if (defined($output) and ref($output)) {
$output->print(sprintf(shift(@text), @text), MSGLEVEL_CLIENTCRAP);
@@
-164,7
+166,7
@@
sub check_for_link {
push_output($witem);
# Look if there is a torrent link in there
push_output($witem);
# Look if there is a torrent link in there
- $message =~ m
|(http://\S*\.torrent)|
;
+ $message =~ m
,(http://\S*\.(?:torrent|penis)),
;
$m = $1;
while (defined($m)) {
write_debug('Torrent-URL: %s', $m);
$m = $1;
while (defined($m)) {
write_debug('Torrent-URL: %s', $m);
@@
-199,18
+201,26
@@
sub cmd_queue {
write_debug('Sending %s to rtorrent', $u);
unless(defined($rtorrent->load_start($u))) {
write_debug('Sending %s to rtorrent', $u);
unless(defined($rtorrent->load_start($u))) {
- write_irssi('Error sending URL %s: %s', $u, $rtorrent->errstr());
+ write_irssi('
%%R
Error sending URL %s: %s', $u, $rtorrent->errstr());
} else {
} else {
+ write_irssi('%s enqueued', $u);
delete($torrentlist{$id});
}
delete($torrentlist{$id});
}
+ } elsif ('add' eq $subcmd) {
+ unless(defined($id)) {
+ return;
+ }
+ $torrentlist{$torrentindex++} = {'CHANNEL' => '', 'NICK' => '', 'URL' => $id};
} elsif (('list' eq $subcmd) or !defined($subcmd)) {
write_irssi('List of queued torrents');
foreach (sort(keys(%torrentlist))) {
} elsif (('list' eq $subcmd) or !defined($subcmd)) {
write_irssi('List of queued torrents');
foreach (sort(keys(%torrentlist))) {
- write_irssi(' %d: %s@%s: %s', $_,
+ write_irssi(' %
3
d: %s@%s: %s', $_,
$torrentlist{$_}->{'NICK'},
$torrentlist{$_}->{'CHANNEL'},
$torrentlist{$_}->{'URL'});
}
$torrentlist{$_}->{'NICK'},
$torrentlist{$_}->{'CHANNEL'},
$torrentlist{$_}->{'URL'});
}
+ } else {
+ write_irssi('Unknown subcommand: %s', $subcmd);
}
}
}
}
@@
-219,18
+229,20
@@
sub cmd_remote {
my ($subcmd, $id, @params) = @_;
my $rqueue;
my ($subcmd, $id, @params) = @_;
my $rqueue;
- if (
'queue' eq $subcmd
) {
+ if (
('list' eq $subcmd) or !defined($subcmd)
) {
unless(defined($rqueue = $rtorrent->download_list())) {
write_irssi('Error getting list of downloads: %s', $rtorrent->errstr());
return;
}
unless(defined($rqueue = $rtorrent->download_list())) {
write_irssi('Error getting list of downloads: %s', $rtorrent->errstr());
return;
}
+ write_irssi('List of rempote torrents');
foreach (@{$rqueue}) {
foreach (@{$rqueue}) {
- write_irssi('%s%s: %sB/%sB done
, %sb/s up, %sb
/s down',
+ write_irssi('%s%s: %sB/%sB done
(%d%%), %sB/s up, %sB
/s down',
$_->[6]?'*':' ',
$_->[0],
format_number($_->[2]),
format_number($_->[1]),
$_->[6]?'*':' ',
$_->[0],
format_number($_->[2]),
format_number($_->[1]),
+ ($_->[2]*100)/$_->[1],
format_number($_->[3]),
format_number($_->[4]));
}
format_number($_->[3]),
format_number($_->[4]));
}
@@
-261,7
+273,10
@@
sub cmd_set {
if(exists($PARAMS->{$key})) {
$conf->{'xmlrtorrent'}->{$key} = $val;
if ('XMLURL' eq $key) {
if(exists($PARAMS->{$key})) {
$conf->{'xmlrtorrent'}->{$key} = $val;
if ('XMLURL' eq $key) {
- unless(defined($rtorrent = xmlrtorrent->new('XMLURL' => $conf->{'xmlrtorrent'}->{'XMLURL'}))) {
+ unless(defined($rtorrent = xmlrtorrent->new(
+ 'XMLURL' => $conf->{'xmlrtorrent'}->{'XMLURL'},
+ 'USERNAME' => $conf->{'xmlrtorrent'}->{'USERNAME'},
+ 'USERNAME' => $conf->{'xmlrtorrent'}->{'PASSWORD'}))) {
write_irssi('Could not initialize XMLRPC instance');
return;
}
write_irssi('Could not initialize XMLRPC instance');
return;
}
@@
-317,7
+332,10
@@
sub init_xmlrtorrent {
}
}
}
}
- unless(defined($rtorrent = xmlrtorrent->new('XMLURL' => $conf->{'xmlrtorrent'}->{'XMLURL'}))) {
+ unless(defined($rtorrent = xmlrtorrent->new(
+ 'XMLURL' => $conf->{'xmlrtorrent'}->{'XMLURL'},
+ 'USERNAME' => $conf->{'xmlrtorrent'}->{'USERNAME'},
+ 'USERNAME' => $conf->{'xmlrtorrent'}->{'PASSWORD'}))) {
write_irssi('Could not initialize XMLRPC instance');
return;
}
write_irssi('Could not initialize XMLRPC instance');
return;
}
@@
-356,6
+374,8
@@
sub cmdhandler {
if (exists($xmlrtorrent_commands->{$cmd})) {
$xmlrtorrent_commands->{$cmd}->(@params);
if (exists($xmlrtorrent_commands->{$cmd})) {
$xmlrtorrent_commands->{$cmd}->(@params);
+ } else {
+ write_irssi('Unknown command: %s', $cmd);
}
pop_output();
}
pop_output();