Skip to content

Instantly share code, notes, and snippets.

@kolen
Created February 13, 2009 20:06
Show Gist options
  • Save kolen/64074 to your computer and use it in GitHub Desktop.
Save kolen/64074 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# migrate torrents from ktorrent to transmission
import re
import os, os.path
ktorrent_path=os.path.expanduser("~/.kde/share/apps/ktorrent")
transmission_address = "localhost:27577"
transmission_args = ""
def execute_trremote_for_torrent(path):
statsfile = open("%s/stats" % path)
for line in statsfile.readlines():
m = re.match("OUTPUTDIR=(.*)/[^/]+/\s*", line)
if m:
outputdir = m.group(1)
cmdline = "transmission-remote %s -a \"%s/torrent\" --download-dir \"%s\" %s" % (transmission_address, path, outputdir, transmission_args)
print cmdline
os.system(cmdline)
def find_all_torrents():
dirs = os.listdir(ktorrent_path)
for dirname in dirs:
if dirname.startswith('tor'):
execute_trremote_for_torrent("%s/%s" % (ktorrent_path, dirname))
if __name__ == "__main__":
find_all_torrents()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment