In [1]:
import os
from dotenv import load_dotenv
from twython import Twython
from datetime import datetime, timedelta
import os.path
from os import path

# Get file names
date = datetime.now() - timedelta(days = 1) 
date_string = date.strftime('%-m-%-d-%y')
first_pic = '/Users/kootsoop/Pictures/COVID-19-FORECAST-' + date_string + '.png'
second_pic = '/Users/kootsoop/Pictures/COVID-19-FORECAST-HISTORY-' + date_string + '.png'

load_dotenv(dotenv_path='/Users/kootsoop/.env')

API_KEY = os.getenv('TWITTER_API_KEY')
API_SECRET_KEY = os.getenv('TWITTER_API_SECRET_KEY')
ACCESS_TOKEN=os.getenv('TWITTER_ACCESS_TOKEN')
ACCESS_TOKEN_SECRET=os.getenv('TWITTER_ACCESS_TOKEN_SECRET')

twitter = Twython(API_KEY, API_SECRET_KEY, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

image1_ids = ''
image2_ids = ''

if path.exists(first_pic):
    print('First pic found : ' + first_pic)
    image1_open = open(first_pic, 'rb')
    image1_ids = twitter.upload_media(media=image1_open)
    

if path.exists(second_pic):
    print('Second pic found : ' + second_pic)
    image2_open = open(second_pic, 'rb')
    image2_ids = twitter.upload_media(media=image2_open)
    
twitter.update_status(status=date_string + ': Forecast date for 200k deaths in the USA. #tracking200k',media_ids=[image1_ids['media_id'], image2_ids['media_id']])


First pic found : /Users/kootsoop/Pictures/COVID-19-FORECAST-7-20-20.png
Second pic found : /Users/kootsoop/Pictures/COVID-19-FORECAST-HISTORY-7-20-20.png
Out[1]:
{'created_at': 'Tue Jul 21 15:06:41 +0000 2020',
 'id': 1285592038965215232,
 'id_str': '1285592038965215232',
 'text': '7-20-20: Forecast date for 200k deaths in the USA. #tracking200k https://t.co/decZJM0VVm',
 'truncated': False,
 'entities': {'hashtags': [{'text': 'tracking200k', 'indices': [51, 64]}],
  'symbols': [],
  'user_mentions': [],
  'urls': [],
  'media': [{'id': 1285592032896065536,
    'id_str': '1285592032896065536',
    'indices': [65, 88],
    'media_url': 'http://pbs.twimg.com/media/EddXJH7XoAAEjKU.png',
    'media_url_https': 'https://pbs.twimg.com/media/EddXJH7XoAAEjKU.png',
    'url': 'https://t.co/decZJM0VVm',
    'display_url': 'pic.twitter.com/decZJM0VVm',
    'expanded_url': 'https://twitter.com/kootsoop/status/1285592038965215232/photo/1',
    'type': 'photo',
    'sizes': {'medium': {'w': 1200, 'h': 1200, 'resize': 'fit'},
     'small': {'w': 680, 'h': 680, 'resize': 'fit'},
     'thumb': {'w': 150, 'h': 150, 'resize': 'crop'},
     'large': {'w': 1440, 'h': 1440, 'resize': 'fit'}}}]},
 'extended_entities': {'media': [{'id': 1285592032896065536,
    'id_str': '1285592032896065536',
    'indices': [65, 88],
    'media_url': 'http://pbs.twimg.com/media/EddXJH7XoAAEjKU.png',
    'media_url_https': 'https://pbs.twimg.com/media/EddXJH7XoAAEjKU.png',
    'url': 'https://t.co/decZJM0VVm',
    'display_url': 'pic.twitter.com/decZJM0VVm',
    'expanded_url': 'https://twitter.com/kootsoop/status/1285592038965215232/photo/1',
    'type': 'photo',
    'sizes': {'medium': {'w': 1200, 'h': 1200, 'resize': 'fit'},
     'small': {'w': 680, 'h': 680, 'resize': 'fit'},
     'thumb': {'w': 150, 'h': 150, 'resize': 'crop'},
     'large': {'w': 1440, 'h': 1440, 'resize': 'fit'}}},
   {'id': 1285592036008132609,
    'id_str': '1285592036008132609',
    'indices': [65, 88],
    'media_url': 'http://pbs.twimg.com/media/EddXJThWAAEIxO5.png',
    'media_url_https': 'https://pbs.twimg.com/media/EddXJThWAAEIxO5.png',
    'url': 'https://t.co/decZJM0VVm',
    'display_url': 'pic.twitter.com/decZJM0VVm',
    'expanded_url': 'https://twitter.com/kootsoop/status/1285592038965215232/photo/1',
    'type': 'photo',
    'sizes': {'medium': {'w': 1200, 'h': 1200, 'resize': 'fit'},
     'small': {'w': 680, 'h': 680, 'resize': 'fit'},
     'thumb': {'w': 150, 'h': 150, 'resize': 'crop'},
     'large': {'w': 1440, 'h': 1440, 'resize': 'fit'}}}]},
 'source': '<a href="http://www.kootsoop.com" rel="nofollow">Pjkr</a>',
 'in_reply_to_status_id': None,
 'in_reply_to_status_id_str': None,
 'in_reply_to_user_id': None,
 'in_reply_to_user_id_str': None,
 'in_reply_to_screen_name': None,
 'user': {'id': 24472612,
  'id_str': '24472612',
  'name': 'Peter J. Kootsookos',
  'screen_name': 'kootsoop',
  'location': 'CT, USA',
  'description': 'Need to do FUN STUFF! Oz/Irish/US engineer, currently living in the USA. Married, one dog 🐶, one cat 🙀, two kids, and three passports. He/him.',
  'url': 'https://t.co/PZLkrwluOI',
  'entities': {'url': {'urls': [{'url': 'https://t.co/PZLkrwluOI',
      'expanded_url': 'https://kootsoop.com/',
      'display_url': 'kootsoop.com',
      'indices': [0, 23]}]},
   'description': {'urls': []}},
  'protected': False,
  'followers_count': 345,
  'friends_count': 1321,
  'listed_count': 28,
  'created_at': 'Sun Mar 15 02:26:51 +0000 2009',
  'favourites_count': 29751,
  'utc_offset': None,
  'time_zone': None,
  'geo_enabled': True,
  'verified': False,
  'statuses_count': 13923,
  'lang': None,
  'contributors_enabled': False,
  'is_translator': False,
  'is_translation_enabled': False,
  'profile_background_color': 'ABB8C2',
  'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme18/bg.gif',
  'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme18/bg.gif',
  'profile_background_tile': True,
  'profile_image_url': 'http://pbs.twimg.com/profile_images/1195087017882849281/Pma0Mbg__normal.jpg',
  'profile_image_url_https': 'https://pbs.twimg.com/profile_images/1195087017882849281/Pma0Mbg__normal.jpg',
  'profile_banner_url': 'https://pbs.twimg.com/profile_banners/24472612/1452297426',
  'profile_link_color': '4A913C',
  'profile_sidebar_border_color': '000000',
  'profile_sidebar_fill_color': 'F6F6F6',
  'profile_text_color': '333333',
  'profile_use_background_image': True,
  'has_extended_profile': True,
  'default_profile': False,
  'default_profile_image': False,
  'following': False,
  'follow_request_sent': False,
  'notifications': False,
  'translator_type': 'none'},
 'geo': None,
 'coordinates': None,
 'place': None,
 'contributors': None,
 'is_quote_status': False,
 'retweet_count': 0,
 'favorite_count': 0,
 'favorited': False,
 'retweeted': False,
 'possibly_sensitive': False,
 'lang': 'en'}

In [ ]: