fix: parse YouTube source URLs from notebook metadata#266
fix: parse YouTube source URLs from notebook metadata#266voidborne-d wants to merge 4 commits intoteng-lin:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds language and instruction parameters to mind-map generation (exposed in the CLI) and centralizes source URL extraction to correctly handle YouTube metadata, with tests covering both changes. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Client as Client (sync/async)
participant Artifacts as ArtifactsAPI
participant Core as Core RPC
CLI->>Client: invoke generate mind-map (description, --language)
Client->>Artifacts: artifacts.generate_mind_map(notebook_id, source_ids, language, instructions)
Artifacts->>Core: rpc_call("GENERATE_MINDMAP", ... , config_with_language_and_context)
Core->>Backend: process mind-map request
Backend-->>Core: mind-map result
Core-->>Artifacts: rpc response
Artifacts-->>Client: returns result
Client-->>CLI: output result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/test_source_status.py`:
- Around line 235-265: Add a focused unit test that directly exercises
Source.from_api_response to ensure YouTube URL extraction from metadata[5][0] is
correct: construct a minimal API response object matching the shape used in
tests (with metadata slot index 5 containing ["https://youtube.com/watch?v=abc",
"abc", "Channel"]), call Source.from_api_response(...) (or the
classmethod/constructor used) and assert the returned Source instance has url ==
"https://youtube.com/watch?v=abc" and kind == "youtube"; reference
Source.from_api_response and the Source class to locate the code to test and
reuse the same SourceStatus/structure as other tests for consistency.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 120d247a-573a-4bf4-968f-4441b978774d
📒 Files selected for processing (7)
src/notebooklm/_artifacts.pysrc/notebooklm/_sources.pysrc/notebooklm/cli/generate.pysrc/notebooklm/types.pytests/unit/cli/test_generate.pytests/unit/test_source_selection.pytests/unit/test_source_status.py
There was a problem hiding this comment.
Code Review
This pull request enhances the mind map generation functionality by adding support for custom instructions and language selection across the API and CLI. It also refactors source URL extraction into a centralized helper function, _extract_source_url, to consistently handle different metadata structures for web, PDF, and YouTube sources. Corresponding unit tests have been added to verify the new parameters and the improved URL parsing logic. I have no feedback to provide as there were no review comments to assess.
Summary
metadata[5][0], while keeping the existing web/PDF and flat fallbacksSourcesAPI.list()for YouTube metadataTesting
PYTHONPATH=src python3 -m pytest tests/unit/test_source_status.py -k youtube_metadata_slotCloses #265
Summary by CodeRabbit
New Features
Bug Fixes
Tests