Browse Source

don't upload picture if youtube video is linked

master
hfte 2 years ago
parent
commit
7101909491
  1. 7
      mastaface.py

7
mastaface.py

@ -103,9 +103,8 @@ for bridge in config['bridges']:
logging.info('New post on https://www.facebook.com/' + bridge['facebook_page'] + ' found')
statuses = None
statuses = []
# Upload image if it exists
if post['image']:
url = post['image']
# Upload image if it exists and no youtube video is to be linked
if post['image'] and not (type(post['link']) == str and post['link'].find('youtu') != -1):
# TO DO
# fp = tempfile.TemporaryFile()
# fp.write(b'Hello world!')
@ -113,7 +112,7 @@ for bridge in config['bridges']:
# fp.read()
# fp.close()
# Using curl is necessary, because facebook's secure-image is very restrictive
subprocess.run(['curl', url, '--output', 'tmp.jpg',
subprocess.run(['curl', post['image'], '--output', 'tmp.jpg',
"-H", 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0',
"-H", 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
"-H", 'Accept-Language: de,en-US;q=0.7,en;q=0.3', "--compressed" ,

Loading…
Cancel
Save