fmab777 commited on
Commit
71553bb
Β·
verified Β·
1 Parent(s): 94758f8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -5
main.py CHANGED
@@ -598,7 +598,8 @@ async def _run_apify_actor_for_web_content(url: str, api_token: str, actor_id: s
598
  # --- END ADDED PROXY CONFIG ---
599
  }
600
  logger.debug(f"{log_prefix} Using input format for Default YT Actor ({APIFY_ACTOR_ID}) with Residential Proxy")
601
- elif actor_id == APIFY_STRUCTURED_YT_ACTOR_ID:
 
602
  # Input specific to the Structured YT Actor – wrap your single URL in a list
603
  run_input = {
604
  "urls": [url], # ← wrap your URL in a list
@@ -608,10 +609,10 @@ async def _run_apify_actor_for_web_content(url: str, api_token: str, actor_id: s
608
  },
609
  "maxRetries": 5,
610
  }
 
611
  logger.debug(f"{log_prefix} Using list input format for Structured YT Actor ({actor_id}) with Residential Proxy")
612
- # --- END ADDED PROXY CONFIG ---
613
-
614
- logger.debug(f"{log_prefix} Using input format for Structured YT Actor ({APIFY_STRUCTURED_YT_ACTOR_ID}) with Residential Proxy")
615
  elif actor_id == APIFY_TEXT_SCRAPER_ACTOR_ID:
616
  # Input specific to Text Scraper Free (2gbQiRSpJIIag2FdR) - Likely expects LIST
617
  run_input = {
@@ -637,7 +638,7 @@ async def _run_apify_actor_for_web_content(url: str, api_token: str, actor_id: s
637
  # Fallback default input if actor ID doesn't match known ones
638
  run_input = {"urls": [url]} # <<< Default to LIST
639
  logger.warning(f"{log_prefix} Unknown Actor ID '{actor_id}'. Using default input format: {run_input}")
640
-
641
 
642
  headers = {"Content-Type": "application/json"}
643
  try:
@@ -746,6 +747,8 @@ async def _run_apify_actor_for_web_content(url: str, api_token: str, actor_id: s
746
  except httpx.RequestError as e: logger.error(f"{log_prefix} Request error during API interaction for {url}: {e}"); return None
747
  except Exception as e: logger.error(f"{log_prefix} Unexpected error during {actor_name} call for {url}: {e}", exc_info=True); return None
748
 
 
 
749
 
750
  async def get_website_content_via_apify_crawler(url: str, api_token: str) -> Optional[str]:
751
  """Fallback 4: Fetches website content using Apify Website Content Crawler."""
 
598
  # --- END ADDED PROXY CONFIG ---
599
  }
600
  logger.debug(f"{log_prefix} Using input format for Default YT Actor ({APIFY_ACTOR_ID}) with Residential Proxy")
601
+ # --- CORRECTED BLOCK START (Ensure this 'elif' has same indentation as the 'if' above) ---
602
+ elif actor_id == APIFY_STRUCTURED_YT_ACTOR_ID:
603
  # Input specific to the Structured YT Actor – wrap your single URL in a list
604
  run_input = {
605
  "urls": [url], # ← wrap your URL in a list
 
609
  },
610
  "maxRetries": 5,
611
  }
612
+ # Log using the actor_id variable passed into the function
613
  logger.debug(f"{log_prefix} Using list input format for Structured YT Actor ({actor_id}) with Residential Proxy")
614
+ # --- END ADDED PROXY CONFIG ---
615
+ # (Extra brace and redundant logger call removed from here)
 
616
  elif actor_id == APIFY_TEXT_SCRAPER_ACTOR_ID:
617
  # Input specific to Text Scraper Free (2gbQiRSpJIIag2FdR) - Likely expects LIST
618
  run_input = {
 
638
  # Fallback default input if actor ID doesn't match known ones
639
  run_input = {"urls": [url]} # <<< Default to LIST
640
  logger.warning(f"{log_prefix} Unknown Actor ID '{actor_id}'. Using default input format: {run_input}")
641
+ # --- END OF if/elif/else block for run_input ---
642
 
643
  headers = {"Content-Type": "application/json"}
644
  try:
 
747
  except httpx.RequestError as e: logger.error(f"{log_prefix} Request error during API interaction for {url}: {e}"); return None
748
  except Exception as e: logger.error(f"{log_prefix} Unexpected error during {actor_name} call for {url}: {e}", exc_info=True); return None
749
 
750
+ # ... (Rest of your main.py code below this function) ...
751
+
752
 
753
  async def get_website_content_via_apify_crawler(url: str, api_token: str) -> Optional[str]:
754
  """Fallback 4: Fetches website content using Apify Website Content Crawler."""