platypush/plugins/rtorrent/__init__.py
def status(self, torrent: str = None) -> dict:
        """
        Get the status of the current transfers.

        :param torrent: Torrent hash.
        :returns: A dictionary:

          .. code-block:: json

            {
              "HASH1234567890": {
                "hash": "HASH1234567890",
                "name": "Your torrent name",
                "save_path": "/home/user/Downloads/Your torrent name",
                "is_active": true,
                "is_open": true,
                "completed_bytes": 666894336,
                "download_rate": 451345,
                "is_multi_file": true,
                "remaining_bytes": 1482827011,
                "size_bytes": 2149721347,
                "load_date": "2020-09-02T18:42:19",
                "peers": 0,
                "state": "paused",
                "start_date": "2020-09-02T18:42:19",
                "finish_date": null,
                "upload_rate": 143967,
                "progress": 31.0,
                "files": ["list", "of", "downloaded", "files"]
              }
            }

        """
        attrs = ['hash', 'name', 'save_path', 'is_active', 'is_open', 'completed_bytes', 'download_rate',
                 'is_multi_file', 'remaining_bytes', 'size_bytes', 'load_date', 'peers', 'start_date',
                 'finish_date', 'upload_rate']
        cmds = ['d.hash=', 'd.name=', 'd.directory=', 'd.is_active=', 'd.is_open=', 'd.completed_bytes=',
                'd.down.rate=', 'd.is_multi_file=', 'd.left_bytes=', 'd.size_bytes=', 'd.load_date=',
                'd.peers_connected=', 'd.timestamp.started=', 'd.timestamp.finished=', 'd.up.rate=']

        mappers = {
            'is_active': lambda v: bool(v),
            'is_open': lambda v: bool(v),
            'is_multi_file': lambda v: bool(v),
            'load_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
            'start_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
            'finish_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
        }

        with self._status_lock:
            torrents = {
                info[0]: {
                    attr: mappers[attr](info[i]) if attr in mappers else info[i]
                    for i, attr in enumerate(attrs)
                }
                for info in self._multicall('', *cmds)
            }

        for torrent_id, info in torrents.items():
            torrents[torrent_id]['progress'] = round(100. * (info['completed_bytes']/info['size_bytes']), 1)
            torrents[torrent_id]['url'] = self._torrent_urls.get(torrent_id, torrent_id)
            torrents[torrent_id]['is_paused'] = not info['is_active']
            torrents[torrent_id]['paused'] = not info['is_active']  # Back compatibility with TorrentPlugin
            torrents[torrent_id]['size'] = info['size_bytes']  # Back compatibility with TorrentPlugin
            torrents[torrent_id]['files'] = []

            if not info['is_open']:
                torrents[torrent_id]['state'] = 'stopped'
            elif not info['is_active']:
                torrents[torrent_id]['state'] = 'paused'
            else:
                torrents[torrent_id]['state'] = 'downloading'

            if info.get('save_path'):
                torrents[torrent_id]['files'] = list(str(f) for f in Path(info['save_path']).rglob('*')) \
                    if info.get('is_multi_file') else info['save_path']

        return torrents.get(torrent, {}) if torrent else torrents

        Get the status of the current transfers.

        :param torrent: Torrent hash.
        :returns: A dictionary:

          .. code-block:: json

            {
              "HASH1234567890": {
                "hash": "HASH1234567890",
                "name": "Your torrent name",
                "save_path": "/home/user/Downloads/Your torrent name",
                "is_active": true,
                "is_open": true,
                "completed_bytes": 666894336,
                "download_rate": 451345,
                "is_multi_file": true,
                "remaining_bytes": 1482827011,
                "size_bytes": 2149721347,
                "load_date": "2020-09-02T18:42:19",
                "peers": 0,
                "state": "paused",
                "start_date": "2020-09-02T18:42:19",
                "finish_date": null,
                "upload_rate": 143967,
                "progress": 31.0,
                "files": ["list", "of", "downloaded", "files"]
              }
            }

        
Get the status of the current transfers.
Get the status of the current transfers .
def status(self, torrent: str = None) -> dict:
        attrs = ['hash', 'name', 'save_path', 'is_active', 'is_open', 'completed_bytes', 'download_rate',
                 'is_multi_file', 'remaining_bytes', 'size_bytes', 'load_date', 'peers', 'start_date',
                 'finish_date', 'upload_rate']
        cmds = ['d.hash=', 'd.name=', 'd.directory=', 'd.is_active=', 'd.is_open=', 'd.completed_bytes=',
                'd.down.rate=', 'd.is_multi_file=', 'd.left_bytes=', 'd.size_bytes=', 'd.load_date=',
                'd.peers_connected=', 'd.timestamp.started=', 'd.timestamp.finished=', 'd.up.rate=']
        mappers = {
            'is_active': lambda v: bool(v),
            'is_open': lambda v: bool(v),
            'is_multi_file': lambda v: bool(v),
            'load_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
            'start_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
            'finish_date': lambda v: datetime.datetime.fromtimestamp(v) if v else None,
        }
        with self._status_lock:
            torrents = {
                info[0]: {
                    attr: mappers[attr](info[i]) if attr in mappers else info[i]
                    for i, attr in enumerate(attrs)
                }
                for info in self._multicall('', *cmds)
            }
        for torrent_id, info in torrents.items():
            torrents[torrent_id]['progress'] = round(100. * (info['completed_bytes']/info['size_bytes']), 1)
            torrents[torrent_id]['url'] = self._torrent_urls.get(torrent_id, torrent_id)
            torrents[torrent_id]['is_paused'] = not info['is_active']
            torrents[torrent_id]['paused'] = not info['is_active']  
            torrents[torrent_id]['size'] = info['size_bytes']  
            torrents[torrent_id]['files'] = []
            if not info['is_open']:
                torrents[torrent_id]['state'] = 'stopped'
            elif not info['is_active']:
                torrents[torrent_id]['state'] = 'paused'
            else:
                torrents[torrent_id]['state'] = 'downloading'
            if info.get('save_path'):
                torrents[torrent_id]['files'] = list(str(f) for f in Path(info['save_path']).rglob('*')) \
                    if info.get('is_multi_file') else info['save_path']
        return torrents.get(torrent, {}) if torrent else torrents
def status ( self , torrent : str = None ) -> dict : attrs = [ 'hash' , 'name' , 'save_path' , 'is_active' , 'is_open' , 'completed_bytes' , 'download_rate' , 'is_multi_file' , 'remaining_bytes' , 'size_bytes' , 'load_date' , 'peers' , 'start_date' , 'finish_date' , 'upload_rate' ] cmds = [ 'd.hash=' , 'd.name=' , 'd.directory=' , 'd.is_active=' , 'd.is_open=' , 'd.completed_bytes=' , 'd.down.rate=' , 'd.is_multi_file=' , 'd.left_bytes=' , 'd.size_bytes=' , 'd.load_date=' , 'd.peers_connected=' , 'd.timestamp.started=' , 'd.timestamp.finished=' , 'd.up.rate=' ] mappers = { 'is_active' : lambda v : bool ( v ) , 'is_open' : lambda v : bool ( v ) , 'is_multi_file' : lambda v : bool ( v ) , 'load_date' : lambda v : datetime . datetime . fromtimestamp ( v ) if v else None , 'start_date' : lambda v : datetime . datetime . fromtimestamp ( v ) if v else None , 'finish_date' : lambda v : datetime . datetime . fromtimestamp ( v ) if v else None , } with self . _status_lock : torrents = { info [ 0 ] : { attr : mappers [ attr ] ( info [ i ] ) if attr in mappers else info [ i ] for i , attr in enumerate ( attrs ) } for info in self . _multicall ( '' , * cmds ) } for torrent_id , info in torrents . items ( ) : torrents [ torrent_id ] [ 'progress' ] = round ( 100. * ( info [ 'completed_bytes' ] / info [ 'size_bytes' ] ) , 1 ) torrents [ torrent_id ] [ 'url' ] = self . _torrent_urls . get ( torrent_id , torrent_id ) torrents [ torrent_id ] [ 'is_paused' ] = not info [ 'is_active' ] torrents [ torrent_id ] [ 'paused' ] = not info [ 'is_active' ] torrents [ torrent_id ] [ 'size' ] = info [ 'size_bytes' ] torrents [ torrent_id ] [ 'files' ] = [ ] if not info [ 'is_open' ] : torrents [ torrent_id ] [ 'state' ] = 'stopped' elif not info [ 'is_active' ] : torrents [ torrent_id ] [ 'state' ] = 'paused' else : torrents [ torrent_id ] [ 'state' ] = 'downloading' if info . get ( 'save_path' ) : torrents [ torrent_id ] [ 'files' ] = list ( str ( f ) for f in Path ( info [ 'save_path' ] ) . rglob ( '*' ) ) if info . get ( 'is_multi_file' ) else info [ 'save_path' ] return torrents . get ( torrent , { } ) if torrent else torrents
Get the status of the current transfers.
Get the status of the current transfers .
"""
        Get the status of the current transfers.

        :param torrent: Torrent hash.
        :returns: A dictionary:

          .. code-block:: json

            {
              "HASH1234567890": {
                "hash": "HASH1234567890",
                "name": "Your torrent name",
                "save_path": "/home/user/Downloads/Your torrent name",
                "is_active": true,
                "is_open": true,
                "completed_bytes": 666894336,
                "download_rate": 451345,
                "is_multi_file": true,
                "remaining_bytes": 1482827011,
                "size_bytes": 2149721347,
                "load_date": "2020-09-02T18:42:19",
                "peers": 0,
                "state": "paused",
                "start_date": "2020-09-02T18:42:19",
                "finish_date": null,
                "upload_rate": 143967,
                "progress": 31.0,
                "files": ["list", "of", "downloaded", "files"]
              }
            }

        """ # Back compatibility with TorrentPlugin # Back compatibility with TorrentPlugin
A dictionary:
code-block:: json


A dictionary : code - block :: json
self
torrent
str
None