Created
September 7, 2020 07:57
-
-
Save fdgogogo/f316441a1a27b046718be00ec8588e9c to your computer and use it in GitHub Desktop.
Fix the issue 'Error: No data found! Ensure your drives are connected or use "Move Data File To...". To re-download, remove the torrent and re-add it.' caused by disk failure or mistakenly deletion By re-download all the torrents.
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Fix the issue 'Error: No data found! Ensure your drives are connected or use "Move Data File To...". To re-download, remove the torrent and re-add it.' | |
caused by disk failure or mistakenly deletion By re-download all the torrents. | |
Make a copy of the "torrents" dir from transmission config dir, the original one will be modified when script is running. | |
Authored by: Fang Jiaan ([email protected]) | |
""" | |
import os | |
torrent_path = '.' | |
files = os.listdir(torrent_path) # torrents copy dir | |
files = [os.path.join(torrent_path, f) for f in files] | |
username = '' | |
password = '' | |
auth = '--auth %s:%s' % (username, password) if (username and password) else '' | |
pp = os.popen('transmission-remote %s -l' % auth) | |
data = pp.read() | |
for line in data.splitlines()[1:-1]: | |
if 'Stopped' not in line: | |
continue | |
header = line[:4].strip() | |
id = header.strip('*') | |
info = os.popen('transmission-remote %s -t %s -i' % (auth, id)).read() | |
lines = info.splitlines() | |
loc = lines[8] | |
hash = lines[3] | |
hash = hash.split(' ')[-1][:16] | |
loc = loc.split(' ')[-1] | |
torrent = [x for x in files if hash in x][0] | |
print id, hash, loc, torrent | |
os.popen('transmission-remote %s -t %s --remove' % (auth, id)).read() | |
os.popen( | |
'transmission-remote %s --add "%s" -w %s' % (auth, torrent, loc)).read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment