feat(youtube): extract transcript highlights like Reddit comment gems
Add extract_transcript_highlights() that scores sentences by specificity (numbers, proper nouns, topic relevance) and filters YouTube filler (subscribe, welcome back, etc). Top 5 highlights shown as structured bullets in compact output. Full transcript moved to collapsible <details> block so the LLM reads highlights first, full text on demand. SKILL.md updated to instruct the judge agent to quote highlights directly in synthesis, same as Reddit top comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -45,5 +45,36 @@ class TestYtDlpFlags(unittest.TestCase):
|
||||
self.assertIn("--no-cookies-from-browser", cmd)
|
||||
|
||||
|
||||
class TestExtractTranscriptHighlights(unittest.TestCase):
|
||||
def test_extracts_specific_sentences(self):
|
||||
transcript = (
|
||||
"Hey guys welcome back to the channel. "
|
||||
"In today's video we're looking at something special. "
|
||||
"The Lego Bugatti Chiron took 13,438 hours to build with over 1 million pieces. "
|
||||
"Don't forget to subscribe and hit the bell. "
|
||||
"The tolerance on each brick is 0.002 millimeters which is insane for injection molding. "
|
||||
"So yeah that's pretty cool. "
|
||||
"Thanks for watching see you next time."
|
||||
)
|
||||
highlights = youtube_yt.extract_transcript_highlights(transcript, "Lego")
|
||||
self.assertTrue(len(highlights) > 0)
|
||||
# Should pick the sentences with numbers and topic relevance, not filler
|
||||
joined = " ".join(highlights)
|
||||
self.assertIn("13,438", joined)
|
||||
self.assertNotIn("subscribe", joined)
|
||||
self.assertNotIn("welcome back", joined)
|
||||
|
||||
def test_empty_transcript(self):
|
||||
self.assertEqual(youtube_yt.extract_transcript_highlights("", "test"), [])
|
||||
|
||||
def test_respects_limit(self):
|
||||
sentences = ". ".join(
|
||||
f"The model {i} has {i * 100} parameters and runs at {i * 10} tokens per second"
|
||||
for i in range(20)
|
||||
) + "."
|
||||
highlights = youtube_yt.extract_transcript_highlights(sentences, "model", limit=3)
|
||||
self.assertEqual(len(highlights), 3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user