1
0
Fork 0
mirror of https://github.com/Horhik/Instagram2Fedi.git synced 2025-04-08 13:26:19 +00:00

Capture error when Instagram flag the bot session

This commit is contained in:
DAMIE Marc 2024-01-19 10:22:32 +01:00
parent 6b7857f3bc
commit 199e8487e1

View file

@ -5,7 +5,7 @@ import time
import requests
from instaloader import Instaloader, Profile
from instaloader.exceptions import QueryReturnedBadRequestException
from instaloader.exceptions import QueryReturnedBadRequestException, ConnectionException
from already_posted import already_posted, mark_as_posted
from converters import split_array, try_to_get_carousel
@ -34,10 +34,16 @@ def get_instagram_user(user, fetched_user):
)
input("Press ENTER once the captcha is solved.")
assert user["name"] == loader.test_login()
except ConnectionException:
print_log(
"Invalid session (probably flagged as bot by Instagram)...",
color="red",
)
raise
print_log("Restored the session")
except FileNotFoundError:
except (FileNotFoundError, ConnectionException):
print_log(
"Found no active session... authentication attempt", color="yellow"
"Found no valid session... authentication attempt", color="yellow"
)
loader.login(user["name"], user["password"])
print_log("Authentication successful", color="green")