import os import io import re import jwt import json import pyotp import time import requests from time import sleep from datetime import datetime as date from PIL import Image from typing import Dict, List from instagrapi import Client from instagrapi.types import UserShort # It's better to store sensitive information in environment variables IG_USERNAME = os.getenv('INSTAGRAM_USERNAME', 'enchantedelysia') IG_PASSWORD = os.getenv('INSTAGRAM_PASSWORD', 'Synchr0!-IG') SECRET_KEY = os.getenv('INSTAGRAM_2FA_SECRET', '3FP7EC4GDQIP7QOQ2PBP5DE65T3SWRCV') IG_CREDENTIAL_PATH = "./ig_influencer_settings.json" SLEEP_TIME = "600" # in seconds IMG_FOLDER = "/Users/sij/AI/Vision/Private/Influencer/Images" ghost_api_key = '6576c87d071770755b69fbff:52e481c99955acfb1a727b8c7fc7f5c1f55b8b289622ef2edbd3747a242518fc' ghost_api_url = 'https://ai.env.esq/ghost/api/admin' rollover_time = 1702605780 TOTP = pyotp.TOTP(SECRET_KEY) current_unix_time = int(time.time()) time_since_rollover = current_unix_time - rollover_time while True: time_remaining = 30 - (time_since_rollover % 30) print(f"TOTP: {TOTP.now()}. Time remainng: {time_remaining}") time.sleep(1) class Bot: _cl = None def __init__(self): current_unix_time = int(time.time()) time_since_rollover = current_unix_time - rollover_time time_remaining = 30 - (time_since_rollover % 30) self._cl = Client() time.sleep(2) if time_remaining < 5: time.sleep(10) self._cl.login(IG_USERNAME, IG_PASSWORD, verification_code=TOTP.now()) self._cl.dump_settings(IG_CREDENTIAL_PATH) ## if __name__ == "__main__": ## bot = Bot()