redditwarp.siteprocs.collection.SYNC#

class redditwarp.siteprocs.collection.SYNC.CollectionProcedures(client: Client)[source]#

Bases: object

create(sr_id: int | str, title: str, description: str | None = None, display_layout: str | None = None) SubmissionCollection[source]#

Create a collection.

Returns the newly created collection.

Parameters:
  • sr_id (int | str) – Subreddit ID.

  • title (str) – A string no longer than 300 characters.

  • description (Optional[str]) – A string no longer than 500 characters.

  • display_layout (Optional[str]) –

    Either TIMELINE or GALLERY.

    Default is TIMELINE.

Return type:

SubmissionCollection

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • SUBREDDIT_NOEXIST:

    The specified subreddit (sr_id) does not exist.

  • NO_TEXT:

    The specified title was empty.

  • TOO_LONG:
    • The specified title was longer than 300 characters.

    • The specified description was longer than 500 characters.

  • INVALID_OPTION:

    The value specified for display_layout is not valid.

    The options are case-sensitive.

add_post(uuid: str, subm_id: int | str) None[source]#

Add a submission to a collection.

Collections have a capacity of 100 posts. Attempting to add to a full collection will result in an INVALID_COLLECTION_UPDATE API error.

Parameters:
  • uuid (str) –

  • subm_id (int | str) –

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_TEXT:

      The specified uuid was empty.

    • TOO_SHORT:

      The specified uuid was under 36 characters.

    • TOO_LONG:
      • The specified uuid was over 36 characters.

      • The specified description was longer than 500 characters.

    • INVALID_COLLECTION_UPDATE:
      • The specified uuid does not exist.

      • The submission specified by subm_id already exists in the collection.

      • The submission specified by subm_id does not match the collection’s subreddit.

      • The collection is full (it contains 100 posts).

  • redditwarp.http.exceptions.StatusCodeException

    • 404:

      The submission specified by subm_id does not exist.

    • 500:

      The value specified by uuid is not a valid UUID.

remove_post(uuid: str, subm_id: int | str) None[source]#

Remove a submission from a collection.

Parameters:
  • uuid (str) –

  • subm_id (int | str) –

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_TEXT:

      The specified uuid was empty.

    • TOO_SHORT:

      The specified uuid was under 36 characters.

    • TOO_LONG:
      • The specified uuid was over 36 characters.

      • The specified description was longer than 500 characters.

    • INVALID_COLLECTION_UPDATE:
      • The specified uuid does not exist.

      • The submission specified by subm_id does not exist in the collection.

  • redditwarp.http.exceptions.StatusCodeException

    • 404:

      The submission specified by subm_id does not exist.

    • 500:

      The value specified by uuid is not a valid UUID.

get_full(uuid: str) SubmissionCollection | None[source]#

Get a collection, including its submissions.

Parameters:

uuid (str) –

Return type:

Optional[SubmissionCollection]

Raises:

redditwarp.exceptions.RedditError

  • NO_TEXT:

    The specified uuid was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:

    The specified uuid was over 36 characters.

get_info(uuid: str) SubmissionCollectionInfo | None[source]#

Get a collection, excluding its submissions.

Parameters:

uuid (str) –

Return type:

Optional[SubmissionCollectionInfo]

Raises:

redditwarp.exceptions.RedditError

  • NO_TEXT:

    The specified uuid was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:

    The specified uuid was over 36 characters.

get_subreddit_collections_info(sr_id: int | str) Sequence[SubmissionCollectionInfo][source]#

Get a list of collections’ details from the subreddit.

Parameters:

id (int | str) – Subreddit ID.

Return type:

Sequence[SubmissionCollectionInfo]

Raises:

redditwarp.exceptions.RedditError

  • SUBREDDIT_NOEXIST:

    The specified subreddit could not be found.

delete(uuid: str) None[source]#

Delete a collection.

Parameters:

uuid (str) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • NO_TEXT:

    The specified uuid was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:

    The specified uuid was over 36 characters.

  • INVALID_COLLECTION_ID:

    The specified does not exist.

reorder(uuid: str, subm_ids: Sequence[int] | Sequence[str]) None[source]#

Reorder posts in a collection.

An API error is returned (INVALID_COLLECTION_UPDATE) if an ID in the given list is not found in the collection.

If only a subset of the IDs in the collection are specified then those submissions will be moved to the top of the collection in the order specified. The rest are moved down, maintaining their order.

Parameters:
  • uuid (str) –

  • subm_ids (Sequence[int] | Sequence[str]) –

Return type:

None

Raises:
set_title(uuid: str, title: str) None[source]#

Update a collection’s title.

Parameters:
  • uuid (str) –

  • title (str) –

    New title for the collection, up to 300 characters long.

    It should not be an empty string.

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • NO_TEXT:
    • The specified uuid was empty.

    • The specified title was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:
    • The specified uuid was over 36 characters.

    • The specified title was over 300 characters.

  • INVALID_COLLECTION_ID:

    The specified uuid does not exist.

set_description(uuid: str, desc: str) None[source]#

Update a collection’s description.

Parameters:
  • uuid (str) –

  • title (str) –

    New description for the collection, up to 500 characters long.

    Can be an empty string.

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • NO_TEXT:
    • The specified uuid was empty.

    • The specified title was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:
    • The specified uuid was over 36 characters.

    • The specified description was over 500 characters.

  • INVALID_COLLECTION_ID:

    The specified uuid does not exist.

set_display_layout(uuid: str, layout: str | None) None[source]#

Update a collection’s display layout.

Parameters:
  • uuid (str) –

  • layout (Optional[str]) –

    Either TIMELINE or GALLERY.

    Case-sensitive.

    If not specified or an empty string, the display_layout field on the collection object will be set to null, which is treated the same as TIMELINE.

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • NO_TEXT:

    The specified uuid was empty.

  • TOO_SHORT:

    The specified uuid was under 36 characters.

  • TOO_LONG:

    The specified uuid was over 36 characters.

  • INVALID_COLLECTION_ID:

    The specified uuid does not exist.

  • INVALID_OPTION:

    The value specified for display_layout is not valid.

    The options are case-sensitive.

follow(uuid: str) None[source]#

Follow a collection.

This actually has a similar effect to follow_event(). When you follow a collection, all submissions in the collection will be followed, even if there is no event information on any of the posts.

When a new submission is added to a followed collection, the submission is automatically followed. If any of the individual submissions are unfollowed via unfollow_event() then the whole collection and all of its submissions are unfollowed, having the same effect as unfollow().

To tell if a collection is followed, check if one of its submissions is:

coll = client.p.collection.get_full('84359211-be58-4c98-87cd-26bc10c59fb3')
if coll is None:
    raise Exception
followed = any(subm.me.is_following_event for subm in coll)
print(followed)
Parameters:

uuid (str) –

Return type:

None

Raises:
unfollow(uuid: str) None[source]#

Unfollow a collection.

Parameters:

uuid (str) –

Return type:

None

(raises):

(Same as follow().)