kopia lustrzana https://github.com/bellingcat/auto-archiver
session file logic
rodzic
63f53358d3
commit
6c80a5b82d
|
@ -22,4 +22,5 @@ credentials.json
|
|||
secrets/*
|
||||
browsertrix/*
|
||||
browsertrix-tmp/*
|
||||
instaloader/*
|
||||
instaloader/*
|
||||
instaloader.session
|
|
@ -26,8 +26,16 @@ class InstagramArchiver(Archiver):
|
|||
try:
|
||||
self.insta.login(config.instagram_config.username, config.instagram_config.
|
||||
password)
|
||||
#TODO: wait for this issue to be fixed https://github.com/instaloader/instaloader/issues/1758
|
||||
self.insta.save_session_to_file(config.instagram_config.session_file)
|
||||
except Exception as e:
|
||||
logger.error(f"Unable to finish login: {e}\n{traceback.format_exc()}")
|
||||
logger.error(f"Unable to finish login (retrying from file): {e}\n{traceback.format_exc()}")
|
||||
try:
|
||||
self.insta.load_session_from_file(config.instagram_config.username, config.instagram_config.session_file)
|
||||
except Exception as e2:
|
||||
logger.error(f"Unable to login from session file: {e2}\n{traceback.format_exc()}")
|
||||
|
||||
|
||||
|
||||
def download(self, url, check_if_exists=False):
|
||||
post_matches = self.post_pattern.findall(url)
|
||||
|
|
|
@ -185,7 +185,8 @@ class Config:
|
|||
if "instagram" in secrets:
|
||||
self.instagram_config = InstagramConfig(
|
||||
username=secrets["instagram"]["username"],
|
||||
password=secrets["instagram"]["password"]
|
||||
password=secrets["instagram"]["password"],
|
||||
session_file=secrets["instagram"].get("session_file", "instaloader.session")
|
||||
)
|
||||
else:
|
||||
self.instagram_config = None
|
||||
|
|
|
@ -6,3 +6,4 @@ from dataclasses import dataclass
|
|||
class InstagramConfig:
|
||||
username: str
|
||||
password: str
|
||||
session_file: str
|
||||
|
|
|
@ -71,6 +71,7 @@ secrets:
|
|||
instagram:
|
||||
username: "username"
|
||||
password: "password"
|
||||
session_file: "instaloader.session" # <- default value
|
||||
|
||||
google_sheets:
|
||||
# local filename: defaults to service_account.json, see https://gspread.readthedocs.io/en/latest/oauth2.html#for-bots-using-service-account
|
||||
|
|
Ładowanie…
Reference in New Issue