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))
评论列表
文章目录