From da5486d004564520296464cfad14d6f3cbc70fa7 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Tue, 16 Apr 2019 10:35:38 +0200 Subject: [PATCH] Fix: Mastodon allows posting 4 images max. --- feediverse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/feediverse.py b/feediverse.py index fff9c1a..446f439 100755 --- a/feediverse.py +++ b/feediverse.py @@ -15,6 +15,7 @@ import urllib3 DEFAULT_CONFIG_FILE = os.path.join("~", ".feediverse") +MAX_IMAGES = 4 # Mastodon allows attaching 4 images max. http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',) @@ -136,6 +137,8 @@ def collect_images(entry, generator=None): if resp.headers['content-type'].startswith(("image/", "video/")): images.append(resp) # IMPORTANT: Need to release_conn() later! + if len(images) >= MAX_IMAGES: + break else: resp.release_conn() return images