Skip to content

Instantly share code, notes, and snippets.

@vanquishregret
Forked from noah/fix_rtorrent.py
Created March 19, 2014 23:53
Show Gist options
  • Save vanquishregret/9654230 to your computer and use it in GitHub Desktop.
Save vanquishregret/9654230 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
SESSION_DIR = '/path/to/.sessions'
# ^ should match session_path from .rtorrent.rc
MV_DIR = '/downloads/complete/tracker1.com'
# ^ Change this to path these files should have been moved to
import os
import sys
import glob
try:
from bencode import bdecode,bencode
except:
print "Please rune # easy_install BitTorrent_bencode"
sys.exit()
sys.path.append('/usr/lib/python2.6/site-packages/BTL')
for torrent in glob.glob(SESSION_DIR):
data = bdecode(open(str(torrent),'rb').read())
path = data['rtorrent']['directory']
dir = os.path.basename(path)
target = os.path.join(MV_DIR,dir)
os.system("mv '%s' '%s'" % (path,target))
data['rtorrent']['directory'] = target
data = bencode(data)
f = open(str(torrent),'w')
f.write(data)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment