Update settings of the live thread. :param description: The live thread's description (default: ``None``). :param nsfw: Indicate whether this thread is not safe for work (default: ``None``). :param resources: Markdown formatted information that is useful for the
(
self,
*,
description: str | None = None,
nsfw: bool | None = None,
resources: str | None = None,
title: str | None = None,
**other_settings: str | None,
)
| 523 | self.thread._reddit.post(url) |
| 524 | |
| 525 | def update( |
| 526 | self, |
| 527 | *, |
| 528 | description: str | None = None, |
| 529 | nsfw: bool | None = None, |
| 530 | resources: str | None = None, |
| 531 | title: str | None = None, |
| 532 | **other_settings: str | None, |
| 533 | ) -> None: |
| 534 | """Update settings of the live thread. |
| 535 | |
| 536 | :param description: The live thread's description (default: ``None``). |
| 537 | :param nsfw: Indicate whether this thread is not safe for work (default: |
| 538 | ``None``). |
| 539 | :param resources: Markdown formatted information that is useful for the live |
| 540 | thread (default: ``None``). |
| 541 | :param title: The title of the live thread (default: ``None``). |
| 542 | |
| 543 | Does nothing if no arguments are provided. |
| 544 | |
| 545 | Each setting will maintain its current value if ``None`` is specified. |
| 546 | |
| 547 | Additional keyword arguments can be provided to handle new settings as Reddit |
| 548 | introduces them. |
| 549 | |
| 550 | Usage: |
| 551 | |
| 552 | .. code-block:: python |
| 553 | |
| 554 | thread = reddit.live("xyu8kmjvfrww") |
| 555 | |
| 556 | # update 'title' and 'nsfw' |
| 557 | updated_thread = thread.contrib.update(title=new_title, nsfw=True) |
| 558 | |
| 559 | If Reddit introduces new settings, you must specify ``None`` for the setting you |
| 560 | want to maintain: |
| 561 | |
| 562 | .. code-block:: python |
| 563 | |
| 564 | # update 'nsfw' and maintain new setting 'foo' |
| 565 | thread.contrib.update(nsfw=True, foo=None) |
| 566 | |
| 567 | """ |
| 568 | settings = { |
| 569 | "description": description, |
| 570 | "nsfw": nsfw, |
| 571 | "resources": resources, |
| 572 | "title": title, |
| 573 | } |
| 574 | settings.update(other_settings) |
| 575 | if all(value is None for value in settings.values()): |
| 576 | return |
| 577 | # get settings from Reddit (not cache) |
| 578 | thread = LiveThread(self.thread._reddit, self.thread.id) |
| 579 | data = {key: getattr(thread, key) if value is None else value for key, value in settings.items()} |
| 580 | |
| 581 | url = API_PATH["live_update_thread"].format(id=self.thread.id) |
| 582 | self.thread._reddit.post(url, data=data.copy()) |
no test coverage detected