From 8e6728af7754b132b9175be3cdfe7241eda37bf1 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 28 May 2023 19:36:48 -0400 Subject: [PATCH] Add session file --- Dockerfile | 2 +- requirements.txt | 2 +- src/arguments.py | 0 src/main.py | 3 +++ src/network.py | 4 +++- 5 files changed, 8 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/arguments.py diff --git a/Dockerfile b/Dockerfile index cc77174..a494273 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.11 COPY . /app diff --git a/requirements.txt b/requirements.txt index f6036a2..7f1bc13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ charset-normalizer==2.1.0 colorama==0.4.5 decorator==5.1.1 idna==3.3 -instaloader==4.9.3 +instaloader==4.9.6 Mastodon.py==1.5.1 python-dateutil==2.8.2 python-magic==0.4.27 diff --git a/src/arguments.py b/src/arguments.py old mode 100644 new mode 100755 diff --git a/src/main.py b/src/main.py index 23f849f..cd8208f 100644 --- a/src/main.py +++ b/src/main.py @@ -40,10 +40,13 @@ agree = [1, True, "true", "True", "yes", "Yes"] if (os.environ.get("USE_KUBERNETES")): id_filename = "/data/already_posted.txt" + id_session = "/data/session" elif (os.environ.get("USE_DOCKER")): id_filename = "/app/already_posted.txt" + id_session = "/app/session" else: id_filename = "./already_posted.txt" + id_session = "./session" print(id_filename) diff --git a/src/network.py b/src/network.py index 80c9516..cc01c95 100644 --- a/src/network.py +++ b/src/network.py @@ -14,10 +14,12 @@ def get_instagram_user(user, fetched_user): print(Fore.GREEN + 'TEST 🚀 > Connecting to Instagram...') print(Style.RESET_ALL) print(datetime.datetime.now()) - + if os.path.exists(id_session): + L.load_session_from_file(user["name"], id_session) if user["name"] != None: print("USER USER USER!!!!!!!!!!!!!", user["name"]) L.login(user["name"], user["password"]) + L.save_session_to_file(id_session) return Profile.from_username(L.context, fetched_user) def get_image(url):