Beispiel #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
    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
    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
    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
Beispiel #5
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
Beispiel #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
Beispiel #7
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
    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
Beispiel #9
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
Beispiel #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
Beispiel #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
Beispiel #12
0
class Transmission(Downloader):

    type = ['torrent', 'torrent_magnet']
    log = CPLog(__name__)

    def download(self, data, movie, filedata = None):

        log.info('Sending "%s" (%s) to Transmission.', (data.get('name'), data.get('type')))

        # Load host from config and split out port.
        host = self.conf('host').split(':')
        if not isInt(host[1]):
            log.error('Config properties are not filled in correctly, port is missing.')
            return False

        # Set parameters for Transmission
        params = {
            'paused': self.conf('paused', default = 0),
        }

        if len(self.conf('directory', default = '')) > 0:
            folder_name = self.createFileName(data, filedata, movie)[:-len(data.get('type')) - 1]
            folder_path = os.path.join(self.conf('directory', default = ''), folder_name).rstrip(os.path.sep)

            # Create the empty folder to download too
            self.makeDir(folder_path)

            params['download-dir'] = folder_path

        torrent_params = {}
        if self.conf('ratio'):
            torrent_params = {
                'seedRatioLimit': self.conf('ratio'),
                'seedRatioMode': self.conf('ratiomode')
            }

        if not filedata and data.get('type') == 'torrent':
            log.error('Failed sending torrent, no data')
            return False

        # Send request to Transmission
        try:
            trpc = TransmissionRPC(host[0], port = host[1], username = self.conf('username'), password = self.conf('password'))
            if data.get('type') == 'torrent_magnet':
                remote_torrent = trpc.add_torrent_uri(data.get('url'), arguments = params)
                torrent_params['trackerAdd'] = self.torrent_trackers
            else:
                remote_torrent = trpc.add_torrent_file(b64encode(filedata), arguments = params)

            if not remote_torrent:
                return False

            # Change settings of added torrents
            elif torrent_params:
                trpc.set_torrent(remote_torrent['torrent-added']['hashString'], torrent_params)

            log.info('Torrent sent to Transmission successfully.')
            return self.downloadReturnId(remote_torrent['torrent-added']['hashString'])
        except:
            log.error('Failed to change settings for transfer: %s', traceback.format_exc())
            return False

    def getAllDownloadStatus(self):

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

        # Load host from config and split out port.
        host = self.conf('host').split(':')
        if not isInt(host[1]):
            log.error('Config properties are not filled in correctly, port is missing.')
            return False

        # Go through Queue
        try:
            trpc = TransmissionRPC(host[0], port = host[1], username = self.conf('username'), password = self.conf('password'))
            return_params = {
                'fields': ['id', 'name', 'hashString', 'percentDone', 'status', 'eta', 'isFinished', 'downloadDir', 'uploadRatio']
            }
            queue = trpc.get_alltorrents(return_params)

        except Exception, err:
            log.error('Failed getting queue: %s', err)
            return False

        statuses = StatusList(self)

        # Get torrents status
            # CouchPotato Status
                #status = 'busy'
                #status = 'failed'
                #status = 'completed'
            # Transmission Status
                #status = 0 => "Torrent is stopped"
                #status = 1 => "Queued to check files"
                #status = 2 => "Checking files"
                #status = 3 => "Queued to download"
                #status = 4 => "Downloading"
                #status = 4 => "Queued to seed"
                #status = 6 => "Seeding"
        #To do :
        #   add checking file
        #   manage no peer in a range time => fail

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

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

            if (item['percentDone'] * 100) >= 100 and (item['status'] == 6 or item['status'] == 0) and item['uploadRatio'] > self.conf('ratio'):
                try:
                    trpc.stop_torrent(item['hashString'], {})
                    statuses.append({
                        'id': item['hashString'],
                        'name': item['name'],
                        'status': 'completed',
                        'original_status': item['status'],
                        'timeleft': str(timedelta(seconds = 0)),
                        'folder': os.path.join(item['downloadDir'], item['name']),
                    })
                except Exception, err:
                    log.error('Failed to stop and remove torrent "%s" with error: %s', (item['name'], err))
                    statuses.append({
                        'id': item['hashString'],
                        'name': item['name'],
                        'status': 'failed',
                        'original_status': item['status'],
                        'timeleft': str(timedelta(seconds = 0)),
                    })
            else:
                statuses.append({
                    'id': item['hashString'],
                    'name': item['name'],
                    'status': 'busy',
                    'original_status': item['status'],
                    'timeleft': str(timedelta(seconds = item['eta'])), # Is ETA in seconds??
                })
