LiveThread

class asyncpraw.models.LiveThread(reddit: asyncpraw.Reddit, id: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)

An individual LiveThread object.

Typical Attributes

Note

This table describes attributes that typically belong to objects of this class. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.

If you would like to add an attribute to this table, feel free to open a pull request.

Attribute

Description

created_utc

The creation time of the live thread, in Unix Time.

description

Description of the live thread, as Markdown.

description_html

Description of the live thread, as HTML.

id

The ID of the live thread.

nsfw

A bool representing whether or not the live thread is marked as NSFW.

__init__(reddit: asyncpraw.Reddit, id: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)

Initialize a LiveThread instance.

Parameters
  • reddit – An instance of Reddit.

  • id – A live thread ID, e.g., "ukaeu1ik4sw5"

contrib() asyncpraw.models.reddit.live.LiveThreadContribution

Provide an instance of LiveThreadContribution.

Usage:

thread = await reddit.live("ukaeu1ik4sw5")
await thread.contrib.add("### update")
contributor() asyncpraw.models.reddit.live.LiveContributorRelationship

Provide an instance of LiveContributorRelationship.

You can call the instance to get a list of contributors which is represented as RedditorList instance consists of Redditor instances. Those Redditor instances have permissions attributes as contributors:

thread = await reddit.live("ukaeu1ik4sw5")
async for contributor in thread.contributor():
    # prints `(Redditor(name="Acidtwist"), [u"all"])`
    print(contributor, contributor.permissions)
discussions(**generator_kwargs: Union[str, int, Dict[str, str]]) AsyncIterator[asyncpraw.models.Submission]

Get submissions linking to the thread.

Parameters

generator_kwargs – keyword arguments passed to ListingGenerator constructor.

Returns

A ListingGenerator object which yields Submission object.

Additional keyword arguments are passed in the initialization of ListingGenerator.

Usage:

thread = await reddit.live("ukaeu1ik4sw5")
async for submission in thread.discussions(limit=None):
    print(submission.title)
await get_update(update_id: str, fetch: bool = True, **kwargs) asyncpraw.models.LiveUpdate

Return a LiveUpdate instance.

Parameters
  • update_id – A live update ID, e.g., "7827987a-c998-11e4-a0b9-22000b6a88d2".

  • fetch – Determines if Async PRAW will fetch the object (default: True).

Usage:

thread = await reddit.live("ukaeu1ik4sw5")
update = await thread.get_update("7827987a-c998-11e4-a0b9-22000b6a88d2")
update.thread  # LiveThread(id="ukaeu1ik4sw5")
update.id  # "7827987a-c998-11e4-a0b9-22000b6a88d2"
update.author  # "umbrae"

If you don’t need the object fetched right away (e.g., to utilize a class method) you can do:

thread = await reddit.live("ukaeu1ik4sw5")
update = await thread.get_update("7827987a-c998-11e4-a0b9-22000b6a88d2", fetch=False)
update.contrib  # LiveUpdateContribution instance
await load()

Re-fetches the object.

This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any RedditBase object.

await reddit_base_object.load()
classmethod parse(data: Dict[str, Any], reddit: asyncpraw.Reddit) Any

Return an instance of cls from data.

Parameters
  • data – The structured data.

  • reddit – An instance of Reddit.

await report(type: str)

Report the thread violating the Reddit rules.

Parameters

type – One of "spam", "vote-manipulation", "personal-information", "sexualizing-minors", or "site-breaking".

Usage:

thread = await reddit.live("xyu8kmjvfrww")
await thread.report("spam")
stream() asyncpraw.models.reddit.live.LiveThreadStream

Provide an instance of LiveThreadStream.

Streams are used to indefinitely retrieve new updates made to a live thread, like:

for live_update in reddit.live("ta535s1hq2je").stream.updates():
    print(live_update.body)

Updates are yielded oldest first as LiveUpdate. Up to 100 historical updates will initially be returned. To only retrieve new updates starting from when the stream is created, pass skip_existing=True:

live_thread = await reddit.live("ta535s1hq2je")
async for live_update in live_thread.stream.updates(skip_existing=True):
    print(live_update.author)
async for ... in updates(**generator_kwargs: Union[str, int, Dict[str, str]]) AsyncIterator[asyncpraw.models.LiveUpdate]

Return a ListingGenerator yields LiveUpdate s.

Parameters

generator_kwargs – keyword arguments passed to ListingGenerator constructor.

Returns

A ListingGenerator object which yields LiveUpdate object.

Additional keyword arguments are passed in the initialization of ListingGenerator.

Usage:

thread = await reddit.live("ukaeu1ik4sw5")
after = "LiveUpdate_fefb3dae-7534-11e6-b259-0ef8c7233633"
async for submission in thread.updates(limit=5, params={"after": after}):
    print(submission.body)