Skip to content

Instantly share code, notes, and snippets.

@mattatcha
Forked from cas--/deluge_tracker_rename.py
Last active June 29, 2016 03:41
Show Gist options
  • Save mattatcha/2d4bdd6f0c2079b7c7521e5a2b7b0417 to your computer and use it in GitHub Desktop.
Save mattatcha/2d4bdd6f0c2079b7c7521e5a2b7b0417 to your computer and use it in GitHub Desktop.

Revisions

  1. mattatcha revised this gist Jun 29, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions deluge_update_auto_manage.py
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@

    state_modified = False
    for torrent in state.torrents:
    if torrent["auto_managed"]:
    torrent["auto_managed"] = False
    if torrent.auto_managed:
    torrent.auto_managed = False
    state_modified = True

    if state_modified:
  2. mattatcha revised this gist Jun 29, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions deluge_update_auto_manage.py
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@

    state_modified = False
    for torrent in state.torrents:
    if torrent.options["auto_managed"]:
    torrent.options["auto_managed"] = False
    if torrent["auto_managed"]:
    torrent["auto_managed"] = False
    state_modified = True

    if state_modified:
  3. mattatcha revised this gist Jun 29, 2016. 1 changed file with 1 addition and 9 deletions.
    10 changes: 1 addition & 9 deletions deluge_update_auto_manage.py
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,12 @@
    #!/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 shutil
    import cPickle

    orig_tracker_url = 'udp://xxx'
    new_tracker_url = 'udp://xxx'

    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')
    @@ -25,7 +19,6 @@
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

    print("State file: %s" % state_file_path)
    print("Replace '%s' with '%s'" % (orig_tracker_url, new_tracker_url))
    state_file = open(state_file_path, 'rb')
    state = cPickle.load(state_file)
    state_file.close()
    @@ -36,7 +29,6 @@
    torrent.options["auto_managed"] = False
    state_modified = True


    if state_modified:
    shutil.copyfile(state_file_path, state_file_path + '.old')
    state_file = open(state_file_path, 'wb')
  4. mattatcha renamed this gist Jun 29, 2016. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions deluge_tracker_rename.py → deluge_update_auto_manage.py
    Original file line number Diff line number Diff line change
    @@ -32,10 +32,9 @@

    state_modified = False
    for torrent in state.torrents:
    for tracker in torrent.trackers:
    if tracker['url'] == orig_tracker_url:
    tracker['url'] = new_tracker_url
    state_modified = True
    if torrent.options["auto_managed"]:
    torrent.options["auto_managed"] = False
    state_modified = True


    if state_modified:
  5. @cas-- cas-- revised this gist Sep 18, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions deluge_tracker_rename.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    #!/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
  6. @cas-- cas-- renamed this gist Apr 6, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @cas-- cas-- revised this gist Apr 6, 2013. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    import os
    import sys
    import platform
    import shutil
    import cPickle
    @@ -8,6 +9,12 @@

    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')

  8. @cas-- cas-- revised this gist Apr 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

    print("State file: %s" % state_file_path)
    print("Replace '{}' with '{}'").format(orig_tracker_url, new_tracker_url)
    print("Replace '%s' with '%s'" % (orig_tracker_url, new_tracker_url))
    state_file = open(state_file_path, 'rb')
    state = cPickle.load(state_file)
    state_file.close()
  9. @cas-- cas-- revised this gist Apr 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    new_tracker_url = 'udp://xxx'

    if platform.system() in ('Windows', 'Microsoft'):
    state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'torrents.state')
    state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'state', 'torrents.state')
    else:
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

  10. @cas-- cas-- revised this gist Apr 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

    print("State file: %s" % state_file_path)
    print("Replace '%s' with '%s'", orig_tracker_url, new_tracker_url)
    print("Replace '{}' with '{}'").format(orig_tracker_url, new_tracker_url)
    state_file = open(state_file_path, 'rb')
    state = cPickle.load(state_file)
    state_file.close()
  11. @cas-- cas-- revised this gist Apr 6, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,8 @@
    else:
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

    print "State file: %s" % state_file_path
    print "Replace '%s' with '%s'" % (orig_tracker_url, new_tracker_url)
    print("State file: %s" % state_file_path)
    print("Replace '%s' with '%s'", orig_tracker_url, new_tracker_url)
    state_file = open(state_file_path, 'rb')
    state = cPickle.load(state_file)
    state_file.close()
    @@ -30,6 +30,6 @@
    state_file = open(state_file_path, 'wb')
    cPickle.dump(state, state_file)
    state_file.close()
    print "State Updated"
    print("State Updated")
    else:
    print "Nothing to do"
    print("Nothing to do")
  12. @cas-- cas-- renamed this gist Apr 6, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @cas-- cas-- created this gist Apr 6, 2013.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    import os
    import platform
    import shutil
    import cPickle

    orig_tracker_url = 'udp://xxx'
    new_tracker_url = 'udp://xxx'

    if platform.system() in ('Windows', 'Microsoft'):
    state_file_path = os.path.join(os.environ.get('APPDATA'), 'deluge', 'torrents.state')
    else:
    state_file_path = os.path.expanduser('~/.config/deluge/state/torrents.state')

    print "State file: %s" % state_file_path
    print "Replace '%s' with '%s'" % (orig_tracker_url, new_tracker_url)
    state_file = open(state_file_path, 'rb')
    state = cPickle.load(state_file)
    state_file.close()

    state_modified = False
    for torrent in state.torrents:
    for tracker in torrent.trackers:
    if tracker['url'] == orig_tracker_url:
    tracker['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"