diff --git a/src/vk_parser_app/workers/insta_parser.py b/src/vk_parser_app/workers/insta_parser.py index 61170a0..e8f90ae 100644 --- a/src/vk_parser_app/workers/insta_parser.py +++ b/src/vk_parser_app/workers/insta_parser.py @@ -8,14 +8,23 @@ import time from datetime import datetime, timedelta, timezone from pathlib import Path -from instagrapi import Client -from instagrapi.exceptions import ( - ChallengeRequired, - PleaseWaitFewMinutes, - LoginRequired, - UserNotFound, - PrivateAccount -) +try: + from instagrapi import Client + from instagrapi.exceptions import ( + ChallengeRequired, + PleaseWaitFewMinutes, + LoginRequired, + UserNotFound, + PrivateAccount + ) +except ImportError: + Client = None + ChallengeRequired = Exception + PleaseWaitFewMinutes = Exception + LoginRequired = Exception + UserNotFound = Exception + PrivateAccount = Exception + from loguru import logger from ..config import settings @@ -240,6 +249,10 @@ class InstaParserWorker: def setup_client(self, login: str, password: str, proxy: str | None) -> bool: if self.client: return True + + if Client is None: + logger.error("instagrapi is not installed! Cannot setup client.") + raise Exception("Module instagrapi is not installed. Please install it.") self.client = Client() if proxy: