Merge branches 'develop' and 'tv' of https://github.com/RuudBurger/CouchPotatoServer into tv
Conflicts: couchpotato/core/plugins/renamer/main.py
This commit is contained in:
@@ -57,13 +57,18 @@ class Downloader(Provider):
|
|||||||
return
|
return
|
||||||
return self.download(data = data, media = media, filedata = filedata)
|
return self.download(data = data, media = media, filedata = filedata)
|
||||||
|
|
||||||
def _getAllDownloadStatus(self):
|
def _getAllDownloadStatus(self, download_ids):
|
||||||
if self.isDisabled(manual = True, data = {}):
|
if self.isDisabled(manual = True, data = {}):
|
||||||
return
|
return
|
||||||
|
|
||||||
return self.getAllDownloadStatus()
|
ids = [download_id['id'] for download_id in download_ids if download_id['downloader'] == self.getName()]
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
if ids:
|
||||||
|
return self.getAllDownloadStatus(ids)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
def getAllDownloadStatus(self, ids):
|
||||||
return
|
return
|
||||||
|
|
||||||
def _removeFailed(self, release_download):
|
def _removeFailed(self, release_download):
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ class Blackhole(Downloader):
|
|||||||
with open(full_path, 'wb') as f:
|
with open(full_path, 'wb') as f:
|
||||||
f.write(filedata)
|
f.write(filedata)
|
||||||
os.chmod(full_path, Env.getPermission('file'))
|
os.chmod(full_path, Env.getPermission('file'))
|
||||||
return True
|
return self.downloadReturnId('')
|
||||||
else:
|
else:
|
||||||
log.info('File %s already exists.', full_path)
|
log.info('File %s already exists.', full_path)
|
||||||
return True
|
return self.downloadReturnId('')
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed to download to blackhole %s', traceback.format_exc())
|
log.error('Failed to download to blackhole %s', traceback.format_exc())
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Deluge(Downloader):
|
|||||||
log.info('Torrent sent to Deluge successfully.')
|
log.info('Torrent sent to Deluge successfully.')
|
||||||
return self.downloadReturnId(remote_torrent)
|
return self.downloadReturnId(remote_torrent)
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking Deluge download status.')
|
log.debug('Checking Deluge download status.')
|
||||||
|
|
||||||
@@ -103,38 +103,39 @@ class Deluge(Downloader):
|
|||||||
|
|
||||||
for torrent_id in queue:
|
for torrent_id in queue:
|
||||||
torrent = queue[torrent_id]
|
torrent = queue[torrent_id]
|
||||||
log.debug('name=%s / id=%s / save_path=%s / move_completed_path=%s / hash=%s / progress=%s / state=%s / eta=%s / ratio=%s / stop_ratio=%s / is_seed=%s / is_finished=%s / paused=%s', (torrent['name'], torrent['hash'], torrent['save_path'], torrent['move_completed_path'], torrent['hash'], torrent['progress'], torrent['state'], torrent['eta'], torrent['ratio'], torrent['stop_ratio'], torrent['is_seed'], torrent['is_finished'], torrent['paused']))
|
if torrent['hash'] in ids:
|
||||||
|
log.debug('name=%s / id=%s / save_path=%s / move_completed_path=%s / hash=%s / progress=%s / state=%s / eta=%s / ratio=%s / stop_ratio=%s / is_seed=%s / is_finished=%s / paused=%s', (torrent['name'], torrent['hash'], torrent['save_path'], torrent['move_completed_path'], torrent['hash'], torrent['progress'], torrent['state'], torrent['eta'], torrent['ratio'], torrent['stop_ratio'], torrent['is_seed'], torrent['is_finished'], torrent['paused']))
|
||||||
# Deluge has no easy way to work out if a torrent is stalled or failing.
|
|
||||||
#status = 'failed'
|
# Deluge has no easy way to work out if a torrent is stalled or failing.
|
||||||
status = 'busy'
|
#status = 'failed'
|
||||||
if torrent['is_seed'] and tryFloat(torrent['ratio']) < tryFloat(torrent['stop_ratio']):
|
status = 'busy'
|
||||||
# We have torrent['seeding_time'] to work out what the seeding time is, but we do not
|
if torrent['is_seed'] and tryFloat(torrent['ratio']) < tryFloat(torrent['stop_ratio']):
|
||||||
# have access to the downloader seed_time, as with deluge we have no way to pass it
|
# We have torrent['seeding_time'] to work out what the seeding time is, but we do not
|
||||||
# when the torrent is added. So Deluge will only look at the ratio.
|
# have access to the downloader seed_time, as with deluge we have no way to pass it
|
||||||
# See above comment in download().
|
# when the torrent is added. So Deluge will only look at the ratio.
|
||||||
status = 'seeding'
|
# See above comment in download().
|
||||||
elif torrent['is_seed'] and torrent['is_finished'] and torrent['paused'] and torrent['state'] == 'Paused':
|
status = 'seeding'
|
||||||
status = 'completed'
|
elif torrent['is_seed'] and torrent['is_finished'] and torrent['paused'] and torrent['state'] == 'Paused':
|
||||||
|
status = 'completed'
|
||||||
download_dir = sp(torrent['save_path'])
|
|
||||||
if torrent['move_on_completed']:
|
download_dir = sp(torrent['save_path'])
|
||||||
download_dir = torrent['move_completed_path']
|
if torrent['move_on_completed']:
|
||||||
|
download_dir = torrent['move_completed_path']
|
||||||
torrent_files = []
|
|
||||||
for file_item in torrent['files']:
|
torrent_files = []
|
||||||
torrent_files.append(sp(os.path.join(download_dir, file_item['path'])))
|
for file_item in torrent['files']:
|
||||||
|
torrent_files.append(sp(os.path.join(download_dir, file_item['path'])))
|
||||||
release_downloads.append({
|
|
||||||
'id': torrent['hash'],
|
release_downloads.append({
|
||||||
'name': torrent['name'],
|
'id': torrent['hash'],
|
||||||
'status': status,
|
'name': torrent['name'],
|
||||||
'original_status': torrent['state'],
|
'status': status,
|
||||||
'seed_ratio': torrent['ratio'],
|
'original_status': torrent['state'],
|
||||||
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
'seed_ratio': torrent['ratio'],
|
||||||
'folder': sp(download_dir if len(torrent_files) == 1 else os.path.join(download_dir, torrent['name'])),
|
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
||||||
'files': '|'.join(torrent_files),
|
'folder': sp(download_dir if len(torrent_files) == 1 else os.path.join(download_dir, torrent['name'])),
|
||||||
})
|
'files': '|'.join(torrent_files),
|
||||||
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class NZBGet(Downloader):
|
|||||||
log.error('NZBGet could not add %s to the queue.', nzb_name)
|
log.error('NZBGet could not add %s to the queue.', nzb_name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking NZBGet download status.')
|
log.debug('Checking NZBGet download status.')
|
||||||
|
|
||||||
@@ -102,51 +102,54 @@ class NZBGet(Downloader):
|
|||||||
release_downloads = ReleaseDownloadList(self)
|
release_downloads = ReleaseDownloadList(self)
|
||||||
|
|
||||||
for nzb in groups:
|
for nzb in groups:
|
||||||
log.debug('Found %s in NZBGet download queue', nzb['NZBFilename'])
|
|
||||||
try:
|
try:
|
||||||
nzb_id = [param['Value'] for param in nzb['Parameters'] if param['Name'] == 'couchpotato'][0]
|
nzb_id = [param['Value'] for param in nzb['Parameters'] if param['Name'] == 'couchpotato'][0]
|
||||||
except:
|
except:
|
||||||
nzb_id = nzb['NZBID']
|
nzb_id = nzb['NZBID']
|
||||||
|
|
||||||
|
if nzb_id in ids:
|
||||||
timeleft = -1
|
log.debug('Found %s in NZBGet download queue', nzb['NZBFilename'])
|
||||||
try:
|
timeleft = -1
|
||||||
if nzb['ActiveDownloads'] > 0 and nzb['DownloadRate'] > 0 and not (status['DownloadPaused'] or status['Download2Paused']):
|
try:
|
||||||
timeleft = str(timedelta(seconds = nzb['RemainingSizeMB'] / status['DownloadRate'] * 2 ^ 20))
|
if nzb['ActiveDownloads'] > 0 and nzb['DownloadRate'] > 0 and not (status['DownloadPaused'] or status['Download2Paused']):
|
||||||
except:
|
timeleft = str(timedelta(seconds = nzb['RemainingSizeMB'] / status['DownloadRate'] * 2 ^ 20))
|
||||||
pass
|
except:
|
||||||
|
pass
|
||||||
release_downloads.append({
|
|
||||||
'id': nzb_id,
|
release_downloads.append({
|
||||||
'name': nzb['NZBFilename'],
|
'id': nzb_id,
|
||||||
'original_status': 'DOWNLOADING' if nzb['ActiveDownloads'] > 0 else 'QUEUED',
|
'name': nzb['NZBFilename'],
|
||||||
# Seems to have no native API function for time left. This will return the time left after NZBGet started downloading this item
|
'original_status': 'DOWNLOADING' if nzb['ActiveDownloads'] > 0 else 'QUEUED',
|
||||||
'timeleft': timeleft,
|
# Seems to have no native API function for time left. This will return the time left after NZBGet started downloading this item
|
||||||
})
|
'timeleft': timeleft,
|
||||||
|
})
|
||||||
|
|
||||||
for nzb in queue: # 'Parameters' is not passed in rpc.postqueue
|
for nzb in queue: # 'Parameters' is not passed in rpc.postqueue
|
||||||
log.debug('Found %s in NZBGet postprocessing queue', nzb['NZBFilename'])
|
if nzb['NZBID'] in ids:
|
||||||
release_downloads.append({
|
log.debug('Found %s in NZBGet postprocessing queue', nzb['NZBFilename'])
|
||||||
'id': nzb['NZBID'],
|
release_downloads.append({
|
||||||
'name': nzb['NZBFilename'],
|
'id': nzb['NZBID'],
|
||||||
'original_status': nzb['Stage'],
|
'name': nzb['NZBFilename'],
|
||||||
'timeleft': str(timedelta(seconds = 0)) if not status['PostPaused'] else -1,
|
'original_status': nzb['Stage'],
|
||||||
})
|
'timeleft': str(timedelta(seconds = 0)) if not status['PostPaused'] else -1,
|
||||||
|
})
|
||||||
|
|
||||||
for nzb in history:
|
for nzb in history:
|
||||||
log.debug('Found %s in NZBGet history. ParStatus: %s, ScriptStatus: %s, Log: %s', (nzb['NZBFilename'] , nzb['ParStatus'], nzb['ScriptStatus'] , nzb['Log']))
|
|
||||||
try:
|
try:
|
||||||
nzb_id = [param['Value'] for param in nzb['Parameters'] if param['Name'] == 'couchpotato'][0]
|
nzb_id = [param['Value'] for param in nzb['Parameters'] if param['Name'] == 'couchpotato'][0]
|
||||||
except:
|
except:
|
||||||
nzb_id = nzb['NZBID']
|
nzb_id = nzb['NZBID']
|
||||||
release_downloads.append({
|
|
||||||
'id': nzb_id,
|
if nzb_id in ids:
|
||||||
'name': nzb['NZBFilename'],
|
log.debug('Found %s in NZBGet history. ParStatus: %s, ScriptStatus: %s, Log: %s', (nzb['NZBFilename'] , nzb['ParStatus'], nzb['ScriptStatus'] , nzb['Log']))
|
||||||
'status': 'completed' if nzb['ParStatus'] in ['SUCCESS', 'NONE'] and nzb['ScriptStatus'] in ['SUCCESS', 'NONE'] else 'failed',
|
release_downloads.append({
|
||||||
'original_status': nzb['ParStatus'] + ', ' + nzb['ScriptStatus'],
|
'id': nzb_id,
|
||||||
'timeleft': str(timedelta(seconds = 0)),
|
'name': nzb['NZBFilename'],
|
||||||
'folder': sp(nzb['DestDir'])
|
'status': 'completed' if nzb['ParStatus'] in ['SUCCESS', 'NONE'] and nzb['ScriptStatus'] in ['SUCCESS', 'NONE'] else 'failed',
|
||||||
})
|
'original_status': nzb['ParStatus'] + ', ' + nzb['ScriptStatus'],
|
||||||
|
'timeleft': str(timedelta(seconds = 0)),
|
||||||
|
'folder': sp(nzb['DestDir'])
|
||||||
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ from uuid import uuid4
|
|||||||
import hashlib
|
import hashlib
|
||||||
import httplib
|
import httplib
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
@@ -32,35 +34,37 @@ class NZBVortex(Downloader):
|
|||||||
nzb_filename = self.createFileName(data, filedata, media)
|
nzb_filename = self.createFileName(data, filedata, media)
|
||||||
self.call('nzb/add', params = {'file': (nzb_filename, filedata)}, multipart = True)
|
self.call('nzb/add', params = {'file': (nzb_filename, filedata)}, multipart = True)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
raw_statuses = self.call('nzb')
|
raw_statuses = self.call('nzb')
|
||||||
nzb_id = [nzb['id'] for nzb in raw_statuses.get('nzbs', []) if nzb['name'] == nzb_filename][0]
|
nzb_id = [nzb['id'] for nzb in raw_statuses.get('nzbs', []) if os.path.basename(item['nzbFileName']) == nzb_filename][0]
|
||||||
return self.downloadReturnId(nzb_id)
|
return self.downloadReturnId(nzb_id)
|
||||||
except:
|
except:
|
||||||
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
raw_statuses = self.call('nzb')
|
raw_statuses = self.call('nzb')
|
||||||
|
|
||||||
release_downloads = ReleaseDownloadList(self)
|
release_downloads = ReleaseDownloadList(self)
|
||||||
for nzb in raw_statuses.get('nzbs', []):
|
for nzb in raw_statuses.get('nzbs', []):
|
||||||
|
if nzb['id'] in ids:
|
||||||
|
|
||||||
# Check status
|
# Check status
|
||||||
status = 'busy'
|
status = 'busy'
|
||||||
if nzb['state'] == 20:
|
if nzb['state'] == 20:
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
elif nzb['state'] in [21, 22, 24]:
|
elif nzb['state'] in [21, 22, 24]:
|
||||||
status = 'failed'
|
status = 'failed'
|
||||||
|
|
||||||
release_downloads.append({
|
release_downloads.append({
|
||||||
'id': nzb['id'],
|
'id': nzb['id'],
|
||||||
'name': nzb['uiTitle'],
|
'name': nzb['uiTitle'],
|
||||||
'status': status,
|
'status': status,
|
||||||
'original_status': nzb['state'],
|
'original_status': nzb['state'],
|
||||||
'timeleft':-1,
|
'timeleft':-1,
|
||||||
'folder': sp(nzb['destinationPath']),
|
'folder': sp(nzb['destinationPath']),
|
||||||
})
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ class Pneumatic(Downloader):
|
|||||||
strm_file.write(strmContent)
|
strm_file.write(strmContent)
|
||||||
strm_file.close()
|
strm_file.close()
|
||||||
|
|
||||||
return True
|
return self.downloadReturnId('')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.info('File %s already exists.', fullPath)
|
log.info('File %s already exists.', fullPath)
|
||||||
return True
|
return self.downloadReturnId('')
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed to download .strm: %s', traceback.format_exc())
|
log.error('Failed to download .strm: %s', traceback.format_exc())
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class rTorrent(Downloader):
|
|||||||
log.error('Failed to send torrent to rTorrent: %s', err)
|
log.error('Failed to send torrent to rTorrent: %s', err)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
log.debug('Checking rTorrent download status.')
|
log.debug('Checking rTorrent download status.')
|
||||||
|
|
||||||
if not self.connect():
|
if not self.connect():
|
||||||
@@ -155,27 +155,28 @@ class rTorrent(Downloader):
|
|||||||
release_downloads = ReleaseDownloadList(self)
|
release_downloads = ReleaseDownloadList(self)
|
||||||
|
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
torrent_files = []
|
if torrent.info_hash in ids:
|
||||||
for file_item in torrent.get_files():
|
torrent_files = []
|
||||||
torrent_files.append(sp(os.path.join(torrent.directory, file_item.path)))
|
for file_item in torrent.get_files():
|
||||||
|
torrent_files.append(sp(os.path.join(torrent.directory, file_item.path)))
|
||||||
status = 'busy'
|
|
||||||
if torrent.complete:
|
status = 'busy'
|
||||||
if torrent.active:
|
if torrent.complete:
|
||||||
status = 'seeding'
|
if torrent.active:
|
||||||
else:
|
status = 'seeding'
|
||||||
status = 'completed'
|
else:
|
||||||
|
status = 'completed'
|
||||||
release_downloads.append({
|
|
||||||
'id': torrent.info_hash,
|
release_downloads.append({
|
||||||
'name': torrent.name,
|
'id': torrent.info_hash,
|
||||||
'status': status,
|
'name': torrent.name,
|
||||||
'seed_ratio': torrent.ratio,
|
'status': status,
|
||||||
'original_status': torrent.state,
|
'seed_ratio': torrent.ratio,
|
||||||
'timeleft': str(timedelta(seconds = float(torrent.left_bytes) / torrent.down_rate)) if torrent.down_rate > 0 else -1,
|
'original_status': torrent.state,
|
||||||
'folder': sp(torrent.directory),
|
'timeleft': str(timedelta(seconds = float(torrent.left_bytes) / torrent.down_rate)) if torrent.down_rate > 0 else -1,
|
||||||
'files': '|'.join(torrent_files)
|
'folder': sp(torrent.directory),
|
||||||
})
|
'files': '|'.join(torrent_files)
|
||||||
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Sabnzbd(Downloader):
|
|||||||
log.error('Error getting data from SABNZBd: %s', sab_data)
|
log.error('Error getting data from SABNZBd: %s', sab_data)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking SABnzbd download status.')
|
log.debug('Checking SABnzbd download status.')
|
||||||
|
|
||||||
@@ -91,35 +91,36 @@ class Sabnzbd(Downloader):
|
|||||||
|
|
||||||
# Get busy releases
|
# Get busy releases
|
||||||
for nzb in queue.get('slots', []):
|
for nzb in queue.get('slots', []):
|
||||||
status = 'busy'
|
if nzb['nzo_id'] in ids:
|
||||||
if 'ENCRYPTED / ' in nzb['filename']:
|
status = 'busy'
|
||||||
status = 'failed'
|
if 'ENCRYPTED / ' in nzb['filename']:
|
||||||
|
status = 'failed'
|
||||||
release_downloads.append({
|
|
||||||
'id': nzb['nzo_id'],
|
release_downloads.append({
|
||||||
'name': nzb['filename'],
|
'id': nzb['nzo_id'],
|
||||||
'status': status,
|
'name': nzb['filename'],
|
||||||
'original_status': nzb['status'],
|
'status': status,
|
||||||
'timeleft': nzb['timeleft'] if not queue['paused'] else -1,
|
'original_status': nzb['status'],
|
||||||
})
|
'timeleft': nzb['timeleft'] if not queue['paused'] else -1,
|
||||||
|
})
|
||||||
|
|
||||||
# Get old releases
|
# Get old releases
|
||||||
for nzb in history.get('slots', []):
|
for nzb in history.get('slots', []):
|
||||||
|
if nzb['nzo_id'] in ids:
|
||||||
status = 'busy'
|
status = 'busy'
|
||||||
if nzb['status'] == 'Failed' or (nzb['status'] == 'Completed' and nzb['fail_message'].strip()):
|
if nzb['status'] == 'Failed' or (nzb['status'] == 'Completed' and nzb['fail_message'].strip()):
|
||||||
status = 'failed'
|
status = 'failed'
|
||||||
elif nzb['status'] == 'Completed':
|
elif nzb['status'] == 'Completed':
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
|
|
||||||
release_downloads.append({
|
release_downloads.append({
|
||||||
'id': nzb['nzo_id'],
|
'id': nzb['nzo_id'],
|
||||||
'name': nzb['name'],
|
'name': nzb['name'],
|
||||||
'status': status,
|
'status': status,
|
||||||
'original_status': nzb['status'],
|
'original_status': nzb['status'],
|
||||||
'timeleft': str(timedelta(seconds = 0)),
|
'timeleft': str(timedelta(seconds = 0)),
|
||||||
'folder': sp(os.path.dirname(nzb['storage']) if os.path.isfile(nzb['storage']) else nzb['storage']),
|
'folder': sp(os.path.dirname(nzb['storage']) if os.path.isfile(nzb['storage']) else nzb['storage']),
|
||||||
})
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Synology(Downloader):
|
|||||||
except:
|
except:
|
||||||
log.error('Exception while adding torrent: %s', traceback.format_exc())
|
log.error('Exception while adding torrent: %s', traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
return response
|
return self.downloadReturnId('') if response else False
|
||||||
|
|
||||||
def getEnabledProtocol(self):
|
def getEnabledProtocol(self):
|
||||||
if self.conf('use_for') == 'both':
|
if self.conf('use_for') == 'both':
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Transmission(Downloader):
|
|||||||
log.info('Torrent sent to Transmission successfully.')
|
log.info('Torrent sent to Transmission successfully.')
|
||||||
return self.downloadReturnId(remote_torrent['torrent-added']['hashString'])
|
return self.downloadReturnId(remote_torrent['torrent-added']['hashString'])
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking Transmission download status.')
|
log.debug('Checking Transmission download status.')
|
||||||
|
|
||||||
@@ -102,31 +102,32 @@ class Transmission(Downloader):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
for torrent in queue['torrents']:
|
for torrent in queue['torrents']:
|
||||||
log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s',
|
if torrent['hashString'] in ids:
|
||||||
(torrent['name'], torrent['id'], torrent['downloadDir'], torrent['hashString'], torrent['percentDone'], torrent['status'], torrent['eta'], torrent['uploadRatio'], torrent['isFinished']))
|
log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s',
|
||||||
|
(torrent['name'], torrent['id'], torrent['downloadDir'], torrent['hashString'], torrent['percentDone'], torrent['status'], torrent['eta'], torrent['uploadRatio'], torrent['isFinished']))
|
||||||
torrent_files = []
|
|
||||||
for file_item in torrent['files']:
|
torrent_files = []
|
||||||
torrent_files.append(sp(os.path.join(torrent['downloadDir'], file_item['name'])))
|
for file_item in torrent['files']:
|
||||||
|
torrent_files.append(sp(os.path.join(torrent['downloadDir'], file_item['name'])))
|
||||||
status = 'busy'
|
|
||||||
if torrent.get('isStalled') and self.conf('stalled_as_failed'):
|
status = 'busy'
|
||||||
status = 'failed'
|
if torrent.get('isStalled') and self.conf('stalled_as_failed'):
|
||||||
elif torrent['status'] == 0 and torrent['percentDone'] == 1:
|
status = 'failed'
|
||||||
status = 'completed'
|
elif torrent['status'] == 0 and torrent['percentDone'] == 1:
|
||||||
elif torrent['status'] in [5, 6]:
|
status = 'completed'
|
||||||
status = 'seeding'
|
elif torrent['status'] in [5, 6]:
|
||||||
|
status = 'seeding'
|
||||||
release_downloads.append({
|
|
||||||
'id': torrent['hashString'],
|
release_downloads.append({
|
||||||
'name': torrent['name'],
|
'id': torrent['hashString'],
|
||||||
'status': status,
|
'name': torrent['name'],
|
||||||
'original_status': torrent['status'],
|
'status': status,
|
||||||
'seed_ratio': torrent['uploadRatio'],
|
'original_status': torrent['status'],
|
||||||
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
'seed_ratio': torrent['uploadRatio'],
|
||||||
'folder': sp(torrent['downloadDir'] if len(torrent_files) == 1 else os.path.join(torrent['downloadDir'], torrent['name'])),
|
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
||||||
'files': '|'.join(torrent_files)
|
'folder': sp(torrent['downloadDir'] if len(torrent_files) == 1 else os.path.join(torrent['downloadDir'], torrent['name'])),
|
||||||
})
|
'files': '|'.join(torrent_files)
|
||||||
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
return self.downloadReturnId(torrent_hash)
|
return self.downloadReturnId(torrent_hash)
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking uTorrent download status.')
|
log.debug('Checking uTorrent download status.')
|
||||||
|
|
||||||
@@ -130,47 +130,48 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
# Get torrents
|
# Get torrents
|
||||||
for torrent in queue['torrents']:
|
for torrent in queue['torrents']:
|
||||||
|
if torrent[0] in ids:
|
||||||
|
|
||||||
#Get files of the torrent
|
#Get files of the torrent
|
||||||
torrent_files = []
|
torrent_files = []
|
||||||
try:
|
try:
|
||||||
torrent_files = json.loads(self.utorrent_api.get_files(torrent[0]))
|
torrent_files = json.loads(self.utorrent_api.get_files(torrent[0]))
|
||||||
torrent_files = [sp(os.path.join(torrent[26], torrent_file[0])) for torrent_file in torrent_files['files'][1]]
|
torrent_files = [sp(os.path.join(torrent[26], torrent_file[0])) for torrent_file in torrent_files['files'][1]]
|
||||||
except:
|
except:
|
||||||
log.debug('Failed getting files from torrent: %s', torrent[2])
|
log.debug('Failed getting files from torrent: %s', torrent[2])
|
||||||
|
|
||||||
status_flags = {
|
status_flags = {
|
||||||
"STARTED" : 1,
|
"STARTED" : 1,
|
||||||
"CHECKING" : 2,
|
"CHECKING" : 2,
|
||||||
"CHECK-START" : 4,
|
"CHECK-START" : 4,
|
||||||
"CHECKED" : 8,
|
"CHECKED" : 8,
|
||||||
"ERROR" : 16,
|
"ERROR" : 16,
|
||||||
"PAUSED" : 32,
|
"PAUSED" : 32,
|
||||||
"QUEUED" : 64,
|
"QUEUED" : 64,
|
||||||
"LOADED" : 128
|
"LOADED" : 128
|
||||||
}
|
}
|
||||||
|
|
||||||
status = 'busy'
|
status = 'busy'
|
||||||
if (torrent[1] & status_flags["STARTED"] or torrent[1] & status_flags["QUEUED"]) and torrent[4] == 1000:
|
if (torrent[1] & status_flags["STARTED"] or torrent[1] & status_flags["QUEUED"]) and torrent[4] == 1000:
|
||||||
status = 'seeding'
|
status = 'seeding'
|
||||||
elif (torrent[1] & status_flags["ERROR"]):
|
elif (torrent[1] & status_flags["ERROR"]):
|
||||||
status = 'failed'
|
status = 'failed'
|
||||||
elif torrent[4] == 1000:
|
elif torrent[4] == 1000:
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
|
|
||||||
if not status == 'busy':
|
if not status == 'busy':
|
||||||
self.removeReadOnly(torrent_files)
|
self.removeReadOnly(torrent_files)
|
||||||
|
|
||||||
release_downloads.append({
|
release_downloads.append({
|
||||||
'id': torrent[0],
|
'id': torrent[0],
|
||||||
'name': torrent[2],
|
'name': torrent[2],
|
||||||
'status': status,
|
'status': status,
|
||||||
'seed_ratio': float(torrent[7]) / 1000,
|
'seed_ratio': float(torrent[7]) / 1000,
|
||||||
'original_status': torrent[1],
|
'original_status': torrent[1],
|
||||||
'timeleft': str(timedelta(seconds = torrent[10])),
|
'timeleft': str(timedelta(seconds = torrent[10])),
|
||||||
'folder': sp(torrent[26]),
|
'folder': sp(torrent[26]),
|
||||||
'files': '|'.join(torrent_files)
|
'files': '|'.join(torrent_files)
|
||||||
})
|
})
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ def sp(path, *args):
|
|||||||
if not path or len(path) == 0:
|
if not path or len(path) == 0:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
# convert windows path (from remote box) to *nix path
|
||||||
|
if os.path.sep == '/' and '\\' in path:
|
||||||
|
path = '/' + path.replace(':', '').replace('\\', '/')
|
||||||
|
|
||||||
path = os.path.normcase(os.path.normpath(ss(path, *args)))
|
path = os.path.normcase(os.path.normpath(ss(path, *args)))
|
||||||
|
|
||||||
if path != os.path.sep:
|
if path != os.path.sep:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import fireEvent, addEvent, fireEventAsync
|
from couchpotato.core.event import fireEvent, addEvent, fireEventAsync
|
||||||
from couchpotato.core.helpers.encoding import ss
|
from couchpotato.core.helpers.encoding import sp
|
||||||
from couchpotato.core.helpers.variable import splitString, getTitle
|
from couchpotato.core.helpers.variable import splitString, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
@@ -122,12 +122,10 @@ class Manage(Plugin):
|
|||||||
releases = fireEvent('release.for_movie', id = done_movie.get('id'), single = True)
|
releases = fireEvent('release.for_movie', id = done_movie.get('id'), single = True)
|
||||||
|
|
||||||
for release in releases:
|
for release in releases:
|
||||||
if len(release.get('files', [])) == 0:
|
if len(release.get('files', [])) > 0:
|
||||||
fireEvent('release.delete', release['id'])
|
|
||||||
else:
|
|
||||||
for release_file in release.get('files', []):
|
for release_file in release.get('files', []):
|
||||||
# Remove release not available anymore
|
# Remove release not available anymore
|
||||||
if not os.path.isfile(ss(release_file['path'])):
|
if not os.path.isfile(sp(release_file['path'])):
|
||||||
fireEvent('release.clean', release['id'])
|
fireEvent('release.clean', release['id'])
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class Release(Plugin):
|
|||||||
value = toUnicode(download_result.get(key))
|
value = toUnicode(download_result.get(key))
|
||||||
)
|
)
|
||||||
rls.info.append(rls_info)
|
rls.info.append(rls_info)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
log_movie = '%s (%s) in %s' % (getTitle(media['library']), media['library']['year'], rls.quality.label)
|
log_movie = '%s (%s) in %s' % (getTitle(media['library']), media['library']['year'], rls.quality.label)
|
||||||
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
||||||
|
|||||||
@@ -403,13 +403,13 @@ class Renamer(Plugin):
|
|||||||
remove_leftovers = True
|
remove_leftovers = True
|
||||||
|
|
||||||
# Add it to the wanted list before we continue
|
# Add it to the wanted list before we continue
|
||||||
if len(library_ent.media) == 0:
|
if len(library_ent.movies) == 0:
|
||||||
profile = db.query(Profile).filter_by(core = True, label = group['meta_data']['quality']['label']).first()
|
profile = db.query(Profile).filter_by(core = True, label = group['meta_data']['quality']['label']).first()
|
||||||
fireEvent('movie.add', params = {'identifier': group['library']['identifier'], 'profile_id': profile.id}, search_after = False)
|
fireEvent('movie.add', params = {'identifier': group['library']['identifier'], 'profile_id': profile.id}, search_after = False)
|
||||||
db.expire_all()
|
db.expire_all()
|
||||||
library_ent = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
library_ent = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
|
||||||
|
|
||||||
for movie in library_ent.media:
|
for movie in library_ent.movies:
|
||||||
|
|
||||||
# Mark movie "done" once it's found the quality with the finish check
|
# Mark movie "done" once it's found the quality with the finish check
|
||||||
try:
|
try:
|
||||||
@@ -820,7 +820,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
try:
|
try:
|
||||||
for rel in rels:
|
for rel in rels:
|
||||||
rel_dict = rel.to_dict({'info': {}})
|
rel_dict = rel.to_dict({'info': {}})
|
||||||
movie_dict = fireEvent('media.get', media_id = rel.media_id, single = True)
|
movie_dict = fireEvent('media.get', media_id = rel.movie_id, single = True)
|
||||||
|
|
||||||
if not isinstance(rel_dict['info'], (dict)):
|
if not isinstance(rel_dict['info'], (dict)):
|
||||||
log.error('Faulty release found without any info, ignoring.')
|
log.error('Faulty release found without any info, ignoring.')
|
||||||
@@ -878,7 +878,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
fireEvent('download.remove_failed', release_download, single = True)
|
fireEvent('download.remove_failed', release_download, single = True)
|
||||||
|
|
||||||
if self.conf('next_on_failed'):
|
if self.conf('next_on_failed'):
|
||||||
fireEvent('movie.searcher.try_next_release', media_id = rel.media_id)
|
fireEvent('movie.searcher.try_next_release', media_id = rel.movie_id)
|
||||||
elif release_download['status'] == 'completed':
|
elif release_download['status'] == 'completed':
|
||||||
log.info('Download of %s completed!', release_download['name'])
|
log.info('Download of %s completed!', release_download['name'])
|
||||||
if self.statusInfoComplete(release_download):
|
if self.statusInfoComplete(release_download):
|
||||||
|
|||||||
Reference in New Issue
Block a user