示例#1
0
    def getAllDownloadStatus(self):
        log.debug('Checking rTorrent download status.')

        if not self.connect():
            return False

        try:
            torrents = self.rt.get_torrents()

            statuses = StatusList(self)

            for item in torrents:
                status = 'busy'
                if item.complete:
                    if item.active:
                        status = 'seeding'
                    else:
                        status = 'completed'

                statuses.append({
                    'id': item.info_hash,
                    'name': item.name,
                    'status': status,
                    'seed_ratio': item.ratio,
                    'original_status': item.state,
                    'timeleft': str(timedelta(seconds = float(item.left_bytes) / item.down_rate)) if item.down_rate > 0 else -1,
                    'folder': ss(item.directory)
                })

            return statuses

        except Exception, err:
            log.error('Failed to get status from rTorrent: %s', err)
            return False
示例#2
0
    def getAllDownloadStatus(self):
        log.debug('Checking rTorrent download status.')

        if not self.connect():
            return False

        try:
            torrents = self.rt.get_torrents()

            statuses = StatusList(self)

            for item in torrents:
                status = 'busy'
                if item.complete:
                    if item.active:
                        status = 'seeding'
                    else:
                        status = 'completed'

                statuses.append({
                    'id': item.info_hash,
                    'name': item.name,
                    'status': status,
                    'seed_ratio': item.ratio,
                    'original_status': item.state,
                    'timeleft': str(timedelta(seconds = float(item.left_bytes) / item.down_rate)) if item.down_rate > 0 else -1,
                    'folder': ss(item.directory)
                })

            return statuses

        except Exception, err:
            log.error('Failed to get status from rTorrent: %s', err)
            return False
示例#3
0
    def getAllDownloadStatus(self):

        log.debug('Checking SABnzbd download status.')

        # Go through Queue
        try:
            queue = self.call({
                'mode': 'queue',
            })
        except:
            log.error('Failed getting queue: %s', traceback.format_exc(1))
            return False

        # Go through history items
        try:
            history = self.call({
                'mode': 'history',
                'limit': 15,
            })
        except:
            log.error('Failed getting history json: %s',
                      traceback.format_exc(1))
            return False

        statuses = StatusList(self)

        # Get busy releases
        for item in queue.get('slots', []):
            statuses.append({
                'id':
                item['nzo_id'],
                'name':
                item['filename'],
                'original_status':
                item['status'],
                'timeleft':
                item['timeleft'] if not queue['paused'] else -1,
            })

        # Get old releases
        for item in history.get('slots', []):

            status = 'busy'
            if item['status'] == 'Failed' or (item['status'] == 'Completed' and
                                              item['fail_message'].strip()):
                status = 'failed'
            elif item['status'] == 'Completed':
                status = 'completed'

            statuses.append({
                'id': item['nzo_id'],
                'name': item['name'],
                'status': status,
                'original_status': item['status'],
                'timeleft': str(timedelta(seconds=0)),
                'folder': item['storage'],
            })

        return statuses
示例#4
0
    def getAllDownloadStatus(self):

        log.debug('Checking SABnzbd download status.')

        # Go through Queue
        try:
            queue = self.call({
                'mode': 'queue',
            })
        except:
            log.error('Failed getting queue: %s', traceback.format_exc(1))
            return False

        # Go through history items
        try:
            history = self.call({
                'mode': 'history',
                'limit': 15,
            })
        except:
            log.error('Failed getting history json: %s', traceback.format_exc(1))
            return False

        statuses = StatusList(self)

        # Get busy releases
        for item in queue.get('slots', []):
            status = 'busy'
            if 'ENCRYPTED / ' in item['filename']:
                status = 'failed'

            statuses.append({
                'id': item['nzo_id'],
                'name': item['filename'],
                'status': status,
                'original_status': item['status'],
                'timeleft': item['timeleft'] if not queue['paused'] else -1,
            })

        # Get old releases
        for item in history.get('slots', []):

            status = 'busy'
            if item['status'] == 'Failed' or (item['status'] == 'Completed' and item['fail_message'].strip()):
                status = 'failed'
            elif item['status'] == 'Completed':
                status = 'completed'

            statuses.append({
                'id': item['nzo_id'],
                'name': item['name'],
                'status': status,
                'original_status': item['status'],
                'timeleft': str(timedelta(seconds = 0)),
                'folder': ss(item['storage']),
            })

        return statuses
示例#5
0
    def getAllDownloadStatus(self):

        log.debug('Checking Deluge download status.')

        if not os.path.isdir(Env.setting('from', 'renamer')):
            log.error('Renamer "from" folder doesn\'t to exist.')
            return

        if not self.connect():
            return False

        statuses = StatusList(self)

        queue = self.drpc.get_alltorrents()

        if not queue:
            log.debug('Nothing in queue or error')
            return False

        for torrent_id in queue:
            item = 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', (item['name'], item['hash'], item['save_path'], item['move_completed_path'], item['hash'], item['progress'], item['state'], item['eta'], item['ratio'], item['stop_ratio'], item['is_seed'], item['is_finished'], item['paused']))

            # Deluge has no easy way to work out if a torrent is stalled or failing.
            #status = 'failed'
            status = 'busy'
            if item['is_seed'] and tryFloat(item['ratio']) < tryFloat(item['stop_ratio']):
                # We have item['seeding_time'] to work out what the seeding time is, but we do not
                # have access to the downloader seed_time, as with deluge we have no way to pass it
                # when the torrent is added. So Deluge will only look at the ratio.
                # See above comment in download().
                status = 'seeding'
            elif item['is_seed'] and item['is_finished'] and item['paused'] and item['state'] == 'Paused':
                status = 'completed'

            download_dir = item['save_path']
            if item['move_on_completed']:
                download_dir = item['move_completed_path']

            statuses.append({
                'id': item['hash'],
                'name': item['name'],
                'status': status,
                'original_status': item['state'],
                'seed_ratio': item['ratio'],
                'timeleft': str(timedelta(seconds = item['eta'])),
                'folder': ss(os.path.join(download_dir, item['name'])),
            })

        return statuses
示例#6
0
    def getAllDownloadStatus(self):

        log.debug('Checking uTorrent download status.')

        if not self.connect():
            return False

        statuses = StatusList(self)

        data = self.utorrent_api.get_status()
        if not data:
            log.error('Error getting data from uTorrent')
            return False

        queue = json.loads(data)
        if queue.get('error'):
            log.error('Error getting data from uTorrent: %s',
                      queue.get('error'))
            return False

        if not queue.get('torrents'):
            log.debug('Nothing in queue')
            return False

        # Get torrents
        for item in queue['torrents']:

            # item[21] = Paused | Downloading | Seeding | Finished
            status = 'busy'
            if 'Finished' in item[21]:
                status = 'completed'
                self.removeReadOnly(item[26])
            elif 'Seeding' in item[21]:
                status = 'seeding'
                self.removeReadOnly(item[26])

            statuses.append({
                'id': item[0],
                'name': item[2],
                'status': status,
                'seed_ratio': float(item[7]) / 1000,
                'original_status': item[1],
                'timeleft': str(timedelta(seconds=item[10])),
                'folder': ss(item[26]),
            })

        return statuses
示例#7
0
    def getAllDownloadStatus(self):

        log.debug('Checking uTorrent download status.')

        if not self.connect():
            return False

        statuses = StatusList(self)

        data = self.utorrent_api.get_status()
        if not data:
            log.error('Error getting data from uTorrent')
            return False

        queue = json.loads(data)
        if queue.get('error'):
            log.error('Error getting data from uTorrent: %s', queue.get('error'))
            return False

        if not queue.get('torrents'):
            log.debug('Nothing in queue')
            return False

        # Get torrents
        for item in queue['torrents']:

            # item[21] = Paused | Downloading | Seeding | Finished
            status = 'busy'
            if 'Finished' in item[21]:
                status = 'completed'
                self.removeReadOnly(item[26])
            elif 'Seeding' in item[21]:
                status = 'seeding'
                self.removeReadOnly(item[26])

            statuses.append({
                'id': item[0],
                'name': item[2],
                'status':  status,
                'seed_ratio': float(item[7]) / 1000,
                'original_status': item[1],
                'timeleft': str(timedelta(seconds = item[10])),
                'folder': ss(item[26]),
            })

        return statuses
示例#8
0
    def getAllDownloadStatus(self):

        log.debug('Checking Transmission download status.')

        if not self.connect():
            return False

        statuses = StatusList(self)

        return_params = {
            'fields': ['id', 'name', 'hashString', 'percentDone', 'status', 'eta', 'isStalled', 'isFinished', 'downloadDir', 'uploadRatio', 'secondsSeeding', 'seedIdleLimit']
        }

        queue = self.trpc.get_alltorrents(return_params)
        if not (queue and queue.get('torrents')):
            log.debug('Nothing in queue or error')
            return False

        for item in queue['torrents']:
            log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s',
                (item['name'], item['id'], item['downloadDir'], item['hashString'], item['percentDone'], item['status'], item['eta'], item['uploadRatio'], item['isFinished']))

            if not os.path.isdir(Env.setting('from', 'renamer')):
                log.error('Renamer "from" folder doesn\'t to exist.')
                return

            status = 'busy'
            if item['isStalled'] and self.conf('stalled_as_failed'):
                status = 'failed'
            elif item['status'] == 0 and item['percentDone'] == 1:
                status = 'completed'
            elif item['status'] in [5, 6]:
                status = 'seeding'

            statuses.append({
                'id': item['hashString'],
                'name': item['name'],
                'status': status,
                'original_status': item['status'],
                'seed_ratio': item['uploadRatio'],
                'timeleft': str(timedelta(seconds = item['eta'])),
                'folder': ss(os.path.join(item['downloadDir'], item['name'])),
            })

        return statuses
示例#9
0
    def getAllDownloadStatus(self):

        log.debug('Checking Transmission download status.')

        if not self.connect():
            return False

        statuses = StatusList(self)

        return_params = {
            'fields': ['id', 'name', 'hashString', 'percentDone', 'status', 'eta', 'isStalled', 'isFinished', 'downloadDir', 'uploadRatio', 'secondsSeeding', 'seedIdleLimit']
        }

        queue = self.trpc.get_alltorrents(return_params)
        if not (queue and queue.get('torrents')):
            log.debug('Nothing in queue or error')
            return False

        for item in queue['torrents']:
            log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s',
                (item['name'], item['id'], item['downloadDir'], item['hashString'], item['percentDone'], item['status'], item['eta'], item['uploadRatio'], item['isFinished']))

            if not os.path.isdir(Env.setting('from', 'renamer')):
                log.error('Renamer "from" folder doesn\'t to exist.')
                return

            status = 'busy'
            if item['isStalled'] and self.conf('stalled_as_failed'):
                status = 'failed'
            elif item['status'] == 0 and item['percentDone'] == 1:
                status = 'completed'
            elif item['status'] in [5, 6]:
                status = 'seeding'

            statuses.append({
                'id': item['hashString'],
                'name': item['name'],
                'status': status,
                'original_status': item['status'],
                'seed_ratio': item['uploadRatio'],
                'timeleft': str(timedelta(seconds = item['eta'])),
                'folder': ss(os.path.join(item['downloadDir'], item['name'])),
            })

        return statuses
示例#10
0
    def getAllDownloadStatus(self):

        raw_statuses = self.call('nzb')

        statuses = StatusList(self)
        for item in raw_statuses.get('nzbs', []):

            # Check status
            status = 'busy'
            if item['state'] == 20:
                status = 'completed'
            elif item['state'] in [21, 22, 24]:
                status = 'failed'

            statuses.append({
                'id': item['id'],
                'name': item['uiTitle'],
                'status': status,
                'original_status': item['state'],
                'timeleft':-1,
            })

        return statuses
