コード例 #1
0
    def get_status(self, info_hash):
        """
        Return torrent status.

        Example result:
        ```
            'hash': '35b814f1438054158b0bd07d305dc0edeb20b704'
            'is_finished': False
            'ratio': 0.0
            'paused': False
            'name': '[FFA] Haikyuu!!: To the Top 2nd Season - 11 [1080p][HEVC][Multiple Subtitle].mkv'
            'stop_ratio': 2.0
            'state': 'Downloading'
            'progress': 23.362499237060547
            'files': ({'index': 0, 'offset': 0, 'path': '[FFA] Haikyuu!!: To ...title].mkv', 'size': 362955692},)
            'is_seed': False
        ```
        """
        if not self.connect():
            log.warning('Error while fetching torrents status')
            return

        torrent = self.drpc._torrent_properties(info_hash)
        if not torrent:
            return False

        client_status = ClientStatus()
        if torrent['state'] == 'Downloading':
            client_status.add_status_string('Downloading')

        if torrent['paused']:
            client_status.add_status_string('Paused')

        # TODO: Find out which state the torrent get's when it fails.
        # if torrent[1] & 16:
        #     client_status.add_status_string('Failed')

        if torrent['is_finished']:
            client_status.add_status_string('Completed')

        if torrent['ratio'] >= torrent['stop_ratio']:
            client_status.add_status_string('Seeded')

        # Store ratio
        client_status.ratio = torrent['ratio']

        # Store progress
        client_status.progress = int(torrent['progress'])

        # Store destination
        client_status.destination = torrent['download_location']

        # Store resource
        client_status.resource = torrent['name']

        return client_status
コード例 #2
0
ファイル: qbittorrent.py プロジェクト: MatyasK/Medusa
    def get_status(self, info_hash):
        """Return torrent status."""
        # Set up the auth. We need it in the following methods.
        if time.time() > self.last_time + 1800 or not self.auth:
            self.last_time = time.time()
            self._get_auth()

        if not self.auth:
            return

        torrent = self._torrent_properties(info_hash)
        if not torrent:
            return

        client_status = ClientStatus()
        if torrent['state'] in ('downloading', 'checkingDL', 'forcedDL',
                                'metaDL', 'queuedDL'):
            client_status.set_status_string('Downloading')

        # Might want to separate these into a PausedDl and PausedUl in future.
        if torrent['state'] in ('pausedDL', 'stalledDL'):
            client_status.set_status_string('Paused')

        if torrent['state'] == 'error':
            client_status.set_status_string('Failed')

        if torrent['state'] in ('uploading', 'queuedUP', 'checkingUP',
                                'forcedUP', 'stalledUP', 'pausedUP'):
            client_status.set_status_string('Completed')

        # if torrent['ratio'] >= torrent['max_ratio']:
        #     client_status.set_status_string('Seeded')

        # Store ratio
        client_status.ratio = torrent['ratio'] * 1.0

        # Store progress
        client_status.progress = int(torrent['downloaded'] / torrent['size'] *
                                     100)

        # Store destination
        client_status.destination = torrent['save_path']

        # Store resource
        client_status.resource = torrent['name']

        log.info('Qbittorrent torrent: [{name}] using state: [{state}]', {
            'name': torrent['name'],
            'state': torrent['state']
        })

        return client_status
コード例 #3
0
def get_status(nzo_id):
    """
    Return nzb status (Paused, Downloading, Downloaded, Failed, Extracting).

    :return: ClientStatus object.
    """
    from medusa.schedulers.download_handler import ClientStatus

    nzb = get_nzb_by_id(nzo_id)
    status = None
    if not nzb:
        return False

    client_status = ClientStatus()
    # Map status to a standard ClientStatus.
    if '/' in nzb['Status']:
        status, _ = nzb['Status'].split('/')
    else:
        status = nzb['Status']

    # Queue status checks (Queued is not recorded as status)
    if status == 'DOWNLOADING':
        client_status.set_status_string('Downloading')

    if status == 'PAUSED':
        client_status.set_status_string('Paused')

    if status == 'UNPACKING':
        client_status.set_status_string('Extracting')

    # History status checks.
    if status == 'DELETED':  # Mostly because of duplicate checks.
        client_status.set_status_string('Aborted')

    if status == 'SUCCESS':
        client_status.set_status_string('Completed')

    if status == 'FAILURE':
        client_status.set_status_string('Failed')

    # Get Progress
    if status == 'SUCCESS':
        client_status.progress = 100
    elif nzb.get('percentage'):
        client_status.progress = int(nzb['percentage'])

    client_status.destination = nzb.get('DestDir', '')

    client_status.resource = nzb.get('NZBFilename')

    return client_status
コード例 #4
0
ファイル: sab.py プロジェクト: k0mmsussert0d/Medusa
def get_status(nzo_id):
    """
    Return nzb status (Paused, Downloading, Downloaded, Failed, Completed).

    :return: ClientStatus object.
    """
    from medusa.schedulers.download_handler import ClientStatus

    nzb = get_nzb_by_id(nzo_id)
    if not nzb:
        return False

    client_status = ClientStatus()

    if nzb['status'] in ('Paused', 'Downloading', 'Downloaded', 'Failed',
                         'Extracting', 'Completed'):
        client_status.set_status_string(nzb['status'])
    else:
        client_status.set_status_string('Downloading')

    # Get Progress
    if nzb['status'] == 'Completed':
        client_status.progress = 100
    elif nzb.get('percentage'):
        client_status.progress = int(nzb['percentage'])

    # Store destination
    storage = nzb.get('storage', '')
    if storage:
        if basename(storage) == nzb.get('name'):
            client_status.destination = storage
            client_status.resource = nzb.get('nzb_name')
        else:
            client_status.destination = dirname(storage)
            client_status.resource = basename(storage)

    return client_status
