From dd587bb40300d247e9609f043339c51371463ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABlle=20Anthony?= Date: Fri, 2 Feb 2018 13:46:47 -0500 Subject: Update Mastodon.py Modified docstring slightly; added type checking for media_ids in the status_post() method. If media_ids is not a list or tuple, put it into a list before parsing it. --- mastodon/Mastodon.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ffaf32e..874d925 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -895,10 +895,10 @@ class Mastodon: Post a status. Can optionally be in reply to another status and contain media. - `media_ids` must be a list (even if you're only attaching one item). It - can contain up to four pieces of media (uploaded via `media_post()`_). - `media_ids` can also be the `media dicts`_ returned by `media_post()`_ - - they are unpacked automatically. + `media_ids` should be a list. (If it's not, the function will turn it + into one.) It can contain up to four pieces of media (uploaded via + `media_post()`_). `media_ids` can also be the `media dicts`_ returned + by `media_post()`_ - they are unpacked automatically. The `sensitive` boolean decides whether or not media attached to the post should be marked as sensitive, which hides it by default on the Mastodon @@ -939,6 +939,8 @@ class Mastodon: if media_ids is not None: try: media_ids_proper = [] + if not isinstance(media_ids, (list, tuple)): + media_ids = [media_ids] for media_id in media_ids: if isinstance(media_id, dict): media_ids_proper.append(media_id["id"]) -- cgit v1.2.3