Fix: Mastodon allows posting 4 images max.
This commit is contained in:
@ -15,6 +15,7 @@ import urllib3
|
|||||||
|
|
||||||
|
|
||||||
DEFAULT_CONFIG_FILE = os.path.join("~", ".feediverse")
|
DEFAULT_CONFIG_FILE = os.path.join("~", ".feediverse")
|
||||||
|
MAX_IMAGES = 4 # Mastodon allows attaching 4 images max.
|
||||||
|
|
||||||
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',)
|
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/")):
|
if resp.headers['content-type'].startswith(("image/", "video/")):
|
||||||
images.append(resp)
|
images.append(resp)
|
||||||
# IMPORTANT: Need to release_conn() later!
|
# IMPORTANT: Need to release_conn() later!
|
||||||
|
if len(images) >= MAX_IMAGES:
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
resp.release_conn()
|
resp.release_conn()
|
||||||
return images
|
return images
|
||||||
|
|||||||
Reference in New Issue
Block a user