コード例 #5
0
ファイル: transmission.py プロジェクト: k0mmsussert0d/Medusa
    def get_status(self, info_hash):
        """
        Return torrent status.

        Status codes:
        ```
            0: "Stopped"
            1: "Check waiting"
            2: "Checking"
            3: "Download waiting"
            4: "Downloading"
            5: "Seed waiting"
            6: "Seeding"
        ```
        """
        torrent = self._torrent_properties(info_hash)
        if not torrent:
            return

        client_status = ClientStatus()
        if torrent['status'] == 4:
            client_status.set_status_string('Downloading')

        if torrent['status'] == 0:
            client_status.set_status_string('Paused')

        # if torrent['status'] == ?:
        #     client_status.set_status_string('Failed')

        if torrent['status'] == 6:
            client_status.set_status_string('Completed')

        if torrent['status'] == 0 and torrent['isFinished']:
            client_status.set_status_string('Seeded')

        # Store ratio
        client_status.ratio = torrent['uploadRatio'] * 1.0

        # Store progress
        client_status.progress = int(torrent['percentDone'] * 100)

        # Store destination
        client_status.destination = torrent['downloadDir']

        # Store resource
        client_status.resource = torrent['name']

        return client_status
コード例 #6
0
    def get_status(self, info_hash):
        """
        Return torrent status.

        Status field returns a bitwize value.
        1 = Started
        2 = Checking
        4 = Start after check
        8 = Checked
        16 = Error
        32 = Paused
        64 = Queued
        128 = Loaded
        """
        torrent = self._torrent_properties(info_hash)
        if not torrent:
            return

        client_status = ClientStatus()
        if torrent[1] & 1:
            client_status.set_status_string('Downloading')

        if torrent[1] & 32:
            client_status.set_status_string('Paused')

        if torrent[1] & 16:
            client_status.set_status_string('Failed')

        if torrent[1] & 1 and torrent[4] == 1000:
            client_status.set_status_string('Completed')

        if torrent[1] == 152:  # Checked + Error + Loaded
            # Probably torrent removed.
            client_status.set_status_string('Aborted')

        # Store ratio
        client_status.ratio = torrent[7] / 1000

        # Store progress
        client_status.progress = int(torrent[4] / 10)

        # Store destination
        client_status.destination = torrent[26]

        # Store resource
        client_status.resource = torrent[2]

        return client_status
コード例 #7
0
    def get_status(self, info_hash):
        """Return torrent status."""
        torrent = self._torrent_properties(info_hash)
        if not torrent:
            return

        client_status = ClientStatus()
        if torrent['state'] in ('downloading', 'checkingDL', 'forcedDL',
                                'metaDL', 'queuedDL'):
            client_status.set_status_string('Downloading')

        # Might want to separate these into a PausedDl and PausedUl in future.
        if torrent['state'] in ('pausedDL', 'stalledDL'):
            client_status.set_status_string('Paused')

        if torrent['state'] == 'error':
            client_status.set_status_string('Failed')

        if torrent['state'] in ('uploading', 'queuedUP', 'checkingUP',
                                'forcedUP', 'stalledUP', 'pausedUP'):
            client_status.set_status_string('Completed')

        # if torrent['ratio'] >= torrent['max_ratio']:
        #     client_status.set_status_string('Seeded')

        # Store ratio
        client_status.ratio = torrent['ratio'] * 1.0

        # Store progress
        client_status.progress = int(torrent['downloaded'] / torrent['size'] *
                                     100) if torrent['size'] else 0

        # Store destination
        client_status.destination = torrent['save_path']

        if torrent.get('content_path'):
            # Store resource
            client_status.resource = basename(torrent['content_path'])

        log.info('Qbittorrent torrent: [{name}] using state: [{state}]', {
            'name': client_status.resource,
            'state': torrent['state']
        })

        return client_status
コード例 #8
0
    def get_status(self, info_hash):
        """
        Return torrent status.

        Status codes:
        ```
            complete: 'Completed download'
            is_finished: 'Finished seeding (ratio reeched)'

        ```
        """
        torrent = self._torrent_properties(info_hash)
        if not torrent:
            return

        client_status = ClientStatus()
        if torrent.started:
            client_status.set_status_string('Downloading')

        if torrent.paused:
            client_status.set_status_string('Paused')

        # # if torrent['status'] == ?:
        # #     client_status.set_status_string('Failed')

        if torrent.complete:
            client_status.set_status_string('Completed')

        # Store ratio
        client_status.ratio = torrent.ratio

        # Store progress
        if torrent.bytes_done:
            client_status.progress = int(torrent.completed_bytes /
                                         torrent.bytes_done * 100)

        # Store destination
        client_status.destination = torrent.directory

        # Store resource
        client_status.resource = torrent.base_filename

        return client_status