|
@ -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 |
|
|
|
|
|
|
|
|