drop md4 i?86 specific asm implementations
[mldonkey.git] / distrib / ed2k_submit / mldonkey_submit
blobe7e6a69532fe09458a517733134d54df19d26e1d
1 #!/usr/bin/perl
3 # Submit an eDonkey download request to mldonkey
5 # Argument(s): An ed2k URI of the form:
7 # ed2k://|file|<filename>|<filesize>|<MD4-sum|
9 use LWP::UserAgent;
11 ($#ARGV >= 0) || die "Usage: mldonkey_submit <ed2kURI> ...\n";
14 # Get username and password for mldonkey's HTTP GUI from
15 # /etc/sysconfig/donkey
17 # This file should read as follows:
19 # HTTPURL=http://localhost:4080
20 # HTTPUSER=me
21 # HTTPPASS=mypassword
23 $vars{'HTTPURL'} = "http://localhost:4080";
25 my $cfg = "/etc/sysconfig/mldonkey_submit";
26 open(I,"<$cfg") || die "Can't read $cfg: $!\n";
27 chomp (my @lines = (<I>));
28 close I;
29 foreach (@lines) {
30 next if (/^#/);
31 if (/([^=\s]+)=([^=\s]+)/) {
32 $vars{$1}="$2";
36 # If you don't like the above config file, you can hardcode
37 # user an password here and comment-out the above code.
38 # Do NOT comment out the default preset for $vars{'HTTPURL'}
40 #$vars{'HTTPURL'} = "http://localhost:4080";
41 #$vars{'HTTPUSER'} = "me";
42 #$vars{'HTTPPASS'} = "mypassword";
45 my $ua = LWP::UserAgent->new;
47 while (my $uri = shift @ARGV) {
48 if ($uri=~m/^(ed2k|http|ftp|sig2dat):\/\//) {
49 my $url=$uri;
50 $url=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
51 my $req = HTTP::Request->new(
52 GET => "$vars{'HTTPURL'}/submit?q=dllink+$url" );
53 if (($vars{'HTTPUSER'}) && ($vars{'HTTPPASS'})) {
54 $req->authorization_basic($vars{'HTTPUSER'},
55 $vars{'HTTPPASS'});
57 my $response = $ua->request($req);
58 unless ($response->is_success) {
59 print $response->error_as_HTML;
60 exit 1;
62 else {
63 print "Link sent.\n";
66 else {
67 print "$uri does not seem a valid URI.\n";