MCPcopy Index your code
hub / github.com/praw-dev/praw / info

Method info

praw/models/helpers.py:284–324  ·  view source on GitHub ↗

Fetch information about each live thread in ``ids``. :param ids: A list of IDs for a live thread. :returns: A generator that yields :class:`.LiveThread` instances. :raises: ``prawcore.ServerError`` if invalid live threads are requested. Requests will be issued in

(self, ids: list[str])

Source from the content-addressed store, hash-verified

282 )
283
284 def info(self, ids: list[str]) -> Iterator[models.LiveThread]:
285 """Fetch information about each live thread in ``ids``.
286
287 :param ids: A list of IDs for a live thread.
288
289 :returns: A generator that yields :class:`.LiveThread` instances.
290
291 :raises: ``prawcore.ServerError`` if invalid live threads are requested.
292
293 Requests will be issued in batches for each 100 IDs.
294
295 .. note::
296
297 This method doesn't support IDs for live updates.
298
299 .. warning::
300
301 Unlike :meth:`.Reddit.info`, the output of this method may not reflect the
302 order of input.
303
304 Usage:
305
306 .. code-block:: python
307
308 ids = ["3rgnbke2rai6hen7ciytwcxadi", "sw7bubeycai6hey4ciytwamw3a", "t8jnufucss07"]
309 for thread in reddit.live.info(ids):
310 print(thread.title)
311
312 """
313 if not isinstance(ids, list):
314 msg = "ids must be a list"
315 raise TypeError(msg)
316
317 def generator() -> Iterator[models.LiveThread]:
318 for position in range(0, len(ids), 100):
319 ids_chunk = ids[position : position + 100]
320 url = API_PATH["live_info"].format(ids=",".join(ids_chunk))
321 params: dict[str, str | int] = {"limit": 100} # 25 is used if not specified
322 yield from self._reddit.get(url, params=params)
323
324 return generator()
325
326 def now(self) -> models.LiveThread | None:
327 """Get the currently featured live thread.

Callers 2

createMethod · 0.45
subredditMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected