Files
bpfire/config/mldonkey/mldonkey_submit
ms 02dc0a76c8 Hinzugefügt:
* Mldonkey 2.7.7
  * Ocaml - letzte Version.
  * Net-Config ins Webinterface.


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@226 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
2006-07-24 15:49:37 +00:00

41 lines
916 B
Perl
Executable File

#!/usr/bin/perl
# Submit an eDonkey download request to mldonkey
#
# Argument(s): An ed2k URI of the form:
#
# ed2k://|file|<filename>|<filesize>|<MD4-sum|
use LWP::UserAgent;
($#ARGV >= 0) || die "Usage: mldonkey_submit <ed2kURI> ...
";
$vars{'HTTPURL'} = "http://127.0.0.1:4080";
$vars{'HTTPUSER'} = "admin";
$vars{'HTTPPASS'} = "";
my $ua = LWP::UserAgent->new;
while (my $uri = shift @ARGV) {
$_ = URI::Escape::uri_unescape($uri);
if (/^ed2k:\/\/\|file\|[^|]+\|(\d+)\|([\dabcdef]+)\|$/) {
my $size = $1;
my $md4 = $2;
my $req = HTTP::Request->new(
GET => "$vars{'HTTPURL'}/submit?q=dllink+$uri"
);
if (($vars{'HTTPUSER'}) && ($vars{'HTTPPASS'})) {
$req->authorization_basic($vars{'HTTPUSER'},
$vars{'HTTPPASS'});
}
my $response = $ua->request($req);
if (!($response->is_success)) {
print $response->error_as_HTML;
exit 1;
}
} else {
print "Not an ed2k URI: $_
";
}
}