Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text to other post types [image, gallery, video] #1987

Closed
wants to merge 10 commits into from

Conversation

DevGW
Copy link

@DevGW DevGW commented Oct 21, 2023

Fixes #1965

Feature Summary and Justification

This adds the ability to include text for the following post types:

  • image

  • video

  • gallery

Copy link
Member

@LilSpazJoekp LilSpazJoekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! This needs pre_push.py ran and then all the commits squashed into one. We will also need integration tests as well.

self,
title: str,
images: list[dict[str, str]],
text: str = '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be named selftext and sorted into the keyword arguments alphabetically.

@@ -1415,6 +1411,7 @@ def submit_image(
title: str,
image_path: str,
*,
text: str = None, # New optional parameter for text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this.

@@ -1631,6 +1631,7 @@ def submit_video(
title: str,
video_path: str,
*,
text: str = None, # New optional parameter for text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this.

:param images: The images to post in dict with the following structure:
``{"image_path": "path", "caption": "caption", "outbound_url": "url"}``,
only ``image_path`` is required.
:param text: The Markdown formatted content for a ``text`` submission. Use an empty string, ``""``, to make a title-only submission.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be sorted in here.

Comment on lines +1307 to +1352
:param title: The title of the submission.
:param images: The images to post in dict with the following structure:
``{"image_path": "path", "caption": "caption", "outbound_url": "url"}``,
only ``image_path`` is required.
:param text: The Markdown formatted content for a ``text`` submission. Use an empty string, ``""``, to make a title-only submission.
:param collection_id: The UUID of a :class:`.Collection` to add the
newly-submitted post to.
:param discussion_type: Set to ``"CHAT"`` to enable live discussion instead of
traditional comments (default: ``None``).
:param flair_id: The flair template to select (default: ``None``).
:param flair_text: If the template's ``flair_text_editable`` value is ``True``,
this value will set a custom text (default: ``None``). ``flair_id`` is
required when ``flair_text`` is provided.
:param nsfw: Whether the submission should be marked NSFW (default: ``False``).
:param send_replies: When ``True``, messages will be sent to the submission
author when comments are made to the submission (default: ``True``).
:param spoiler: Whether the submission should be marked asa spoiler (default:
``False``).
:returns: A :class:`.Submission` object for the newly created submission.
:raises: :class:`.ClientException` if ``image_path`` in ``images`` refers to a
file that is not an image.
For example, to submit an image gallery to r/test do:
.. code-block:: python
title = "My favorite pictures"
image = "/path/to/image.png"
image2 = "/path/to/image2.png"
image3 = "/path/to/image3.png"
images = [
{"image_path": image},
{
"image_path": image2,
"caption": "Image caption 2",
},
{
"image_path": image3,
"caption": "Image caption 3",
"outbound_url": "https://example.com/link3",
},
]
reddit.subreddit("test").submit_gallery(title, images)
.. seealso::
- :meth:`~.Subreddit.submit` to submit url posts and selftexts
- :meth:`~.Subreddit.submit_image` to submit single images
- :meth:`~.Subreddit.submit_poll` to submit polls
- :meth:`~.Subreddit.submit_video` to submit videos and videogifs
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs reverted with just the new selftext parameter added.

@@ -1367,13 +1361,14 @@ def submit_gallery(
"spoiler": bool(spoiler),
"sr": str(self),
"title": title,
"text": text,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a conditional inclusion. It needs added to the for-loop on 1367.

@@ -1496,11 +1493,15 @@ def submit_image(
"spoiler": bool(spoiler),
"validate_on_submit": self._reddit.validate_on_submit,
}
# Check if text is provided and add to data dictionary
if text:
data["text"] = text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to for-loop below.

@@ -1715,6 +1716,7 @@ def submit_video(
"resubmit": bool(resubmit),
"sendreplies": bool(send_replies),
"title": title,
"text": text, # Add the new 'text' parameter to the data dict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mentioned above, this needs added to the for-loop.

Copy link

This PR is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale Issue or pull request has been inactive for 20 days label Nov 20, 2023
Copy link

This PR was closed because it has been stale for 30 days with no activity.

@github-actions github-actions bot added the Auto-closed - Stale Automatically closed due to being stale for too long label Dec 21, 2023
@github-actions github-actions bot closed this Dec 21, 2023
@LilSpazJoekp LilSpazJoekp reopened this Dec 28, 2023
@github-actions github-actions bot removed the Auto-closed - Stale Automatically closed due to being stale for too long label Dec 28, 2023
Copy link

This PR was closed because it has been stale for 30 days with no activity.

@github-actions github-actions bot added the Auto-closed - Stale Automatically closed due to being stale for too long label Jan 27, 2024
@github-actions github-actions bot closed this Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-closed - Stale Automatically closed due to being stale for too long Stale Issue or pull request has been inactive for 20 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support adding text on all post types
2 participants