Browse Source

Skip files that are too large.

master
Trey Del Bonis 2 years ago
parent
commit
480b6398f3
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      main.py

+ 6
- 0
main.py View File

import requests import requests
from mastodon import Mastodon from mastodon import Mastodon


MAX_SIZE = 39000000

def load_config(): def load_config():
with open(os.getenv('MR_CONFIG', 'config.json'), 'r') as f: with open(os.getenv('MR_CONFIG', 'config.json'), 'r') as f:
return json.loads(f.read()) return json.loads(f.read())
image_resps = [] image_resps = []
for a in data['media']: for a in data['media']:
dlpath = download_file(a, td) 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) res = masto.media_post(dlpath)
image_resps.append(res) image_resps.append(res)



Loading…
Cancel
Save