my $PARAMS = {
'XMLURL' => 'http://localhost/RPC2',
+ 'USERNAME' => '',
+ 'PASSWORD' => '',
};
# activate debug here
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);
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);
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('%%RError sending URL %s: %s', $u, $rtorrent->errstr());
} else {
+ write_irssi('%s enqueued', $u);
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))) {
- write_irssi(' %d: %s@%s: %s', $_,
+ write_irssi(' %3d: %s@%s: %s', $_,
$torrentlist{$_}->{'NICK'},
$torrentlist{$_}->{'CHANNEL'},
$torrentlist{$_}->{'URL'});
}
+ } else {
+ write_irssi('Unknown subcommand: %s', $subcmd);
}
}
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;
}
+ write_irssi('List of rempote torrents');
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]),
+ ($_->[2]*100)/$_->[1],
format_number($_->[3]),
format_number($_->[4]));
}
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;
}
}
}
- 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;
}
if (exists($xmlrtorrent_commands->{$cmd})) {
$xmlrtorrent_commands->{$cmd}->(@params);
+ } else {
+ write_irssi('Unknown command: %s', $cmd);
}
pop_output();