Include files from downloader in renamer
This commit is contained in:
1 parent
a09e8b63ae
commit
54c7aad57a
3 files changed
+23
-39
No files matched your search
@@ -190,6 +190,7 @@ class StatusList(list):
|
|||||||
'status': 'busy',
|
'status': 'busy',
|
||||||
'downloader': self.provider.getName(),
|
'downloader': self.provider.getName(),
|
||||||
'folder': '',
|
'folder': '',
|
||||||
|
'files': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeDicts(defaults, result)
|
return mergeDicts(defaults, result)
|
||||||
|
|||||||
@@ -102,39 +102,6 @@ class uTorrent(Downloader):
|
|||||||
if self.conf('paused', default = 0):
|
if self.conf('paused', default = 0):
|
||||||
self.utorrent_api.pause_torrent(torrent_hash)
|
self.utorrent_api.pause_torrent(torrent_hash)
|
||||||
|
|
||||||
count = 0
|
|
||||||
while True:
|
|
||||||
|
|
||||||
count += 1
|
|
||||||
# Check if torrent is saved in subfolder of torrent name
|
|
||||||
getfiles_data = self.utorrent_api.get_files(torrent_hash)
|
|
||||||
|
|
||||||
torrent_files = json.loads(getfiles_data)
|
|
||||||
if torrent_files.get('error'):
|
|
||||||
log.error('Error getting data from uTorrent: %s', torrent_files.get('error'))
|
|
||||||
return False
|
|
||||||
|
|
||||||
if (torrent_files.get('files') and len(torrent_files['files'][1]) > 0) or count > 60:
|
|
||||||
break
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# Torrent has only one file, so uTorrent wont create a folder for it
|
|
||||||
if len(torrent_files['files'][1]) == 1:
|
|
||||||
# Remove torrent and try again
|
|
||||||
self.utorrent_api.remove_torrent(torrent_hash, remove_data = True)
|
|
||||||
|
|
||||||
# Send request to uTorrent
|
|
||||||
if data.get('protocol') == 'torrent_magnet':
|
|
||||||
self.utorrent_api.add_torrent_uri(torrent_filename, data.get('url'), add_folder = True)
|
|
||||||
else:
|
|
||||||
self.utorrent_api.add_torrent_file(torrent_filename, filedata, add_folder = True)
|
|
||||||
|
|
||||||
# Change settings of added torrent
|
|
||||||
self.utorrent_api.set_torrent(torrent_hash, torrent_params)
|
|
||||||
if self.conf('paused', default = 0):
|
|
||||||
self.utorrent_api.pause_torrent(torrent_hash)
|
|
||||||
|
|
||||||
return self.downloadReturnId(torrent_hash)
|
return self.downloadReturnId(torrent_hash)
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self):
|
||||||
@@ -172,6 +139,14 @@ class uTorrent(Downloader):
|
|||||||
status = 'seeding'
|
status = 'seeding'
|
||||||
self.removeReadOnly(item[26])
|
self.removeReadOnly(item[26])
|
||||||
|
|
||||||
|
#Get files of the torrent
|
||||||
|
torrent_files = ''
|
||||||
|
try:
|
||||||
|
torrent_files = json.loads(self.utorrent_api.get_files(item[0]))
|
||||||
|
torrent_files = [os.path.join(item[26], torrent_file[0]) for torrent_file in torrent_files['files'][1]]
|
||||||
|
except:
|
||||||
|
log.debug('Failed getting files from torrent: %s', item[2])
|
||||||
|
|
||||||
statuses.append({
|
statuses.append({
|
||||||
'id': item[0],
|
'id': item[0],
|
||||||
'name': item[2],
|
'name': item[2],
|
||||||
@@ -180,6 +155,7 @@ class uTorrent(Downloader):
|
|||||||
'original_status': item[1],
|
'original_status': item[1],
|
||||||
'timeleft': str(timedelta(seconds = item[10])),
|
'timeleft': str(timedelta(seconds = item[10])),
|
||||||
'folder': ss(item[26]),
|
'folder': ss(item[26]),
|
||||||
|
'files': ss('|'.join(torrent_files))
|
||||||
})
|
})
|
||||||
|
|
||||||
return statuses
|
return statuses
|
||||||
|
|||||||
@@ -115,12 +115,19 @@ class Renamer(Plugin):
|
|||||||
movie_folder = movie_folder.rstrip(os.path.sep)
|
movie_folder = movie_folder.rstrip(os.path.sep)
|
||||||
folder = os.path.dirname(movie_folder)
|
folder = os.path.dirname(movie_folder)
|
||||||
|
|
||||||
# Get all files from the specified folder
|
if download_info['files']:
|
||||||
try:
|
files = download_info['files'].split('|')
|
||||||
for root, folders, names in os.walk(movie_folder):
|
|
||||||
files.extend([os.path.join(root, name) for name in names])
|
# If there is only one file in the torrent, the downloader did not create a subfolder
|
||||||
except:
|
if len(files) == 1:
|
||||||
log.error('Failed getting files from %s: %s', (movie_folder, traceback.format_exc()))
|
folder = movie_folder
|
||||||
|
else:
|
||||||
|
# Get all files from the specified folder
|
||||||
|
try:
|
||||||
|
for root, folders, names in os.walk(movie_folder):
|
||||||
|
files.extend([os.path.join(root, name) for name in names])
|
||||||
|
except:
|
||||||
|
log.error('Failed getting files from %s: %s', (movie_folder, traceback.format_exc()))
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user