Created
September 7, 2015 14:02
-
-
Save cas--/80878b98619e985932db to your computer and use it in GitHub Desktop.
Verify torrents.state file
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 characters
#!/usr/bin/env python | |
# | |
# Find and replace tracker urls in a Deluge torrents.state | |
# | |
# Need to edit the variables: orig_tracker_url and new_tracker_url | |
import os | |
import sys | |
import platform | |
import cPickle | |
if platform.system() in ['Windows', 'Microsoft']: | |
state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'state', 'torrents.state') | |
deluge_dir = os.path.join(os.environ['ProgramFiles'], 'Deluge') | |
if os.path.isdir(deluge_dir): | |
sys.path.append(deluge_dir) | |
for item in os.listdir(deluge_dir): | |
if item.endswith(('.egg', '.zip')): | |
sys.path.append(os.path.join(deluge_dir, item)) | |
else: | |
state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state') | |
state_file = open(state_file_path, 'rb') | |
state = cPickle.load(state_file) | |
state_file.close() | |
for t in state.torrents: | |
print t.filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment