Page 2 of 2

Re: Batch change tracker URL for torrents

Posted: Mon Mar 27, 2017 9:53 pm
by marteenzh
Found something that works well in Mac OS.

Code: Select all

perl -pi -w -e 's/THIS/THAT/g;' /path/to/files*.txt

Referenced from ... mand-line/

Re: Batch change tracker URL for torrents

Posted: Sun Oct 04, 2020 8:31 pm
by stogie bear

Sorry for the necrobump but hoping someone might be able to help me get this script to work.

So far as I can tell the reason it wont work is because I dont use the standard 'program files' install location for deluge. My copy of deluge is installed to D:\Deluge_Daemon and D:\Internet\Deluge.

The script works up until i confirm i want to proceed with the operation then I get this error
Traceback (most recent call last):
File "", line 39, in <module>
state = cPickle.load(state_file)
ImportError: No module named deluge.core.torrentmanager

I don't know anything about python or programming and despite my best efforts this has me stumped.

Re: Batch change tracker URL for torrents

Posted: Mon Oct 05, 2020 12:23 pm
by shamael
Hi stogie bear,

Under Linux I published the solution I use many times per year now here
It's mainly a stop of all Deluges's services and file search&replace operation on the file torrents.state located in your profile.

You seems to be under Windows, I propose below generic info/how_to.

The config file are in your user profile, a user profile is accessible with variable.
File to edit: torrents.state
Location of the file: %APPDATA%\deluge\state\

Copy this location in Windows explorer to confirm you see the file, check the date. If this is the right file the date should be recent.

Change proposal
I don't have a Deluge under Windows right now so cannot properly test tracker swap. I'll rely on Notepad++ for this part for this reason
Mainly the script only create a backup copy prior you change it, just in case...P

- stop all Deluge services, confirm with the task manager
- open a Powershell prompt and past blow line to create a backup of your deluge folder located in %APPDATA%

Code: Select all

#Create Deluge profile backup
$SOURCE = "$env:appdata\deluge"
$BACKUP = "$env:appdata\deluge.backup"
New-Item -ItemType "directory" -Path $BACKUP -force | out-null
Copy-Item -R -Path $SOURCE -Destination $BACKUP -force

- open Notepad++ and edit the file %APPDATA%\deluge\state\torrents.state by replacing the URL
- start Deluge and check

If you have anything wrong stop Deluge again and recover the files from the backup.

Re: Batch change tracker URL for torrents

Posted: Tue Oct 06, 2020 9:55 pm
by stogie bear
Thanks shamael! I never realised the state file was in an editable format. Something went wrong the first time I tried but I used the backup and tried again and it works as expected now, no way i was going to manually change 125 torrents :lol:.

Re: Batch change tracker URL for torrents

Posted: Fri Feb 05, 2021 8:06 am
by neatchee
Sorry for the necro bump as well but I'm having trouble with this...

I have tried editing the torrents.state file in multiple ways (simple text editor, sed, python decode/encode, even via direct hex editing) and in all cases I wind up with what appears to be a corrupt state. Starting the daemon and connecting from my client results in a completely empty torrent list.

Is there something I'm missing? Did this somehow stop working in 2.x?

Any help would be appreciated!

Re: Batch change tracker URL for torrents

Posted: Fri Feb 05, 2021 1:32 pm
by shamael
Hi neatchee,

Concerning my post: I still use this method but I never test it on 2.X version so cannot tell. if still existing maybe a link with the resume file, both may be checked.

I think the new 2.0 interface allow you to edit multiple torrents directly no? Even if it doesn't help a lot for torrents with multiple tracker

Re: Batch change tracker URL for torrents

Posted: Tue Feb 09, 2021 3:36 am
by neatchee
Unfortunately the "Edit Trackers" option does not apply to all the torrents selected; only the first one :(

Re: Batch change tracker URL for torrents

Posted: Tue Feb 09, 2021 3:22 pm
by shamael
Damn, I was thinking this option was implemented. Are you sure all the Deluge process are closed prior editing the files?
It this confirmed with a "ps"?
On the 1.3.x version this is the only issue I've found.

What about the sed line you used, may you expose it? (remove any personal key)

Re: Batch change tracker URL for torrents

Posted: Sat Mar 06, 2021 12:35 am
by NoTcheu
I'm using Deluge 2.0.3 and I have tried every solution proposed on this thread but all ended up with a corruption of Deluge's state.

After checking how deluge-web was implemented, I found out that the whole API was pretty darn clear and accessible from the dev console.
From there you can easily retrieve which torrent is selected and send a tracker update to the daemon.

To do that select whatever torrents you'd like to update in the web interface and run the following in your Chrome / Firefox / other browser console. Don't forget to replace the dummy url with your tracker url ;)

Code: Select all

const trackers = [{"tier":0,"url":"http://tracker.url"}]
ids = deluge.torrents.getSelectedIds();
ids.forEach(id => {
    deluge.client.core.set_torrent_trackers(id, trackers, {
        failure: () => console.warn(`Failed to update ${id}`)

Based on this code, I would expect it to be possible to set multiple tracker urls by adding more entries to the list of trackers, but I've never tried it.

The frontend looks well implemented and quite modular, so one could easily embed this whole feature into a more user-friendly GUI.

Edit: If you have a lot of torrents selected (I tried with around 100) you may have to run it twice.