Files
bpfire/config/mldonkey/mldonkey_submit
ms c7e54648e6 Grosses mldonkey-Update.
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@941 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
2007-10-03 16:23:29 +00:00

41 lines
921 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://192.168.181.70: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: $_
";
}
}