]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - config/mldonkey/mldonkey_submit
Updater: disabled cache file for blkid.
[people/pmueller/ipfire-2.x.git] / config / mldonkey / mldonkey_submit
CommitLineData
02dc0a76
MT
1#!/usr/bin/perl
2
3# Submit an eDonkey download request to mldonkey
4#
5# Argument(s): An ed2k URI of the form:
6#
7# ed2k://|file|<filename>|<filesize>|<MD4-sum|
8use LWP::UserAgent;
9
10($#ARGV >= 0) || die "Usage: mldonkey_submit <ed2kURI> ...
11";
12
c7e54648 13$vars{'HTTPURL'} = "http://192.168.181.70:4080";
02dc0a76
MT
14$vars{'HTTPUSER'} = "admin";
15$vars{'HTTPPASS'} = "";
16
17my $ua = LWP::UserAgent->new;
18
19while (my $uri = shift @ARGV) {
20 $_ = URI::Escape::uri_unescape($uri);
21 if (/^ed2k:\/\/\|file\|[^|]+\|(\d+)\|([\dabcdef]+)\|$/) {
22 my $size = $1;
23 my $md4 = $2;
24 my $req = HTTP::Request->new(
25 GET => "$vars{'HTTPURL'}/submit?q=dllink+$uri"
26 );
27 if (($vars{'HTTPUSER'}) && ($vars{'HTTPPASS'})) {
28 $req->authorization_basic($vars{'HTTPUSER'},
29 $vars{'HTTPPASS'});
30 }
31 my $response = $ua->request($req);
32 if (!($response->is_success)) {
33 print $response->error_as_HTML;
34 exit 1;
35 }
36 } else {
37 print "Not an ed2k URI: $_
38";
39 }
40}