Skip to content

Commit

Permalink
Fix pydantic==1.10.9 [#1435]
Browse files Browse the repository at this point in the history
  • Loading branch information
adw0rd committed Jul 9, 2023
1 parent 288803b commit 70ff317
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions instagrapi/mixins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,3 +843,23 @@ def authorization(self) -> str:
b64part = base64.b64encode(dumps(self.authorization_data).encode()).decode()
return f"Bearer IGT:2:{b64part}"
return ""

def dump_instaman(self):
# helen9151hernandez:AgcXb0GJhAP|Instagram 200.0.0.24.121 Android (24/7.0; 640dpi; 1440x2392; Samsung; SGH-T849; SGH-T849; hi3660; pt_BR; 304101669)|097e7efb59ba976b;03c1746f-77cd-4ac6-8f7e-175b0ba0dc17;c4155719-9d80-466c-b3f7-f98f0a14a372;7fa9e7c7-75e1-498f-8d0f-8f56fe7a4f45|X-MID=YaHXxQABAAFcCc6aAC_OQ53CVDbd;IG-U-DS-USER-ID=50511821576;IG-U-RUR=FRC,50511821576,1669532533:01f705b9f6a7411dc1e985485b1fe39dd317e97b2cf166f380148836d9c2e5233cac5476;Authorization=Bearer IGT:2:eyJkc191c2VyX2lkIjoiNTA1MTE4MjE1NzYiLCJzZXNzaW9uaWQiOiI1MDUxMTgyMTU3NiUzQWtyaEVSbHF2VW8wbnRXJTNBMjQiLCJzaG91bGRfdXNlX2hlYWRlcl9vdmVyX2Nvb2tpZXMiOnRydWV9;X-IG-WWW-Claim=hmac.AR300vJeNkurM8IGnekSoFtSKJmXazjxOawhWNC3d1Gw1OiX;||
uuids = ";".join(
[
self.android_device_id.replace("android-", ""),
self.uuid,
self.phone_id,
self.client_session_id,
]
)
headers = {
"X-MID": self.mid,
"IG-U-DS-USER-ID": self.user_id,
"IG-U-RUR": self.ig_u_rur,
"Authorization": self.authorization,
"X-IG-WWW-Claim": self.ig_www_claim or "0",
}
headers = ";".join([f"{key}={value}" for key, value in headers.items()])
return f"{self.username}:{self.password}|{self.user_agent}|{uuids}|{headers};||"
5 changes: 5 additions & 0 deletions instagrapi/mixins/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PublicRequestMixin:
last_public_json = {}
public_request_logger = logging.getLogger("public_request")
request_timeout = 1
last_response_ts = 0

def __init__(self, *args, **kwargs):
# setup request session with retries
Expand Down Expand Up @@ -128,6 +129,8 @@ def _send_public_request(
self.public_requests_count += 1
if headers:
self.public.headers.update(headers)
if self.last_response_ts and (time.time() - self.last_response_ts) < 1.0:
time.sleep(1.0)
if self.request_timeout:
time.sleep(self.request_timeout)
try:
Expand Down Expand Up @@ -199,6 +202,8 @@ def _send_public_request(

except requests.ConnectionError as e:
raise ClientConnectionError("{} {}".format(e.__class__.__name__, str(e)))
finally:
self.last_response_ts = time.time()

def public_a1_request(self, endpoint, data=None, params=None, headers=None):
url = self.PUBLIC_API_URL + endpoint.lstrip("/")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requests==2.31.0
PySocks==1.7.1
pydantic==2.0
pydantic==1.10.9
moviepy==1.0.3
pycryptodomex==3.18.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

setup(
name="instagrapi",
version="1.17.11",
version="1.17.12",
author="Mikhail Andreev",
author_email="[email protected]",
license="MIT",
Expand Down

0 comments on commit 70ff317

Please sign in to comment.