diff --git a/instagrapi/mixins/auth.py b/instagrapi/mixins/auth.py index 4326a2d6..2883011d 100644 --- a/instagrapi/mixins/auth.py +++ b/instagrapi/mixins/auth.py @@ -218,7 +218,7 @@ def get_timeline_feed( "reason": reason, "battery_level": 100, # Random battery level is not simulating real bahaviour "timezone_offset": str(self.timezone_offset), - "_csrftoken": self.token, + # "_csrftoken": self.token, No longer in data "device_id": self.uuid, "request_id": self.request_id, "_uuid": self.uuid, @@ -235,6 +235,7 @@ def get_timeline_feed( if max_id: data["max_id"] = max_id + data["reason"] = "pagination" # if "push_disabled" in options: # data["push_disabled"] = "true" # if "recovered_from_crash" in options: diff --git a/instagrapi/mixins/user.py b/instagrapi/mixins/user.py index 30be7cd8..659b6260 100644 --- a/instagrapi/mixins/user.py +++ b/instagrapi/mixins/user.py @@ -14,6 +14,14 @@ from instagrapi.utils import json_value MAX_USER_COUNT = 200 +INFO_FROM_MODULES = ("self_profile", "feed_timeline", "reel_feed_timeline") + +try: + from typing import Literal + + INFO_FROM_MODULE = Literal[INFO_FROM_MODULES] +except: + INFO_FROM_MODULE = str class UserMixin: @@ -224,7 +232,12 @@ def user_info_gql(self, user_id: str) -> User: except JSONDecodeError as e: raise ClientJSONDecodeError(e, user_id=user_id) - def user_info_v1(self, user_id: str) -> User: + def user_info_v1( + self, + user_id: str, + from_module: INFO_FROM_MODULE = "self_profile", + is_app_start: bool = False, + ) -> User: """ Get user object from user id @@ -232,6 +245,10 @@ def user_info_v1(self, user_id: str) -> User: ---------- user_id: str User id of an instagram account + from_module: str + Which module triggered request: self_profile, feed_timeline, reel_feed_timeline. Default: self_profile + is_app_start: bool + Boolean value specifying if profile is being retrieved on app launch Returns ------- @@ -240,7 +257,19 @@ def user_info_v1(self, user_id: str) -> User: """ user_id = str(user_id) try: - result = self.private_request(f"users/{user_id}/info/") + params = { + "is_prefetch": "false", + "entry_point": "self_profile", + "from_module": from_module, + "is_app_start": is_app_start, + } + assert ( + from_module in INFO_FROM_MODULES + ), f'Unsupported send_attribute="{from_module}" {INFO_FROM_MODULES}' + if from_module != "self_profile": + params["entry_point"] = "profile" + + result = self.private_request(f"users/{user_id}/info/", params=params) except ClientNotFoundError as e: raise UserNotFound(e, user_id=user_id, **self.last_json) except ClientError as e: @@ -340,7 +369,10 @@ def user_friendship_v1(self, user_id: str) -> Relationship: """ try: - result = self.private_request(f"friendships/show/{user_id}/") + params = { + "is_external_deeplink_profile_view": "false", + } + result = self.private_request(f"friendships/show/{user_id}/", params=params) assert result.get("status", "") == "ok" return Relationship(user_id=user_id, **result)