Trackers are not added through magnets.

General support for problems installing or using Deluge
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Trackers are not added through magnets.

Post by mhertz »

I narrowed it down to commit 2bd095e specifically being the culprit and submitted bug-ticket here: https://dev.deluge-torrent.org/ticket/3530#ticket

Thanks again nemonein and Spire :)

Edit: I updated ticket with a fix for issue. Can be applied locally if wanted through e.g.:

Code: Select all

sudo find /usr -path *deluge/core/torrentmanager.py -exec sed -i "s/if magnet_info:/if magnet_info:\n                add_torrent_params['url'] = magnet.strip().encode()/" {} \;
Edit: The fix above is deprecated, and should be changed to using 'lt.parse_magnet_uri()' to generate 'add_torrent_params', though that is already used in the offending commit, and i'm not sure where to otherwise 'strip().encode()' frankly - i'll leave that to the people actually knowing what they are doing lol :) Anyway, the fix works for time being atleast.

Edit2: Last note, it's not the 'strip().encode()' making it work, but just mere addition of the 'add_torrent_params['url'] = magnet'. In libtorrent v2 docs it's stated to be removed in v2, though isn't here on v2.0.6 where still fixes issue. Also, 'lt.parse_magnet_uri()' I said was used before in offending commit, but was only used in the prefetching I see now, but cannot myself make it work in next part as doesn't play nice with rest code there for me.
Spire
New User
New User
Posts: 3
Joined: Thu Jun 30, 2022 11:15 am

Re: Trackers are not added through magnets.

Post by Spire »

I've noticed some interesting behaviour to this issue.

If the Deluge client is open and I click on a magnet link then no trackers are added.

If the Deluge client is open and I right click on a magnet link and choose 'Coopy Link' (or equivelent) and add it with '+' (Add Torrent), 'URL' (magnet link is prefilled), 'OK', tracker IS added.

Sort of a workaround for now.

Edit: I see mhertz has made a tickent https://dev.deluge-torrent.org/ticket/3530 and tracked down the offending commit. Thanks mhertz. Well done.
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Trackers are not added through magnets.

Post by nemonein »

@mhertz
You are VERY KIND!
I've reported bugs and errors quite a few times, but I don't think I have got replies like yours.
But don't worry, I was not upset at all. I fully understand your situation/behavior/(whatever you may call it..). :lol:

My first language is not English, nor which is my second. (Actually I can speak only ONE language!)
Because of that, I might look like I was upsetting, but that's not true.
I'm using deluge for a long time, I love it, and I'd like to support it. I'm not a developer, so reporting is all I can do.

Anyway, I haven't tested yet, but found something strange, again.
The result differs when magnet link added by a click from browsers(xdg-open) and added by + mark(Add torrents)/url on deluge.
First one adds trackers, latter one does not.

Please go to my blog. Try click the link and copy/paste the URI below to deluge, each.
Be aware that this works only on Deluged 2.0.5. (2.1.0 has no trackers on any circumstances.)
By Click and xdg-open (Google Chrome / Firefox)
NAME on Deluge: KaOS-2022.06-x86_64.iso
Trackers : Good

By Add torrents with url.
NAME on Deluge: d87a3eccf17d108071b704404e4e67edac1a9a70 (after a while, it changed to real file name)
Trackers : None
I hope you find a good solution! :roll:

****
I read @Spire's post after I wrote this!!!
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Trackers are not added through magnets.

Post by mhertz »

@Spire, thanks buddy, I really appreciate your kind words and supportive post and your help and feedback in this thread :) When I test this here, then if having 'Always show' disabled in deluge preferences under 'Downloads', then your first example always fail adding trackers as you stated. If not having that option disabled, then for me it's a matter of if i'm pressing 'Add' before or after the fiellist gets populated with magnet file-contents - before and it fails and after and it works. The same for me is happening with your next example. This is just what I see here in quick test atleast and also fits with my theory about it being related to if prefetching metadata is finished or not, but I can be wrong of-course. Thanks again for helping track this down and suggesting workarounds.

