@danhachuel/thunderbolt 0.6.64 → 0.6.65

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.
@@ -605,10 +605,25 @@ def fetch_public_instagram_posts(source: str, limit: int = 10) -> IntegrationRes
605
605
  return IntegrationResult(False, 'Esta conta é privada. O Instagram não disponibiliza posts sem uma sessão autenticada.', reference | {'posts': [], 'is_private': True})
606
606
  if platform.system() == 'Windows':
607
607
  html_posts = api_user.get('_html_posts') or []
608
- return IntegrationResult(bool(html_posts), 'Posts públicos encontrados.' if html_posts else 'Não foi possível encontrar posts públicos nesta página do Instagram.', reference | {'posts': html_posts[:max(1, int(limit))]})
608
+ print(f'Posts no user inicial para @{reference["username"]}: {len(html_posts)}')
609
+ if html_posts:
610
+ return IntegrationResult(True, 'Posts públicos encontrados.', reference | {'posts': html_posts[:max(1, int(limit))]})
609
611
  if platform.system() == 'Windows':
610
612
  html_content = _fetch_instagram_html_with_playwright(reference['url'], reference['username'])
611
- posts = _extract_posts_from_html(html_content, limit) if html_content else []
613
+ html_user = _extract_profile_user_from_html(html_content, reference['username']) if html_content else {}
614
+ media = html_user.get('edge_owner_to_timeline_media') if isinstance(html_user, Mapping) else {}
615
+ edges = media.get('edges') if isinstance(media, Mapping) else []
616
+ print(f'JSON do perfil extraído no Windows para @{reference["username"]}: {bool(html_user)}; edges encontrados: {len(edges or [])}')
617
+ posts: list[dict[str, Any]] = []
618
+ for edge in edges or []:
619
+ node = edge.get('node') if isinstance(edge, Mapping) else edge
620
+ if isinstance(node, dict):
621
+ post = _post_from_node(node)
622
+ if post:
623
+ posts.append(post)
624
+ if not posts:
625
+ posts = _extract_posts_from_html(html_content, limit) if html_content else []
626
+ posts = posts[:max(1, int(limit))]
612
627
  print(f'Posts extraídos no Windows para @{reference["username"]}: {len(posts)}')
613
628
  if not posts and html_content:
614
629
  try:
@@ -618,7 +633,7 @@ def fetch_public_instagram_posts(source: str, limit: int = 10) -> IntegrationRes
618
633
  print(f'HTML de debug dos posts guardado em storage/debug_posts.html para @{reference["username"]}')
619
634
  except OSError as exc:
620
635
  print(f'Não foi possível guardar storage/debug_posts.html: {exc}')
621
- return IntegrationResult(bool(posts), 'Posts públicos encontrados.' if posts else 'Não foi possível encontrar posts públicos nesta página do Instagram.', reference | {'posts': posts[:max(1, int(limit))]})
636
+ return IntegrationResult(bool(posts), 'Posts públicos encontrados.' if posts else 'Não foi possível encontrar posts públicos nesta página do Instagram.', reference | {'posts': posts})
622
637
  try:
623
638
  response = requests.get(reference['url'], headers={'User-Agent': 'Mozilla/5.0', 'Accept-Language': 'pt-BR,pt;q=0.9,en;q=0.8'}, timeout=15)
624
639
  except requests.RequestException as exc:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.6.64",
3
+ "version": "0.6.65",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",