|
|
@@ -11,6 +11,8 @@ from urllib.parse import urlparse |
|
|
|
import requests |
|
|
|
from mastodon import Mastodon |
|
|
|
|
|
|
|
MAX_SIZE = 39000000 |
|
|
|
|
|
|
|
def load_config(): |
|
|
|
with open(os.getenv('MR_CONFIG', 'config.json'), 'r') as f: |
|
|
|
return json.loads(f.read()) |
|
|
@@ -62,6 +64,10 @@ def make_post(masto, data): |
|
|
|
image_resps = [] |
|
|
|
for a in data['media']: |
|
|
|
dlpath = download_file(a, td) |
|
|
|
fsize = os.path.getsize(dlpath) |
|
|
|
if fsize > MAX_SIZE: |
|
|
|
print('ignoring file (too big):', dlpath, fsize, 'bytes') |
|
|
|
continue |
|
|
|
res = masto.media_post(dlpath) |
|
|
|
image_resps.append(res) |
|
|
|
|