@danhachuel/thunderbolt 0.6.68 → 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
- headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/131.0 Safari/537.36'
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,38 +599,6 @@ def _post_from_node(node: dict[str, Any]) -> dict[str, Any] | None:
585
599
  }
586
600
 
587
601
 
588
- def _fetch_posts_with_instaloader(username: str, limit: int = 10) -> list[dict[str, Any]]:
589
- """Obtém os posts mais recentes de um perfil público usando Instaloader."""
590
- print(f'Instaloader: tentando obter posts de @{username}')
591
- try:
592
- import instaloader
593
-
594
- loader = instaloader.Instaloader()
595
- profile = instaloader.Profile.from_username(loader.context, username)
596
- posts: list[dict[str, Any]] = []
597
- for post in profile.get_posts():
598
- if len(posts) >= max(1, int(limit)):
599
- break
600
- timestamp = post.date_utc.timestamp() if post.date_utc else ''
601
- post_url = str(post.url or '').strip()
602
- shortcode = str(post.shortcode or '').strip()
603
- posts.append({
604
- 'id': post.mediaid,
605
- 'shortcode': shortcode,
606
- 'url': f'https://www.instagram.com/p/{shortcode}/' if shortcode else post_url,
607
- 'image_url': post_url,
608
- 'display_url': post_url,
609
- 'caption': str(post.caption or '').strip(),
610
- 'published_at': timestamp,
611
- 'timestamp': timestamp,
612
- 'is_video': bool(getattr(post, 'is_video', False)),
613
- })
614
- print(f'Instaloader: {len(posts)} posts encontrados para @{username}')
615
- return posts
616
- except Exception as exc:
617
- print(f'Instaloader falhou para @{username}: {exc}')
618
- return []
619
-
620
602
 
621
603
  def _fetch_posts_with_ytdlp(username: str, limit: int = 10) -> list[dict[str, Any]]:
622
604
  """Fetch public Instagram post metadata with the installed yt-dlp CLI."""
@@ -672,13 +654,7 @@ def fetch_public_instagram_posts(source: str, limit: int = 10) -> IntegrationRes
672
654
  except ValueError as exc:
673
655
  return IntegrationResult(False, str(exc), {})
674
656
  if platform.system() == 'Windows':
675
- instaloader_posts = _fetch_posts_with_instaloader(reference['username'], limit)
676
- if instaloader_posts:
677
- return IntegrationResult(True, f'{len(instaloader_posts)} posts obtidos via Instaloader', reference | {'posts': instaloader_posts})
678
- ytdlp_posts = _fetch_posts_with_ytdlp(reference['username'], limit)
679
- print(f'yt-dlp posts retornados para @{reference["username"]}: {len(ytdlp_posts)}')
680
- if ytdlp_posts:
681
- 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"]}')
682
658
  api_user = _fetch_web_profile_user(reference['username'])
683
659
  if api_user:
684
660
  api_posts: list[dict[str, Any]] = []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.6.68",
3
+ "version": "0.6.69",
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",
package/requirements.txt CHANGED
@@ -17,7 +17,6 @@ mlxtend>=0.23,<1
17
17
  plotly>=5.18,<7
18
18
  seaborn>=0.13,<1
19
19
  yt-dlp[default]>=2025.1.15,<2027
20
- instaloader>=4.14,<5
21
20
  deno>=2.3,<3
22
21
  youtube-transcript-api>=1.2.0,<2
23
22
  ytmusicapi>=1.12,<2
@@ -481,7 +481,7 @@ function writeSettings(moneyprinterPath) {
481
481
 
482
482
  function installThunderboltDependencies(python) {
483
483
  if (!existsSync(pythonBin)) run(python.command, [...python.args, "-m", "venv", venvPath]);
484
- installRequirementIfNeeded(join(root, "requirements.txt"), "thunderbolt_requirements_sha256", ["streamlit", "requests", "pandas", "toml", "imageio_ffmpeg", "edge_tts", "google.auth", "google_auth_oauthlib", "googleapiclient", "yt_dlp", "instaloader", "deno", "youtube_transcript_api", "huggingface_hub", "playwright"], "Thunderbolt");
484
+ installRequirementIfNeeded(join(root, "requirements.txt"), "thunderbolt_requirements_sha256", ["streamlit", "requests", "pandas", "toml", "imageio_ffmpeg", "edge_tts", "google.auth", "google_auth_oauthlib", "googleapiclient", "yt_dlp", "deno", "youtube_transcript_api", "huggingface_hub", "playwright"], "Thunderbolt");
485
485
  installPlaywrightBrowsers();
486
486
  }
487
487