api_torrent.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:stig 作者: rndusr 项目源码 文件源码
def torrents(self, torrents=None, keys='ALL', autoconnect=True):
        """Fetch and return torrents

        torrents: Iterator of torrent IDs, TorrentFilter object (or its string
                  representation) or None for all torrents
        keys: tuple of Torrent keys to fetch or 'ALL' for all torrents
        autoconnect: Wether to attempt to connect automatically if not
                     connected; if False and not connected, return None

        Return Response with the following properties:
            torrents: tuple of Torrent objects with requested torrents
            success: False if no torrents were found, True otherwise
            msgs: list of strings/`ClientError`s caused by the request
        """
        if not autoconnect and not self.rpc.connected:
            return None
        elif torrents is None:
            return await self._get_torrents_by_ids(keys)
        elif isinstance(torrents, (str, TorrentFilter)):
            return await self._get_torrents_by_filter(keys, tfilter=torrents)
        elif isinstance(torrents, abc.Sequence) and \
             all(isinstance(id, int) for id in torrents):
            return await self._get_torrents_by_ids(keys, ids=torrents)
        else:
            raise ValueError("Invalid 'torrents' argument: {!r}".format(torrents))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号