Skip to content

teng-lin/notebooklm-py

notebooklm

Verified

Install, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API. Do not use for the generic Gemini API or unrelated content creation.

FileKindSize
SKILL.mdskill md16.0 KB
examples/bulk-import.pyscript3.4 KB
examples/chat.pyscript6.9 KB
examples/notes.pyscript9.8 KB
examples/quickstart.pyscript2.3 KB
examples/refresh_browser_cookies.pyscript2.9 KB
examples/research-to-podcast.pyscript3.2 KB
examples/video.pyscript5.9 KB
scripts/__init__.pyscript73 B
scripts/_ci_e2e_notebooks.pyscript19.0 KB
scripts/_ci_progress.pyscript2.5 KB
scripts/_ci_rpc_progress.pyscript7.5 KB
scripts/_live_auth_scenarios/__init__.pyscript2.6 KB
scripts/_live_auth_scenarios/_contract.pyscript1.9 KB
scripts/_live_auth_scenarios/browser_refresh.pyscript3.1 KB
scripts/_live_auth_scenarios/crash_safe_writer.pyscript1.9 KB
scripts/_live_auth_scenarios/master_token_recovery.pyscript3.3 KB
scripts/_live_auth_scenarios/mcp_recovery.pyscript3.0 KB
scripts/_live_auth_scenarios/rest_recovery.pyscript5.9 KB
scripts/_live_auth_scenarios/sibling_concurrent_reload.pyscript3.9 KB
scripts/_live_auth_scenarios/storage_reload.pyscript2.9 KB
scripts/_onetime_rescrub_cookies.pyscript6.6 KB
scripts/_onetime_retarget_cassette_hosts.pyscript8.5 KB
scripts/_strip_audit_refs.pyscript15.9 KB
scripts/_tracked_files.pyscript872 B
scripts/aggregate_ci_e2e_outcomes.pyscript10.8 KB
scripts/android_grpc_canary.pyscript26.6 KB
scripts/api-compat-allowlist.jsonconfig163 B
scripts/audit_auth_import_graph.pyscript7.5 KB
scripts/audit_auth_patch_sites.pyscript83.6 KB
scripts/audit_auth_shared_mutations.pyscript41.7 KB
scripts/audit_backend_coupling.pyscript32.8 KB
scripts/audit_public_api_compat.pyscript47.4 KB
scripts/audit_test_suite.pyscript10.7 KB
scripts/capture_mobile_grpc.jsscript5.1 KB
scripts/capture_rpc_registry.pyscript44.5 KB
scripts/check_action_pinning.pyscript6.7 KB
scripts/check_auth_behavior_scenario_policy.pyscript37.1 KB
scripts/check_auth_coverage_delta.pyscript23.2 KB
scripts/check_auth_lifecycle_cleanup_policy.pyscript11.7 KB
scripts/check_base_wheel.pyscript6.3 KB
scripts/check_ci_install_parity.pyscript8.8 KB
scripts/check_claude_md_freshness.pyscript8.0 KB
scripts/check_coverage_thresholds.pyscript8.4 KB
scripts/check_deprecation_targets.pyscript33.1 KB
scripts/check_docs_module_refs.pyscript14.4 KB
scripts/check_rpc_health.pyscript112.0 KB
scripts/check_workflow_permissions.pyscript5.3 KB
scripts/check_workflow_secret_gates.pyscript40.4 KB
scripts/decode_mobile_grpc.pyscript7.2 KB
scripts/diagnose_get_notebook.pyscript9.1 KB
scripts/extract_blutter_grpc_signatures.pyscript7.6 KB
scripts/live_auth_matrix.pyscript40.2 KB
scripts/manage_ci_e2e_notebooks.pyscript67.4 KB
scripts/materialize_ci_auth.pyscript8.0 KB
scripts/mcp_live_smoke.pyexecutablescript224 B
scripts/parse_pbenums.pyscript8.6 KB
scripts/parse_pbschema.pyscript11.8 KB
scripts/regen_baselines.pyscript2.7 KB
scripts/regenerate_android_protos.pyscript16.3 KB
scripts/rescrub-cassettes.pyscript13.3 KB
scripts/scrub_rpc_har.pyscript9.4 KB
scripts/select_ci_account.pyscript4.8 KB
scripts/stress_fault_server.pyscript20.6 KB
scripts/test_taxonomy_inventory.pyscript16.1 KB
scripts/verify_ci_artifacts.pyscript35.3 KB

examples/video.py

