I use Deluge to download torrents rather than Transmission. On Ubuntu MATE 17.04, I had issues to associate magnet links with it. They’re apparently handled by the MIME system and I fixed the issue by running these commands:
Since I upgraded to Ubuntu MATE 17.10, it’s broken: clicking on a magnet link still opens Deluge (so the association seems to be fine), but the torrent is not added anymore, I have to manually add it. The URL field is pre-filled, though, so it looks like it’s properly passed to Deluge (or is at least in the clipboard) but it’s not treated.
Not sure if it’s an issue in Deluge or in Ubuntu MATE more generally. Any idea?
I ran into this as well. I looked at this for a few minutes and have a workaround. It would probably get fixed by installing deluge from source, but I decided to just fix it since I saw it was only a few lines of code.
So to patch this you need sudo access & some text editing tool like vi or nano.
First sudo edit /usr/lib/python2.7/dist-packages/deluge/common.py. Look for the function def is_magnet(uri):. After the docstring inside the “”", add 2 lines so the function looks like this:
def is_magnet(uri):
"""
A check to determine if a uri is a valid bittorrent magnet uri
:param uri: the uri to check
:type uri: string
:returns: True or False
:rtype: bool
**Usage**
>>> is_magnet("magnet:?xt=urn:btih:SU5225URMTUEQLDXQWRB2EQWN6KLTYKN")
True
"""
if uri.startswith("magnet:///"):
uri = "magnet:" + uri[len("magnet:///"):]
magnet_scheme = 'magnet:?'
xt_param = 'xt=urn:btih:'
if uri.startswith(magnet_scheme) and xt_param in uri:
return True
return False
Then sudo edit /usr/lib/python2.7/dist-packages/deluge/ui/gtkui/ipcinterface.py and find the def process_args(args): function. Inside that function there is a check elif deluge.common.is_magnet(arg):, change the code in there so it looks like this - I added 2 lines:
elif deluge.common.is_magnet(arg):
log.debug("Attempting to add magnet (%s) from external source...", arg)
if arg.startswith("magnet:///"):
arg = "magnet:" + arg[len("magnet:///"):]
if config["interactive_add"]:
component.get("AddTorrentDialog").add_from_magnets([arg])
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
else:
client.core.add_torrent_magnet(arg, {})
After saving, restart deluge. The patch is ugly, but it works.