Browser Integration

From MLDonkey

Jump to: navigation, search

ed2k:// links, .torrent-uri's, etc.

Contents

[edit] Windows (Internet Explorer)

Windows users should read this and forget the rest written here :) : mlsubmit.reg

[edit] Mozilla

Mozilla Users can simply copy the ed2kprotocol.js from the sources (in the ed2k_mozilla directory) in the /usr/lib/mozilla-version/components directory . Then remove the /usr/lib/mozilla-version/components/compreg.dat . Restart Mozilla and it will handle ed2k links ! Successfully tested on Mozilla 1.1

Mozilla 1.4 Users make sure that under Preferences -> Advanced Javascript and Software Installation are enabled. Enter the pathname to the mldonkey_protocol_handler.xpi file in the webadress field e.g. \"file://<path_to_mldonkey/ed2k_mozilla/mldonkey_protocol_handler.xpi\" and let Mozilla install the new protocol handler.

Mozilla 1.4 Users that want to forward links to a different server (like e.g. http://192.168.1.1:4444/ instead of http://127.0.0.1:4080/). Type \"about:config\" in the url bar. The entries that need to be changed are NOT visible. Add the following strings:
network.mldonkey.server localhost (hostname on which MLdonkey is running)
network.mldonkey.user (login with this username)
network.mldonkey.pass (login with this password)
network.mldonkey.port 4080 (port of the MLdonkey WEB service)

For updated information on the xpi file see the README at: [1]

There is also a new Firefox Extension called Donkeyfire which adds a progress bar in Firefox's Status Bar.

[edit] Firefox 0.9 or later (and mozilla 1.7 or later)

[edit] Solution 1

This one is very easy and based on the Konqueror solution.

  • Requirements: Perl, incl. Perl URI module

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:

  • Insert about:config in the address bar
  • Right click on the list, select New, then Boolean; insert network.protocol-handler.external.ed2k as Preference Name and true as Value
  • Now another right click, select New and String; insert network.protocol-handler.app.ed2k as Preference Name and /path/to/firefox_submit (path to where the file is installed on your system) as Value.

[edit] Solution 2 (only ed2k protocol)

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

  • Start Mozilla/firefox browser
  • Insert about:config in the address bar
  • Right click on the list, select New, then Boolean; insert network.protocol-handler.external.ed2k as Preference Name and true as Value
  • Now another right click, select New and String; insert network.protocol-handler.app.ed2k as Preference Name and /path/to/mldonkey_submit (path to where the file is installed on your system) as Value.

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";
        }
}

[edit] Gnome

[edit] Gnome compliant browsers (Galeon,Epiphany,...) GNOME 2.8 and older