View on GitHub
"""Example: Generate a Video Overview from notebook sources.

This example demonstrates:
1. Setting up a notebook with sources
2. Generating a video overview with style options
3. Checking artifact status
4. Downloading the completed video

Video Overviews are animated explainer videos that summarize your
notebook content with AI-generated narration and visuals.

Prerequisites:
    - Authentication configured via `notebooklm auth` CLI command
    - Valid Google account with NotebookLM access
"""

import asyncio

from notebooklm import NotebookLMClient, VideoFormat, VideoStyle


async def main():
    """Generate a video overview from notebook sources."""

    async with NotebookLMClient.from_storage() as client:
        # Step 1: Create a notebook with content
        print("Creating notebook...")
        notebook = await client.notebooks.create("Video Demo Notebook")
        print(f"Created notebook: {notebook.id}")

        # Add sources for video content
        print("\nAdding sources...")
        urls = [
            "https://en.wikipedia.org/wiki/Quantum_computing",
        ]

        for url in urls:
            source = await client.sources.add_url(notebook.id, url)
            print(f"  Added: {source.title or url}")

        # Wait for source processing
        print("\nWaiting for source processing...")
        await asyncio.sleep(5)

        # Step 2: Generate the video overview
        # Video generation options:
        #
        # video_format:
        #   - EXPLAINER: Full explanatory video (default)
        #   - BRIEF: Shorter summary video
        #   - CINEMATIC: AI-generated documentary footage (Veo 3)
        #   - SHORT: Vertical short-form video (fixed style; no video_style)
        #
        # video_style:
        #   - AUTO_SELECT: Let AI choose the best style (default)
        #   - CUSTOM: Caller-provided style
        #   - CLASSIC: Traditional presentation style
        #   - WHITEBOARD: Whiteboard animation style
        #   - KAWAII: Cute, kawaii-inspired style
        #   - ANIME: Anime visual style
        #   - WATERCOLOR: Watercolor painting style
        #   - RETRO_PRINT: Retro print style
        #   - HERITAGE: Heritage/vintage style
        #   - PAPER_CRAFT: Paper-craft style

        print("\nStarting video generation...")
        print("Video generation typically takes 3-8 minutes")

        generation = await client.artifacts.generate_video(
            notebook.id,
            video_format=VideoFormat.EXPLAINER,
            video_style=VideoStyle.AUTO_SELECT,
            language="en",
            instructions="Create an engaging overview suitable for general audiences",
        )

        print(f"Generation started: {generation.task_id}")
        print(f"Initial status: {generation.status}")

        # Step 3: Wait for completion with status updates
        print("\nWaiting for video generation...")

        try:
            final_status = await client.artifacts.wait_for_completion(
                notebook.id,
                generation.task_id,
                initial_interval=10.0,  # Check every 10 seconds initially
                max_interval=30.0,  # Max 30 seconds between checks
                timeout=900.0,  # 15 minute timeout for videos
            )

            if final_status.is_complete:
                print("\nVideo generation complete!")

                # Step 4: Download the video
                output_path = "quantum_video.mp4"
                print(f"Downloading video to {output_path}...")

                await client.artifacts.download_video(
                    notebook.id,
                    output_path,
                    artifact_id=generation.task_id,
                )
                print(f"Video downloaded: {output_path}")

            elif final_status.is_failed:
                print(f"\nGeneration failed: {final_status.error}")

        except TimeoutError:
            print("\nVideo generation timed out")
            print("Check NotebookLM web UI for completion")

        # =====================================================================
        # Alternative: Check existing artifacts
        # =====================================================================

        print("\n--- Listing All Video Artifacts ---")

        # List all video artifacts in the notebook
        videos = await client.artifacts.list_video(notebook.id)

        for video in videos:
            status = "Ready" if video.is_completed else "Processing"
            print(f"\n  Title: {video.title}")
            print(f"  ID: {video.id}")
            print(f"  Status: {status}")
            if video.created_at:
                print(f"  Created: {video.created_at}")

        # =====================================================================
        # Manual status polling example
        # =====================================================================

        print("\n--- Manual Status Polling ---")

        if generation.task_id:
            # You can manually poll status without wait_for_completion
            status = await client.artifacts.poll_status(
                notebook.id,
                generation.task_id,
            )
            print(f"Current status: {status.status}")
            print(f"Is complete: {status.is_complete}")
            print(f"Is in progress: {status.is_in_progress}")

        # =====================================================================
        # Download existing video
        # =====================================================================

        # If you have an existing completed video, download it directly
        if videos and videos[0].is_completed:
            print("\n--- Downloading Existing Video ---")
            existing_path = "existing_video.mp4"
            await client.artifacts.download_video(
                notebook.id,
                existing_path,
                artifact_id=videos[0].id,
            )
            print(f"Downloaded: {existing_path}")


if __name__ == "__main__":
    asyncio.run(main())
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall