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

Nested exception when a tweet contains photos and videos #26

Open
javerous opened this issue Mar 31, 2023 · 0 comments
Open

Nested exception when a tweet contains photos and videos #26

javerous opened this issue Mar 31, 2023 · 0 comments

Comments

@javerous
Copy link

javerous commented Mar 31, 2023

Apparently, it's not possible to mix photos and videos in a toot, contrary to a tweet. Mastodon API raises an exception in this case when the script try to post such toot.

There is a catch, then a 10s wait, but the script re-do the same, and the same exception is raised again.

I did a temporary "fix" by changing

        try:
            if len(toot_media)>0:
                time.sleep(5)
            toot = mastodon_api.status_post(c,
                                        in_reply_to_id=None,
                                        media_ids=toot_media,
                                        sensitive=False,
                                        visibility='unlisted',
                                        spoiler_text=None)
        except:
            print("10s delay")
            time.sleep(10)
            toot = mastodon_api.status_post(c,
                                            in_reply_to_id=None,
                                            media_ids=toot_media,
                                            sensitive=False,
                                            visibility='unlisted',
                                            spoiler_text=None)
            pass

to

        try:
            if len(toot_media)>0:
                time.sleep(5)
            toot = mastodon_api.status_post(c,
                                        in_reply_to_id=None,
                                        media_ids=toot_media,
                                        sensitive=False,
                                        visibility='unlisted',
                                        spoiler_text=None)
        except:
            print("10s delay")
            time.sleep(10)
            toot = mastodon_api.status_post(c,
                                            in_reply_to_id=None,
                                            media_ids=[],
                                            sensitive=False,
                                            visibility='unlisted',
                                            spoiler_text=None)
            pass

But I guess there is a better way to fix that (I'm very far from being a Python expert…)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant