Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor params updates #1958

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion instagrapi/mixins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
38 changes: 35 additions & 3 deletions instagrapi/mixins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -224,14 +232,23 @@ 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

Parameters
----------
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
-------
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
Loading