redditwarp.siteprocs.submission.create.SYNC#

class redditwarp.siteprocs.submission.create.SYNC.Create(client: Client)[source]#

Bases: object

text: Text#

Create a text post.

Use the following code to get the ID36 of the newly created post:

client.p.submission.create.text(...)
id36 = client.last_value['json']['data']['id']
Parameters:
  • sr (str) – Name of the subreddit to submit the post to.

  • title (str) – Title of the post.

  • body (Union[str, Mapping[str, JSON_ro]]) –

    The body text of the post.

    Specify either markdown text or a richtext document.

  • reply_notifications (bool) – Receive inbox notifications for replies.

  • spoiler (bool) – Mark as spoiler.

  • nsfw (bool) – Mark as NSFW.

  • oc (bool) – Mark as original content.

  • collection_uuid (Optional[str]) – The UUID of a collection to add this post to a collection.

  • flair_uuid (Optional[str]) – The UUID of a flair template to use.

  • flair_text (Optional[str]) – Custom flair text.

  • event_start (Optional[str]) – A datetime ISO 8601 string. E.g. 2018-09-11T12:00:00.

  • event_end (Optional[str]) – A datetime ISO 8601 string.

  • event_tz (Optional[str]) – A timezone. E.g., America/Los_Angeles.

Return type:

None

Returns:

For _YIntOrStr = int:

The integer ID of the newly created post.

For _YIntOrStr = str:

The base 36 ID of the newly created post.

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • BAD_SR_NAME:

      An empty string was specified for sr.

    • SUBREDDIT_NOEXIST:
      • The specified subreddit does not exist.

      • The specified subreddit is invalid.

    • SUBREDDIT_NOTALLOWED:
      • The subreddit is restricted and you are not an approved user.

      • You are banned from the subreddit.

      • You are trying to submit an image or video post to a NSFW subreddit.

      Note, quarantined subreddits can be posted to even if you haven’t yet opt-ed in to viewing its content.

    • NO_TEXT:

      The title parameter was not specified, was blank, or contained only whitespace.

    • JSON_PARSE_ERROR:

      Richtext was passed and it was not in the correct format.

    • TOO_LONG:
      • The title parameter must be under 300 characters.

      • The body parameter must be under 40000 characters.

    • NO_SELFS:

      The subreddit doesn’t accept text posts.

    • USER_REQUIRED:

      There is no user context.

  • redditwarp.http.exceptions.StatusCodeException

    • 404:

      The target subreddit is private or banned.

Create a link post.

Behaves similarly to text().

When linking to non-upload-lease resource locations, it is possible to get the ID36 of the newly created post using the following code:

client.p.submission.create.text(...)
id36 = client.last_value['json']['data']['id']

If the given link is an upload-lease resource location, a KeyError will occur upon the lookup of 'id'.

(parameters):

Similar to text().

Parameters:

url (str) – A URL.

(returns):

Similar to text().

(raises):

Similar to text().

Raises:

redditwarp.exceptions.RedditError

  • NO_URL:

    The link parameter was not specified, or the URL is invalid.

image: Image#

Create an image post.

Behaves similarly to text().

(parameters):

Similar to text().

Parameters:

link (str) – A URL to an image.

(returns):

Similar to text().

(raises):

Similar to text().

video: Video#

Create a video post.

Behaves similarly to text().

(parameters):

Similar to text().

Parameters:
  • link (str) – A URL to a video.

  • thumbnail (str) – A URL to an image to be used as a thumbnail for the video.

  • vgif (bool) – Pass True to create a video GIF.

Return type:

None

(raises):

Similar to text().

Raises:

redditwarp.exceptions.RedditError

  • MISSING_VIDEO_URLS:

    The thumbnail parameter was empty.

  • NO_VIDEOS:

    The subreddit does not accept video posts.

gallery: Gallery#

Create a gallery post.

Behaves similarly to text().

Use the following code to get the ID36 of the newly created post:

client.p.submission.create.text(...)
id36 = client.last_value['json']['data']['id'][3:]
(parameters):

Similar to text().

Parameters:

items (Sequence[GalleryItem]) – A list of gallery items.

(returns):

Similar to text().

(raises):

Similar to text().

poll: Poll#

Create a poll post.

Behaves similarly to text().

Use the following code to get the ID36 of the newly created post:

client.p.submission.create.text(...)
id36 = client.last_value['json']['data']['id'][3:]
(parameters):

Similar to text().

Parameters:
  • body (str) –

  • options (Sequence[str]) –

  • duration (int) –

    The number of days the poll runs for.

    Valid values are 1 to 7. If a number is specified outside this range it is clamped within range.

    The UI default is 3 days.

(returns):

Similar to text().

(raises):

Similar to text().

cross: Cross#

Create a crosspost.

Behaves similarly to text().

Use the following code to get the ID36 of the newly created post:

client.p.submission.create.text(...)
id36 = client.last_value['json']['data']['id']
(parameters):

Similar to text().

Parameters:

target (Union[int, str]) – The ID of a submission.

(returns):

Similar to text().

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED: Same as in text().

  • BAD_SR_NAME: “…”

  • SUBREDDIT_NOEXIST: “…”

  • SUBREDDIT_NOTALLOWED: “…”

  • INVALID_CROSSPOST_THING:

    The target subreddit is the same as the source.