Batch change tracker URL for torrents

General support for problems installing or using Deluge
marteenzh
New User
New User
Posts: 2
Joined: Mon Mar 27, 2017 9:47 pm

Re: Batch change tracker URL for torrents

Post 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 http://osxdaily.com/2013/08/20/find-rep ... mand-line/
stogie bear
New User
New User
Posts: 8
Joined: Sun Dec 04, 2016 1:57 am

Re: Batch change tracker URL for torrents

Post 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 "deluge_tracker_rename.py", 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.
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: Batch change tracker URL for torrents

Post by shamael »

Hi stogie bear,

Under Linux I published the solution I use many times per year now here viewtopic.php?f=7&t=54491&p=226225&hili ... er#p226225
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.

Info:
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.
stogie bear
New User
New User
Posts: 8
Joined: Sun Dec 04, 2016 1:57 am

Re: Batch change tracker URL for torrents

Post 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:.
neatchee
New User
New User
Posts: 4
Joined: Sun Jan 18, 2015 11:04 am

Re: Batch change tracker URL for torrents

Post 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!
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: Batch change tracker URL for torrents

Post 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
neatchee
New User
New User
Posts: 4
Joined: Sun Jan 18, 2015 11:04 am

Re: Batch change tracker URL for torrents

Post by neatchee »

Unfortunately the "Edit Trackers" option does not apply to all the torrents selected; only the first one :(
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: Batch change tracker URL for torrents

Post 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)
NoTcheu
New User
New User
Posts: 1
Joined: Sat Mar 06, 2021 12:16 am

Re: Batch change tracker URL for torrents

Post 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.
Post Reply