Firefox handler hacks

From MLDonkey
Jump to: navigation, search

FireFox handler are a bit complex to setup relative to the alternatives but they work even with ancient versions of FireFox.

This first one is based on the Konqueror solution.

Make a file named e.g. firefox_submit and put it in a directory. Make it executable. The first script (simple) is only for local MLDonkey's and a default install (admin, no password). The second script (advanced) can be configured for other users, passwords and servers. The latter script also triggers a warning in Firefox, so I advise you if possible to use the first one.:

Simple:

#!/usr/bin/perl

#Creates a link to submit to MLdonkey and submits using Firefox

use URI::Escape;
$uri  = $ARGV[0];

$link = sprintf("http://localhost:4080/submit?q=dllink+%s",
        uri_escape($uri));

exec ('firefox',$link);

Advanced:

#!/usr/bin/perl

#Creates a link to submit to MLdonkey and submits using Firefox

use URI::Escape;
$uri  = $ARGV[0];
# change these as needed
$username = "admin";
$password = "";
$server_addr = "localhost";
$server_port = "4080";

$link = sprintf("http://%s:%s@%s:%s/submit?q=dllink+%s",
        $username,$password,$server_addr,$server_port,uri_escape($uri));

exec ('firefox',$link);

When opening a torrent file from the web or your local file system, let Firefox open the links/files with firefox_submit and let Firefox remember it.

This works for .torrent-files. You can also use it for ed2k:/-links. To use this start Firefox and do this:

Solution 2 (only ed2k protocol)

This solution is based on Amule Wiki ([1]).

Use this script as mldonkey_submit :

#!/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> ...\n";

#
# Edit lines below.
#
$vars{'HTTPURL'} = "http://IP_or_HOSTNAME:PORT";
$vars{'HTTPUSER'} = "USER";
$vars{'HTTPPASS'} = "PASSWORD";
#

my $ua = LWP::UserAgent->new;

while (my $uri = shift @ARGV) {
        $esc_uri = URI::Escape::uri_escape($uri);
        $_ = URI::Escape::uri_unescape($uri);
        if (m@^ed2k://\|file\|[^|]+\|(\d+)\|([\da-fA-F]+)\|@) {
                my $size = $1;
                my $md4 = $2;
                my $req = HTTP::Request->new(
                        GET <code>> "$vars{'HTTPURL'}/submit?q</code>dllink+$esc_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: $_\n";
        }
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox