Created
February 25, 2022 16:44
Revisions
-
Sispheor created this gist
Feb 25, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ import os import sys import platform import shutil import pickle as cPickle # Config orig_tracker_url = [ "http://domain.net:8080/key/announce", "http://domain2.net:8080/key/announce", ] new_tracker_url = "http://new.domain:8080/key/announce" state_file_path = os.path.expanduser('/data/deluge/.config/deluge/state/torrents.state') # Run state_file = open(state_file_path, 'rb') state = cPickle.load(state_file) state_file.close() state_modified = False for torrent in state.torrents: for idx, tracker in enumerate(torrent.trackers[:]): #print(tracker['url']) if tracker['url'] in orig_tracker_url: #print(torrent.trackers[idx]['url']) torrent.trackers[idx]['url'] = new_tracker_url state_modified = True if state_modified: shutil.copyfile(state_file_path, state_file_path + '.old') state_file = open(state_file_path, 'wb') cPickle.dump(state, state_file) state_file.close() print("State Updated") else: print("Nothing to do")