Add add_sources.py: create a notebook & bulk-upload local sources#43
Open
Gavin-Thomas wants to merge 1 commit into
Open
Add add_sources.py: create a notebook & bulk-upload local sources#43Gavin-Thomas wants to merge 1 commit into
Gavin-Thomas wants to merge 1 commit into
Conversation
…urces The skill could authenticate and query notebooks, and notebook_manager.py registers an existing notebook URL in the local library — but there was no way to *create* a notebook or upload sources (SKILL.md notes "manual upload required"). add_sources.py closes that loop. - Reuses the authenticated persistent profile via BrowserFactory, so it works right after `auth_manager.py setup`. - Creates a new notebook and bulk-uploads every .txt/.md/.pdf in a directory in a single input[type=file] call, then renames the notebook and prints the URL. - Rename uses NotebookLM's <input class="title-input"> via fill()+Tab, avoiding the macOS Ctrl+A select-all pitfall. - Defensive: fallback locators, --probe to inspect the UI, --headless, --keep-open, --rename-only, and step screenshots saved to data/shots/. - No new dependencies; no changes to existing scripts; data/ untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
scripts/add_sources.py— create a new NotebookLM notebook and bulk-upload local source files, end to end, from the CLI.Why
Today the skill can authenticate and query notebooks, and
notebook_manager.py addregisters an existing notebook URL in the local library — but there's no way to create a notebook or upload sources.SKILL.mdexplicitly says "Manual upload required (user must add docs to NotebookLM)." This closes that loop, so the full workflow (create → upload → register → query) runs without leaving the CLI.How it works
BrowserFactory.launch_persistent_context, so it works immediately afterauth_manager.py setup(same hybrid-auth / cookie-injection path as the rest of the skill)..txt/.md/.pdffiles in--sources-dirin a singleinput[type=file]call (NotebookLM supports multi-file upload).<input class="title-input">; it is set with Playwrightfill()(clears + dispatches the input event Angular needs) followed byTabto commit — avoiding the macOSCtrl+Aselect-all pitfall.NOTEBOOK_URL:so the caller can immediatelynotebook_manager.py addit.Robustness / safety
--probeopens the home page, screenshots, and dumps clickable labels to help adapt selectors if Google's UI shifts.--headless,--keep-open,--rename-only <url>,--timeout-s.data/shots/for verification/debugging.patchright+config/browser_utils), no changes to existing scripts, and nothing underdata/is touched or committed.Usage
python scripts/run.py add_sources.py --sources-dir ./sources --name "My Docs"Docs
README updated: Quick Start step 3 now shows an automated option, the commands table and architecture diagram list the script, and the "manual upload" limitation note is updated.
Testing
Verified end-to-end on macOS (real Chrome, Python 3.12): created a notebook, bulk-uploaded 13
.txtsources (confirmed the "(13)" source count in NotebookLM), renamed it, registered it vianotebook_manager.py, and queried it successfully viaask_question.py.🤖 Generated with Claude Code