@danhachuel/thunderbolt 0.6.67 → 0.6.69
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.
|
@@ -272,7 +272,12 @@ def _extract_profile_user_from_html(document: str, username: str) -> dict[str, A
|
|
|
272
272
|
|
|
273
273
|
def _fetch_web_profile_user(username: str) -> dict[str, Any] | None:
|
|
274
274
|
headers = _instagram_headers()
|
|
275
|
-
|
|
275
|
+
if platform.system() == 'Windows':
|
|
276
|
+
headers.update({
|
|
277
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/131.0 Safari/537.36',
|
|
278
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
279
|
+
'Accept-Language': 'pt-BR,pt;q=0.9,en;q=0.8',
|
|
280
|
+
})
|
|
276
281
|
# The www host is the current public web endpoint. The legacy i host is
|
|
277
282
|
# retained as a fallback because Instagram rate-limits the two hosts
|
|
278
283
|
# independently and their availability can vary by region.
|
|
@@ -305,11 +310,20 @@ def _fetch_web_profile_user(username: str) -> dict[str, Any] | None:
|
|
|
305
310
|
best_user: dict[str, Any] | None = None
|
|
306
311
|
for endpoint in endpoints:
|
|
307
312
|
try:
|
|
313
|
+
if platform.system() == 'Windows':
|
|
314
|
+
print(f'Instagram API Windows: URL chamada: {endpoint}')
|
|
308
315
|
response = requests.get(endpoint, headers=headers, timeout=15)
|
|
316
|
+
if platform.system() == 'Windows':
|
|
317
|
+
response_text = str(getattr(response, 'text', '') or '')
|
|
318
|
+
print(f'Instagram API Windows: status={response.status_code}; tamanho={len(response_text)}; início={response_text[:500]!r}')
|
|
309
319
|
if response.status_code >= 400:
|
|
320
|
+
if platform.system() == 'Windows':
|
|
321
|
+
print(f'Instagram API Windows: HTTP {response.status_code}; a tentar o próximo endpoint/fallback.')
|
|
310
322
|
continue
|
|
311
323
|
payload = response.json()
|
|
312
|
-
except (requests.RequestException, ValueError, AttributeError):
|
|
324
|
+
except (requests.RequestException, ValueError, AttributeError) as exc:
|
|
325
|
+
if platform.system() == 'Windows':
|
|
326
|
+
print(f'Instagram API Windows: erro ao consultar/parsing {endpoint}: {exc}')
|
|
313
327
|
continue
|
|
314
328
|
user = ((payload.get('data') or {}).get('user') if isinstance(payload, dict) else None)
|
|
315
329
|
if isinstance(user, dict):
|
|
@@ -585,6 +599,7 @@ def _post_from_node(node: dict[str, Any]) -> dict[str, Any] | None:
|
|
|
585
599
|
}
|
|
586
600
|
|
|
587
601
|
|
|
602
|
+
|
|
588
603
|
def _fetch_posts_with_ytdlp(username: str, limit: int = 10) -> list[dict[str, Any]]:
|
|
589
604
|
"""Fetch public Instagram post metadata with the installed yt-dlp CLI."""
|
|
590
605
|
import subprocess
|
|
@@ -639,10 +654,7 @@ def fetch_public_instagram_posts(source: str, limit: int = 10) -> IntegrationRes
|
|
|
639
654
|
except ValueError as exc:
|
|
640
655
|
return IntegrationResult(False, str(exc), {})
|
|
641
656
|
if platform.system() == 'Windows':
|
|
642
|
-
|
|
643
|
-
print(f'yt-dlp posts retornados para @{reference["username"]}: {len(ytdlp_posts)}')
|
|
644
|
-
if ytdlp_posts:
|
|
645
|
-
return IntegrationResult(True, f'{len(ytdlp_posts)} posts obtidos via yt-dlp', reference | {'posts': ytdlp_posts})
|
|
657
|
+
print(f'Posts Windows: a iniciar consulta pública API/HTML para @{reference["username"]}')
|
|
646
658
|
api_user = _fetch_web_profile_user(reference['username'])
|
|
647
659
|
if api_user:
|
|
648
660
|
api_posts: list[dict[str, Any]] = []
|
package/package.json
CHANGED