示例#11
0
    def getAllDownloadStatus(self):

        raw_statuses = self.call('nzb')

        statuses = StatusList(self)
        for item in raw_statuses.get('nzbs', []):

            # Check status
            status = 'busy'
            if item['state'] == 20:
                status = 'completed'
            elif item['state'] in [21, 22, 24]:
                status = 'failed'

            statuses.append({
                'id': item['id'],
                'name': item['uiTitle'],
                'status': status,
                'original_status': item['state'],
                'timeleft': -1,
                'folder': ss(item['destinationPath']),
            })

        return statuses
示例#12
0
        except:
            log.error('Failed getting data: %s', traceback.format_exc(1))
            return False

        statuses = StatusList(self)

        for item in groups:
            log.debug('Found %s in NZBGet download queue', item['NZBFilename'])
            try:
                nzb_id = [param['Value'] for param in item['Parameters'] if param['Name'] == 'couchpotato'][0]
            except:
                nzb_id = item['NZBID']
            statuses.append({
                'id': nzb_id,
                'name': item['NZBFilename'],
                'original_status': 'DOWNLOADING' if item['ActiveDownloads'] > 0 else 'QUEUED',
                # Seems to have no native API function for time left. This will return the time left after NZBGet started downloading this item
                'timeleft': str(timedelta(seconds = item['RemainingSizeMB'] / status['DownloadRate'] * 2 ^ 20)) if item['ActiveDownloads'] > 0 and not (status['DownloadPaused'] or status['Download2Paused']) else -1,
            })

        for item in queue: # 'Parameters' is not passed in rpc.postqueue
            log.debug('Found %s in NZBGet postprocessing queue', item['NZBFilename'])
            statuses.append({
                'id': item['NZBID'],
                'name': item['NZBFilename'],
                'original_status': item['Stage'],
                'timeleft': str(timedelta(seconds = 0)) if not status['PostPaused'] else -1,
            })

        for item in history:
            log.debug('Found %s in NZBGet history. ParStatus: %s, ScriptStatus: %s, Log: %s', (item['NZBFilename'] , item['ParStatus'], item['ScriptStatus'] , item['Log']))
示例#13
0
        for item in queue.get('torrents', []):

            # item[21] = Paused | Downloading | Seeding | Finished
            status = 'busy'
            if item[21] == 'Finished' or item[21] == 'Seeding':
                status = 'completed'

            if settings_dict['dir_add_label']:
                release_folder = os.path.join(download_folder, item[11], item[2])
            else:
                release_folder = os.path.join(download_folder, item[2])

            statuses.append({
                'id': item[0],
                'name': item[2],
                'status':  status,
                'original_status': item[1],
                'timeleft': str(timedelta(seconds = item[10])),
                'folder': release_folder, 
            })

        return statuses



class uTorrentAPI(object):

    def __init__(self, host = 'localhost', port = 8000, username = None, password = None):

        super(uTorrentAPI, self).__init__()

        self.url = 'http://' + str(host) + ':' + str(port) + '/gui/'
示例#14
0
            # item[21] = Paused | Downloading | Seeding | Finished
            status = 'busy'
            if item[21] == 'Finished' or item[21] == 'Seeding':
                status = 'completed'

            if settings_dict['dir_add_label']:
                release_folder = os.path.join(download_folder, item[11],
                                              item[2])
            else:
                release_folder = os.path.join(download_folder, item[2])

            statuses.append({
                'id': item[0],
                'name': item[2],
                'status': status,
                'original_status': item[1],
                'timeleft': str(timedelta(seconds=item[10])),
                'folder': release_folder,
            })

        return statuses


class uTorrentAPI(object):
    def __init__(self,
                 host='localhost',
                 port=8000,
                 username=None,
                 password=None):

        super(uTorrentAPI, self).__init__()
示例#15
0
                if item['ActiveDownloads'] > 0 and item[
                        'DownloadRate'] > 0 and not (
                            status['DownloadPaused']
                            or status['Download2Paused']):
                    timeleft = str(
                        timedelta(seconds=item['RemainingSizeMB'] /
                                  status['DownloadRate'] * 2 ^ 20))
            except:
                pass

            statuses.append({
                'id':
                nzb_id,
                'name':
                item['NZBFilename'],
                'original_status':
                'DOWNLOADING' if item['ActiveDownloads'] > 0 else 'QUEUED',
                # 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 item in queue:  # 'Parameters' is not passed in rpc.postqueue
            log.debug('Found %s in NZBGet postprocessing queue',
                      item['NZBFilename'])
            statuses.append({
                'id':
                item['NZBID'],
                'name':
                item['NZBFilename'],
                'original_status':
示例#16
0
            timeleft = -1
            try:
                if (
                    item["ActiveDownloads"] > 0
                    and item["DownloadRate"] > 0
                    and not (status["DownloadPaused"] or status["Download2Paused"])
                ):
                    timeleft = str(timedelta(seconds=item["RemainingSizeMB"] / status["DownloadRate"] * 2 ^ 20))
            except:
                pass

            statuses.append(
                {
                    "id": nzb_id,
                    "name": item["NZBFilename"],
                    "original_status": "DOWNLOADING" if item["ActiveDownloads"] > 0 else "QUEUED",
                    # 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 item in queue:  # 'Parameters' is not passed in rpc.postqueue
            log.debug("Found %s in NZBGet postprocessing queue", item["NZBFilename"])
            statuses.append(
                {
                    "id": item["NZBID"],
                    "name": item["NZBFilename"],
                    "original_status": item["Stage"],
                    "timeleft": str(timedelta(seconds=0)) if not status["PostPaused"] else -1,
                }
            )
示例#17
0
            # item[21] = Paused | Downloading | Seeding | Finished
            status = "busy"
            if item[21] == "Finished" or item[21] == "Seeding":
                status = "completed"

            if settings_dict["dir_add_label"]:
                release_folder = os.path.join(download_folder, item[11], item[2])
            else:
                release_folder = os.path.join(download_folder, item[2])

            statuses.append(
                {
                    "id": item[0],
                    "name": item[2],
                    "status": status,
                    "original_status": item[1],
                    "timeleft": str(timedelta(seconds=item[10])),
                    "folder": release_folder,
                }
            )

        return statuses


class uTorrentAPI(object):
    def __init__(self, host="localhost", port=8000, username=None, password=None):

        super(uTorrentAPI, self).__init__()

        self.url = "http://" + str(host) + ":" + str(port) + "/gui/"
        self.token = ""
示例#18
0
    def getAllDownloadStatus(self):

        log.debug("Checking Transmission download status.")

        if not self.connect():
            return False

        statuses = StatusList(self)

        return_params = {
            "fields": [
                "id",
                "name",
                "hashString",
                "percentDone",
                "status",
                "eta",
                "isStalled",
                "isFinished",
                "downloadDir",
                "uploadRatio",
                "secondsSeeding",
                "seedIdleLimit",
            ]
        }

        queue = self.trpc.get_alltorrents(return_params)
        if not (queue and queue.get("torrents")):
            log.debug("Nothing in queue or error")
            return False

        for item in queue["torrents"]:
            log.debug(
                "name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s",
                (
                    item["name"],
                    item["id"],
                    item["downloadDir"],
                    item["hashString"],
                    item["percentDone"],
                    item["status"],
                    item["eta"],
                    item["uploadRatio"],
                    item["isFinished"],
                ),
            )

            if not os.path.isdir(Env.setting("from", "renamer")):
                log.error('Renamer "from" folder doesn\'t to exist.')
                return

            status = "busy"
            if item["isStalled"] and self.conf("stalled_as_failed"):
                status = "failed"
            elif item["status"] == 0 and item["percentDone"] == 1:
                status = "completed"
            elif item["status"] in [5, 6]:
                status = "seeding"

            statuses.append(
                {
                    "id": item["hashString"],
                    "name": item["name"],
                    "status": status,
                    "original_status": item["status"],
                    "seed_ratio": item["uploadRatio"],
                    "timeleft": str(timedelta(seconds=item["eta"])),
                    "folder": ss(os.path.join(item["downloadDir"], item["name"])),
                }
            )

        return statuses
示例#19
0
            return False

        statuses = StatusList(self)

        # Get torrents
        for item in queue.get('torrents', []):

            # item[21] = Paused | Downloading | Seeding | Finished
            status = 'busy'
            if item[21] == 'Finished' or item[21] == 'Seeding':
                status = 'completed'

            statuses.append({
                'id': item[0],
                'name': item[2],
                'status':  status,
                'original_status': item[1],
                'timeleft': item[10],
            })

        return statuses



class uTorrentAPI(object):

    def __init__(self, host = 'localhost', port = 8000, username = None, password = None):

        super(uTorrentAPI, self).__init__()

        self.url = 'http://' + str(host) + ':' + str(port) + '/gui/'
示例#20
0
    def getAllDownloadStatus(self):

        log.debug('Checking Deluge download status.')

        if not os.path.isdir(Env.setting('from', 'renamer')):
            log.error('Renamer "from" folder doesn\'t to exist.')
            return

        if not self.connect():
            return False

        statuses = StatusList(self)

        queue = self.drpc.get_alltorrents()

        if not queue:
            log.debug('Nothing in queue or error')
            return False

        for torrent_id in queue:
            item = 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',
                (item['name'], item['hash'], item['save_path'],
                 item['move_completed_path'], item['hash'], item['progress'],
                 item['state'], item['eta'], item['ratio'], item['stop_ratio'],
                 item['is_seed'], item['is_finished'], item['paused']))

            # Deluge has no easy way to work out if a torrent is stalled or failing.
            #status = 'failed'
            status = 'busy'
            if item['is_seed'] and tryFloat(item['ratio']) < tryFloat(
                    item['stop_ratio']):
                # We have item['seeding_time'] to work out what the seeding time is, but we do not
                # have access to the downloader seed_time, as with deluge we have no way to pass it
                # when the torrent is added. So Deluge will only look at the ratio.
                # See above comment in download().
                status = 'seeding'
            elif item['is_seed'] and item['is_finished'] and item[
                    'paused'] and item['state'] == 'Paused':
                status = 'completed'

            download_dir = item['save_path']
            if item['move_on_completed']:
                download_dir = item['move_completed_path']

            statuses.append({
                'id':
                item['hash'],
                'name':
                item['name'],
                'status':
                status,
                'original_status':
                item['state'],
                'seed_ratio':
                item['ratio'],
                'timeleft':
                str(timedelta(seconds=item['eta'])),
                'folder':
                ss(os.path.join(download_dir, item['name'])),
            })

        return statuses
示例#21
0
                nzb_id = [param['Value'] for param in item['Parameters'] if param['Name'] == 'couchpotato'][0]
            except:
                nzb_id = item['NZBID']


            timeleft = -1
            try:
                if item['ActiveDownloads'] > 0 and item['DownloadRate'] > 0 and not (status['DownloadPaused'] or status['Download2Paused']):
                    timeleft = str(timedelta(seconds = item['RemainingSizeMB'] / status['DownloadRate'] * 2 ^ 20))
            except:
                pass

            statuses.append({
                'id': nzb_id,
                'name': item['NZBFilename'],
                'original_status': 'DOWNLOADING' if item['ActiveDownloads'] > 0 else 'QUEUED',
                # 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 item in queue: # 'Parameters' is not passed in rpc.postqueue
            log.debug('Found %s in NZBGet postprocessing queue', item['NZBFilename'])
            statuses.append({
                'id': item['NZBID'],
                'name': item['NZBFilename'],
                'original_status': item['Stage'],
                'timeleft': str(timedelta(seconds = 0)) if not status['PostPaused'] else -1,
            })

        for item in history:
            log.debug('Found %s in NZBGet history. ParStatus: %s, ScriptStatus: %s, Log: %s', (item['NZBFilename'] , item['ParStatus'], item['ScriptStatus'] , item['Log']))