mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-10 19:15:54 +02:00
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@941 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
41 lines
921 B
Perl
Executable File
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: $_
|
|
";
|
|
}
|
|
}
|