@nemonein, hey that honestly made my day reading, and you're incredibly kind posting such kind message to me and I sincerly thank you my friend for that! :)

I again here have the same result as what I posted above to Spire, so I don't know if same scenario or you have hit something I cannot reproduce, yet atleast :) For the test at your blog, then I here never got trackers, neither with deluge 2.1.0 or 2.0.5 with libtorrent 2.0.6 or 1.2.15. Strange these differences we see. The reason for that I didn't get trackers on your blog-link is i'm guessing because it uses something I never seen before, I haven't checked if even compliant(guessing not, but as said not sure), but it uses for optional trackers not usual: '&tr=', but more esotic(for me atleast ;) ) '&tr= '.

Heh, I was reading this post before submitting and decided to read little up on the '&' thing, and it's a html command and not a URi one, however need adding to URI if inclosed into a link - so that is the culprit seemingly, as is inclosed link - reason for me getting no trackers even by "clicking" was because I didn't click sorry, but copy/pasted and used 'xdg-open', which should explain the issue, but nice catch! :)

Anyway @all, If wanting use my fix which works for time being, untill proper fix added by the devs, but not wanting running my previous posted 'sudo' command-line for fixing this, then here's the manual instructions if preferred:

Run this line to find where the file needing changed is located:

Code: Select all

find /usr -path *deluge/core/torrentmanager.py

Replace that file with this: torrentmanager.py (rightclick > 'save as' if link doesn't download upon clicking it - Also, you can back up original file first if wanted, but a reinstall of deluge will restore original anyways)

Alternatively, then don't need my file and can just in your file add this new line after line 437, so becomes line 438:

Code: Select all

                add_torrent_params['url'] = magnet.strip().encode()
Should look like this(only second line is new here):

Code: Select all

            if magnet_info:
                add_torrent_params['url'] = magnet.strip().encode()
                add_torrent_params['name'] = magnet_info['name']
                torrent_id = magnet_info['info_hash']
nemonein
Member
Member
Posts: 16
Joined: Fri Jul 10, 2020 3:41 pm

Re: Trackers are not added through magnets.

Post by nemonein »

Everything works fine after the fix. Even Magnet Link with Numbered Trackers work.
Click(xdg-open) as well as 'Add torrents' with URL work very well.
Thank you very much! :D

And forget about the &amp thing. It was my mistake. I've change the code. I'm very sorry.
----
However, one more thing..
There is something weird thing happens when 'Add torrents with URL.'
I'll open a post about this.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Trackers are not added through magnets.

Post by mhertz »

You're very welcome, and likewise I appreciate you reporting back, plus initially reporting it, as realize it affects me to I see, as use public torrents which often have a bunch optional trackers appended by various trackers, well would work anyways but might as well utilize the additions when defined as such instead of ignore, so thanks bro, appreciated :)

Actually I just saw in the git commit-log that Cas has fixed the issue, and proppely, so thanks alot for that Cas, much appreciated!

@all, I didn't test it honestly yet, but however trust Cas, obviously, and the fix and explenation makes sense, so here's instructions for the proper fix for deluge 2.1.0 users(though if having already applied the old fix then optional if wanting to change it, as old one works as stated, just being deprecated, meaning scheduled for removal at later point down the road, from libtorrent where utilized from in fix):

In torrentmanager.py(see my previous post where find), after line 438 you make an extra new line 439 with this:

Code: Select all

                add_torrent_params['trackers'] = list(magnet_info['trackers'])
So should look like this, with only 3'rd line new:

Code: Select all

            if magnet_info:
                add_torrent_params['name'] = magnet_info['name']
                add_torrent_params['trackers'] = list(magnet_info['trackers'])
                torrent_id = magnet_info['info_hash']

Post Reply