Galeon Users and users of other Gnome compliant applications, just install [mlurlslave for GTK+ http://ircnet.de/home/cru/ed2k_urlslave/mlurlslave.html] or mlurlslave for GTK2
Alternately use instructions at mlurlslave but use /usr/bin/mldonkey_command instead of mlurlslave

However, if you happen to not have gnomecc --as is true for gnome2-- you still can set it up. Here goes: (we start at 4)

start gnome-control-center* go to complex (Komplex* in German) double-click on File Types and Programs (Dateitypen und Programme* in German) highlight Internet Services* click on Add Service...*

  • for protocol type ed2k
  • for program to run type mlurlslave \"%s\"
  • add whatever description you want (I have none)

make sure Run in Terminal is unchecked* click OK*

You're done! Well I was... Now I can click on ed2k://-links and they are added to the queue.


If you have problems _please_ come by the IRC channel and look for me --housetier--, so we can sort it out. (Channel is #mldonkey on irc.freenode.net; see also the HomePage, under FAQs)

[edit] New GNOME 2 integration using gconf (GNOME 2.10 and newer)

Just install [mlurlslave for GTK+] or [mlurlslave for GTK2]

The filetypes and Programs capplet does not exist anymore in newer GNOME versions, so you'd have to add the handler directly to the gconf database. To do this you type:

  • gconftool-2 -s -t string /desktop/gnome/url-handlers/ed2k/command "/usr/local/bin/mlurlslave %s" (if you installed in /usr/local/bin)
  • gconftool-2 -s -t bool /desktop/gnome/url-handlers/ed2k/enabled true
  • gconftool-2 -s -t bool /desktop/gnome/url-handlers/ed2k/need-terminal false

(Oh yeah, I noticed that the telnet protocol changed somewhat, so you have to edit the mlurlslave file (/usr/local/bin/mlurlslave) and change the line elsif(/download started/){ to elsif(/Added link/){. If you don't do this, mlurlslave will give you an error message. The download is still started though. Test reaction with dllink in console when in doubt.)

[edit] Konqueror

Here is the code for konqueror_submit:

#!/usr/bin/perl

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

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 ('konqueror',$link);

Edit and put in your path. Make sure you chmod +x konqueror_submit or it won't work.

This works for .torrent-files/links. To use it with the edk2 protocol, do:

Here is the protocol handler file that goes in .kde/shar/services/edk2.protocol

[Protocol]
exec=konqueror_submit '%u'
protocol=ed2k
input=none
output=none
helper=true
listing=false
reading=false
writing=false
makedir=false
deleting=false
Icon=remote
Description=Handles eDonkey2000 ed2k://-links

RedZeus, source Forums&fileviewtopic&t=2462

[edit] Opera

[edit] Unix

(~HowTo found on the web @ http://knowledge.martignier.net/MlDonkey in german - translated by fob)


  • close opera
  • open \"opera6.ini\"

in the section ~~User Prefs* add:

TrustedExternalURLProtocols=ed2k

Find section ~~Trusted Applications* (create it if it does not exist) and add:

ed2k=/usr/bin/ed2kopera
 or for Opera 7:
ed2k=/usr/bin/ed2kopera %u
  • save and close the file
  • install \"[netcat]\" (for Debian: apt-get install nc on woody apt-get install netcat)

create the file /usr/bin/ed2kopera* and insert the following text:

#!/bin/sh
echo dllink ed2k://$1 || nc -q 1 127.0.0.1 4000

(Change \"127.0.0.1\" and \"4000\" to fit the IP-Address and Portnumber that your mldonkey-core uses)

[edit] Unix v 8 Beta 2 (tested in Gentoo Linux-2.6.11-r4, Gnome 2.8.3)

  • In the Settings->Applications and path:
Add protocol \"ed2k\"
Open with \"/home/userdir/ed2kopera\"
  • Install \"netcat\" (for Debian: apt-get install nc on woody apt-get install netcat)
  • Create the file /home/userdir/ed2kopera and insert the following text:
#!/bin/sh
echo dllink $1 || nc -q 1 127.0.0.1 4000

(Change \"127.0.0.1\" and \"4000\" to fit the IP-Address and Portnumber that your mldonkey-core uses)

[edit] Windows

In the root folder of the Opera installation (most probably C:\Program Files\Opera7) find the file 'opera6.ini'.

+Add in this file under ~~User Prefs

TrustedExternalURLProtocols=ed2k

Find the same file in the subfolder 'profile' (most probably C:\Program Files\Opera7\profile).

+Add in this file under ~~Trusted Protocols

ed2k<code>0,0,opera.EXE ~http://admin:@127.0.0.1:4080/submit?q</code>dllink+%1

And you are ready to click your favourite Ed2k links.

_(by White FrosT, only tested on Opera 7+)_


As a Side note with the particular version of opera I have (7.21) I had to use the following:

~[[~User Prefs]]
TrustedExternalURLProtocols=ed2k
...
~[[~Trusted Protocols]]
ed2k=0,0, /usr/bin/ed2kopera %u

and nc -q wasn't valid so i changed that in the script above to nc -i

_/cotyer_

[edit] elinks

elinks browser (http://elinks.or.cz/) can be customized with Lua scripts, so for this you need lua support enabled. Then, you have to modify your ~~/.elinks/hooks.lua file. In this file you can find the function called follow_url_hook. All web petitions go through this hook, which receives the URL the user has selected and it is either returned like that, or modified. We will modify it to detect ed2k and bittorrent links, and redirect them to our local mldonkey daemon.

First, somewhere add the following function used to reencode some bad characters found in URLs:

function url_encode(text)
    text = gsub(text, \" \", \"%%20\")
    text = gsub(text, \"%:\", \"%%3A\")
    text = gsub(text, \"%/\", \"%%2F\")
    text = gsub(text, \"%||\", \"%%7C\")
    text = gsub(text, \"%!\", \"%%21\")
    text = gsub(text, \"%�\", \"%%AA\")
    text = gsub(text, \"%&\", \"%%26\")
    return gsub(text, \"%#\", \"%%23\")
end

And now, before any processing is done in follow_url_hook, detect the urls. Example:

function follow_url_hook (url)

    -- Detecting ed2k links
    if strfind(url,'ed2k.*%||file%||') then
      text = url_encode(gsub(url, \"(.-)ed2k.'''file%||(~[[^]]''')%||(%d''')%||(%x''').*\", \"dllink ed2k://||file||%2%||%3%||%4%||\"))
      return \"~http://127.0.0.1:4080/submit?q=\"..text
    end

    -- Detecting ~BitTorrent links
    if strfind(url,'.*%.torrent$') then
      return \"~http://127.0.0.1:4080/submit?q=dllink%20\"..url_encode(url)
    end

    -- Return url without changes.
    return url
end

[edit] All browsers using Sancho (only BitTorrent)

Sancho (http://sancho-gui.sourceforge.net/) supports remote and local loading of a torrent direct from browser to mlnet. Assign browser to launch \"sancho -l %s\" for browser integration.

/usr/bin/sancho -l /home/username/somefile.torrent

Thats right this works even if the mlnet sancho is configured to access is on a remote machine.

[edit] All browsers using MLDonkey daemon running as user mldonkey (only BitTorrent)

Bash script to load local torrent

Another way to click on a bittorrent link and have it load in mldonkey is via a secondary script. Save this bash script as an executable in $HOME/bin. Assign your browser to launch the file when torrents are clicked on. Script and mldonkey must be on same system to work.

Note: The permissions and group may need to be fiddled with to get this script to work

Note: For mlnet on remote machine have torrent go to SMB shared directory and launch script on mlnet machine via auto ssh login and execution of script.

#!/bin/bash
#
# Script to be called by web browser to load torrents to mldonkey
#
# Created by ProteusMoteus
#
# This is setup for mldonkey running as daemon process as
# user mldonkey.  As configured by mldonkey-init.

MLCMD=\"/usr/bin/mldonkey_command\"
# Directory to move the .torrent to
CLOSET=\"/var/lib/mldonkey/torrents/downloads\"

if [[ [ ! -w \"$CLOSET\" | ! -s \"$1\" ]] ||] ||| ! $MLCMD; then
 [[ ! -s \"$1\" ]] && echo \"usage: mlbittorrent-script <torrent file>\"
 [[ ! -w \"$CLOSET\" ]] && echo ERR. Not writeable directory $CLOSET
else
 echo Given: $1
 CLOSET=\"$CLOSET/`basename \"$1\"`\"
 mv \"$1\" \"$CLOSET\"
 echo Moved to: $CLOSET
 ls -la \"$CLOSET\"
# Two lines below may need to be tweaked to get script to work
 chmod 660 \"$CLOSET\"
 chgrp mldonkey \"$CLOSET\"
 echo Changed permissions and group
 ls -l \"$CLOSET\"
 $MLCMD dllink \"$CLOSET\"
 echo Check downloads for file:
 echo \"$MLCMD vd || grep `basename \"$CLOSET\" .torrent`\"
 [[[ \"$CLOSET\" != *.torrent ]]] && echo WARNING. No torrent extension for $CLOSET
fi

#enable for troubleshooting
#echo Press [[ENTER]] to continue
#read


[edit] See also

Forum: how to download bittorrent with mldonkey?

Personal tools