@danhachuel/thunderbolt 0.6.36 → 0.6.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/integrations/instagram_public.py +20 -12
- package/package.json +1 -1
|
@@ -152,20 +152,28 @@ def _fetch_web_profile_user(username: str) -> dict[str, Any] | None:
|
|
|
152
152
|
merged[key] = value
|
|
153
153
|
return merged
|
|
154
154
|
|
|
155
|
+
request_headers = [
|
|
156
|
+
headers,
|
|
157
|
+
{**headers, 'User-Agent': 'Instagram 390.0.0.0.50 Android', 'Accept': 'application/json, text/plain, */*'},
|
|
158
|
+
{**headers, 'Referer': f'https://www.instagram.com/{username}/', 'Origin': 'https://www.instagram.com', 'X-Requested-With': 'XMLHttpRequest'},
|
|
159
|
+
]
|
|
155
160
|
best_user: dict[str, Any] | None = None
|
|
156
|
-
for
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
for request_header in request_headers:
|
|
162
|
+
for endpoint in endpoints:
|
|
163
|
+
try:
|
|
164
|
+
response = requests.get(endpoint, headers=request_header, timeout=15)
|
|
165
|
+
if response.status_code >= 400:
|
|
166
|
+
continue
|
|
167
|
+
payload = response.json()
|
|
168
|
+
except (requests.RequestException, ValueError, AttributeError, StopIteration):
|
|
169
|
+
if best_user:
|
|
170
|
+
return best_user
|
|
160
171
|
continue
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
best_user = merge_profile(best_user, user)
|
|
167
|
-
if profile_quality(best_user) >= 4:
|
|
168
|
-
return best_user
|
|
172
|
+
user = ((payload.get('data') or {}).get('user') if isinstance(payload, dict) else None)
|
|
173
|
+
if isinstance(user, dict):
|
|
174
|
+
best_user = merge_profile(best_user, user)
|
|
175
|
+
if profile_quality(best_user) >= 4:
|
|
176
|
+
return best_user
|
|
169
177
|
|
|
170
178
|
curl = shutil.which('curl')
|
|
171
179
|
if curl:
|
package/package.json
CHANGED