AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix: simplify youtube quality nudge checks
Trevin Chowd3b0a45a9418
diff --git a/skills/last30days/scripts/lib/quality_nudge.py b/skills/last30days/scripts/lib/quality_nudge.pyindex bea8b8fe..8559d913 100644--- a/skills/last30days/scripts/lib/quality_nudge.py+++ b/skills/last30days/scripts/lib/quality_nudge.py@@ -56,9 +56,8 @@ def _youtube_returned_data(research_results: dict) -> bool:return videos > 0 or transcripts > 0-def _is_youtube_active(config: dict, research_results: dict) -> bool:+def _is_youtube_active(config: dict, research_results: dict, *, has_ytdlp: bool) -> bool:"""Check if YouTube source is active (yt-dlp installed)."""- has_ytdlp = _has_ytdlp()if not has_ytdlp:return Falseif research_results.get("youtube_error"):@@ -188,8 +187,8 @@ def compute_quality_score(config: dict, research_results: dict) -> dict:core_errored.append("x")# YouTube- yt_active = _is_youtube_active(config, research_results)has_ytdlp = _has_ytdlp()+ yt_active = _is_youtube_active(config, research_results, has_ytdlp=has_ytdlp)youtube_returned_data = _youtube_returned_data(research_results)if yt_active:core_active.append("youtube")@@ -205,9 +204,10 @@ def compute_quality_score(config: dict, research_results: dict) -> dict:# local free yt-dlp lane is unavailable. Count the source as present,# but surface it as degraded so users do not see the contradictory# "Missing: YouTube" ending after a report with YouTube evidence.+ # has_ytdlp is provably False here: yt_active is False and youtube_error+ # is excluded by this guard, leaving unavailable yt-dlp as the cause.core_active.append("youtube")- if not has_ytdlp:- core_degraded.append("youtube")+ core_degraded.append("youtube")else:core_missing.append("youtube")# Check if configured but errored (yt-dlp installed but failed this run)@@ -231,6 +231,7 @@ def compute_quality_score(config: dict, research_results: dict) -> dict:has_sc=has_sc,active_sources=active_sources,bonus_errored=bonus_errored,+ has_ytdlp=has_ytdlp,) if (core_missing or core_degraded or bonus_errored) else Nonereturn {@@ -252,6 +253,7 @@ def _build_nudge_text(has_sc: bool = False,active_sources: list = None,bonus_errored: List[str] = None,+ has_ytdlp: bool = False,) -> str:"""Build human-readable nudge text describing what was missed or degraded.@@ -316,7 +318,7 @@ def _build_nudge_text(videos = int(research_results.get("youtube_videos_count") or 0)transcripts = int(research_results.get("youtube_transcripts_count") or 0)captions_disabled = int(research_results.get("youtube_captions_disabled_count") or 0)- if not _has_ytdlp() and _youtube_returned_data(research_results):+ if not has_ytdlp and _youtube_returned_data(research_results):free_suggestions.append(f"YouTube returned {videos} videos and {transcripts} transcripts ""through a fallback/provider path, but local yt-dlp is not "diff --git a/tests/test_quality_nudge.py b/tests/test_quality_nudge.pyindex 8008e68c..7f7b9566 100644--- a/tests/test_quality_nudge.py+++ b/tests/test_quality_nudge.py@@ -210,6 +210,21 @@ class TestYouTubeFallbackProvider:assert "local yt-dlp is not installed" in q["nudge_text"]assert "stale yt-dlp" not in q["nudge_text"].lower()+ def test_ytdlp_install_check_runs_once_per_score(self):+ from lib.quality_nudge import compute_quality_score+ from lib import youtube_yt++ with patch.object(youtube_yt, "is_ytdlp_installed", return_value=False) as ytdlp_check:+ compute_quality_score(+ _base_config(AUTH_TOKEN="tok123"),+ _base_results(+ youtube_videos_count=5,+ youtube_transcripts_count=4,+ ),+ )++ ytdlp_check.assert_called_once()+def test_no_fallback_data_without_ytdlp_still_missing(self):q = _compute(config_overrides={"SCRAPECREATORS_API_KEY": "sc_key"},