Skip to content

Commit

Permalink
Merge pull request #1666 from jarrodnorwell/master
Browse files Browse the repository at this point in the history
Fixes .com// in public api url and updates query_hash's for user_following_gql_chunk and user_followers_gql_chunk
  • Loading branch information
subzeroid authored Nov 30, 2023
2 parents 1b4a6ce + c49daa5 commit c9e6ba5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion instagrapi/mixins/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def _send_public_request(
self.last_response_ts = time.time()

def public_a1_request(self, endpoint, data=None, params=None, headers=None):
url = self.PUBLIC_API_URL + endpoint # (jarrodnorwell) fixed KeyError: 'data'
url = (self.PUBLIC_API_URL + str(endpoint)).replace(
".com//", ".com/"
) # (jarrodnorwell) fixed KeyError: 'data', fixed // error
params = params or {}
params.update({"__a": 1, "__d": "dis"})

Expand Down
5 changes: 2 additions & 3 deletions instagrapi/mixins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ def search_users(self, query: str, count: int = 50) -> List[UserShort]:
return self.search_users_v1(query, count)

def search_followers_v1(self, user_id: str, query: str) -> List[UserShort]:

"""
Search users by followers (Private Mobile API)
Expand Down Expand Up @@ -507,7 +506,7 @@ def user_following_gql(self, user_id: str, amount: int = 0) -> List[UserShort]:
if end_cursor:
variables["after"] = end_cursor
data = self.public_graphql_request(
variables, query_hash="e7e2f4da4b02303f74f0841279e52d76"
variables, query_hash="58712303d941c6855d4e888c5f0cd22f"
)
if not data["user"] and not users:
raise UserNotFound(user_id=user_id, **data)
Expand Down Expand Up @@ -662,7 +661,7 @@ def user_followers_gql_chunk(
if end_cursor:
variables["after"] = end_cursor
data = self.public_graphql_request(
variables, query_hash="5aefa9893005572d237da5068082d8d5"
variables, query_hash="37479f2b8209594dde7facb0d904896a"
)
if not data["user"] and not users:
raise UserNotFound(user_id=user_id, **data)
Expand Down
4 changes: 4 additions & 0 deletions instagrapi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class Resource(BaseModel):


class User(BaseModel):
model_config = ConfigDict(
coerce_numbers_to_str=True
) # (jarrodnorwell) fixed city_id issue

pk: str
username: str
full_name: str
Expand Down

0 comments on commit c9e6ba5

Please sign in to comment.