Beispiel #13
0
        try:
            data = self.utorrent_api.get_status()
            queue = json.loads(data)
            if queue.get('error'):
                log.error('Error getting data from uTorrent: %s', queue.get('error'))
                return False

        except Exception, err:
            log.error('Failed to get status from uTorrent: %s', err)
            return False

        if queue.get('torrents', []) == []:
            log.debug('Nothing in queue')
            return False

        statuses = StatusList(self)
        download_folder = ''
        settings_dict = {}

        try:
            data = self.utorrent_api.get_settings()
            utorrent_settings = json.loads(data)

            # Create settings dict
            for item in utorrent_settings['settings']:
                if item[1] == 0: # int
                    settings_dict[item[0]] = int(item[2] if not item[2].strip() == '' else '0')
                elif item[1] == 1: # bool
                    settings_dict[item[0]] = True if item[2] == 'true' else False
                elif item[1] == 2: # string
                    settings_dict[item[0]] = item[2]
Beispiel #14
0
            data = self.utorrent_api.get_status()
            queue = json.loads(data)
            if queue.get('error'):
                log.error('Error getting data from uTorrent: %s',
                          queue.get('error'))
                return False

        except Exception, err:
            log.error('Failed to get status from uTorrent: %s', err)
            return False

        if queue.get('torrents', []) == []:
            log.debug('Nothing in queue')
            return False

        statuses = StatusList(self)
        download_folder = ''
        settings_dict = {}

        try:
            data = self.utorrent_api.get_settings()
            utorrent_settings = json.loads(data)

            # Create settings dict
            for item in utorrent_settings['settings']:
                if item[1] == 0:  # int
                    settings_dict[item[0]] = int(
                        item[2] if not item[2].strip() == '' else '0')
                elif item[1] == 1:  # bool
                    settings_dict[
                        item[0]] = True if item[2] == 'true' else False
Beispiel #15
0
                log.error("Password is incorrect.")
            else:
                log.error("Protocol Error: %s", e)
            return False

        # Get NZBGet data
        try:
            status = rpc.status()
            groups = rpc.listgroups()
            queue = rpc.postqueue(0)
            history = rpc.history()
        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"]

            timeleft = -1
            try:
                if (
                    item["ActiveDownloads"] > 0
                    and item["DownloadRate"] > 0
                    and not (status["DownloadPaused"] or status["Download2Paused"])
                ):
Beispiel #16
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
Beispiel #17
0
        try:
            data = self.utorrent_api.get_status()
            queue = json.loads(data)
            if queue.get('error'):
                log.error('Error getting data from uTorrent: %s', queue.get('error'))
                return False

        except Exception, err:
            log.error('Failed to get status from uTorrent: %s', err)
            return False

        if queue.get('torrents', []) == []:
            log.debug('Nothing in queue')
            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],
Beispiel #18
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
Beispiel #19
0
                log.error('Password is incorrect.')
            else:
                log.error('Protocol Error: %s', e)
            return False

        # Get NZBGet data
        try:
            status = rpc.status()
            groups = rpc.listgroups()
            queue = rpc.postqueue(0)
            history = rpc.history()
        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,
            })
Beispiel #20
0
                log.error('Password is incorrect.')
            else:
                log.error('Protocol Error: %s', e)
            return False

        # Get NZBGet data
        try:
            status = rpc.status()
            groups = rpc.listgroups()
            queue = rpc.postqueue(0)
            history = rpc.history()
        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']

            timeleft = -1
            try:
                if item['ActiveDownloads'] > 0 and item[
                        'DownloadRate'] > 0 and not (
Beispiel #21
0
        try:
            data = self.utorrent_api.get_status()
            queue = json.loads(data)
            if queue.get("error"):
                log.error("Error getting data from uTorrent: %s", queue.get("error"))
                return False

        except Exception, err:
            log.error("Failed to get status from uTorrent: %s", err)
            return False

        if queue.get("torrents", []) == []:
            log.debug("Nothing in queue")
            return False

        statuses = StatusList(self)
        download_folder = ""
        settings_dict = {}

        try:
            data = self.utorrent_api.get_settings()
            utorrent_settings = json.loads(data)

            # Create settings dict
            for item in utorrent_settings["settings"]:
                if item[1] == 0:  # int
                    settings_dict[item[0]] = int(item[2] if not item[2].strip() == "" else "0")
                elif item[1] == 1:  # bool
                    settings_dict[item[0]] = True if item[2] == "true" else False
                elif item[1] == 2:  # string
                    settings_dict[item[0]] = item[2]
Beispiel #22
0
                log.error('Password is incorrect.')
            else:
                log.error('Protocol Error: %s', e)
            return False

        # Get NZBGet data
        try:
            status = rpc.status()
            groups = rpc.listgroups()
            queue = rpc.postqueue(0)
            history = rpc.history()
        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']


            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