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

scripts/_onetime_rescrub_cookies.py

View on GitHub
#!/usr/bin/env python3
"""ONE-TIME: clear every cookie value in Cookie/Set-Cookie headers, in place.

Re-scrubs the committed corpus for the name-agnostic cookie leak: cookies that
were NOT on the name-anchored allowlist (``_ga`` / ``_ga_<id>`` / ``_gcl_au`` /
``AEC`` / ``SEARCH_SAMESITE`` …) kept their REAL values in committed cassettes.
This walks every ``tests/cassettes/web/*.yaml``, parses it with PyYAML to recover
each request ``Cookie:`` and response ``Set-Cookie:`` header's LOGICAL value,
computes the name-agnostic scrub via ``cassette_patterns.scrub_cookie_header`` /
``scrub_set_cookie``, and splices the cleared ``name=value`` pairs back into the
RAW text by literal substitution.

Why literal raw-text substitution (not yaml.dump round-trip): re-dumping the
whole file would reformat every body scalar and produce a massive noisy diff.
Cookie pairs are verified to never split across a YAML fold boundary in this
corpus, so each ``name=realvalue`` substring is contiguous in the raw text and a
literal replace to ``name=SCRUBBED`` is exact and formatting-preserving. Bodies
and byte-count prefixes are untouched.

Retained as a historical repair utility; use
``tests/scripts/check_cassettes_clean.py`` for ongoing cassette cleanliness
checks.
"""

from __future__ import annotations

import sys
from pathlib import Path

import yaml

try:
    from yaml import CSafeLoader as Loader
except ImportError:  # pragma: no cover
    from yaml import SafeLoader as Loader  # type: ignore[assignment]

_REPO_ROOT = Path(__file__).resolve().parent.parent
_TESTS_DIR = _REPO_ROOT / "tests"
_CASSETTE_DIR = _TESTS_DIR / "cassettes" / "web"
sys.path.insert(0, str(_TESTS_DIR))

from cassette_patterns import (  # noqa: E402
    SCRUB_PLACEHOLDERS,
    find_cookie_leaks,
    scrub_cookie_header,
    scrub_set_cookie,
)


def _pairs(original: str, scrubbed: str) -> list[tuple[str, str]]:
    """Return ``(old_segment, new_segment)`` for each pair the scrub changed.

    Splits the original and scrubbed header value on ``;`` (their segment lists
    are aligned because scrubbing only rewrites VALUES, never the count/order of
    segments) and yields the stripped ``name=value`` pairs that differ.
    """
    out: list[tuple[str, str]] = []
    o_segs = original.split(";")
    s_segs = scrubbed.split(";")
    if len(o_segs) != len(s_segs):
        return out
    for o, s in zip(o_segs, s_segs, strict=True):
        o_core = o.strip()
        s_core = s.strip()
        if o_core != s_core and o_core:
            out.append((o_core, s_core))
    return out


def _rescrub_file(path: Path) -> tuple[bool, int]:
    raw = path.read_text(encoding="utf-8")
    data = yaml.load(raw, Loader=Loader)
    if not isinstance(data, dict):
        return False, 0

    replacements: list[tuple[str, str]] = []
    for interaction in data.get("interactions") or []:
        if not isinstance(interaction, dict):
            continue
        req = interaction.get("request") or {}
        resp = interaction.get("response") or {}
        for hk, hv in (req.get("headers") or {}).items():
            if isinstance(hk, str) and hk.lower() == "cookie":
                vals = hv if isinstance(hv, list) else [hv]
                for v in vals:
                    if isinstance(v, str):
                        replacements.extend(_pairs(v, scrub_cookie_header(v)))
        for hk, hv in (resp.get("headers") or {}).items():
            if isinstance(hk, str) and hk.lower() == "set-cookie":
                vals = hv if isinstance(hv, list) else [hv]
                for v in vals:
                    if isinstance(v, str):
                        replacements.extend(_pairs(v, scrub_set_cookie(v)))

    if not replacements:
        return False, 0

    new_raw = raw
    for old_seg, new_seg in replacements:
        # ``old_seg`` is a contiguous ``name=realvalue`` substring (verified to
        # never split across a fold boundary). Replace ALL occurrences (the same
        # cookie value recurs across every interaction in a cassette).
        if old_seg and old_seg in new_raw:
            new_raw = new_raw.replace(old_seg, new_seg)

    if new_raw == raw:
        return False, 0
    path.write_text(new_raw, encoding="utf-8")
    return True, len(new_raw.encode("utf-8")) - len(raw.encode("utf-8"))


def main(argv: list[str] | None = None) -> int:
    argv = sys.argv[1:] if argv is None else argv
    targets = [Path(p) for p in argv] if argv else sorted(_CASSETTE_DIR.glob("*.yaml"))
    changed = 0
    for path in targets:
        did, diff = _rescrub_file(path)
        if did:
            changed += 1
            print(f"scrubbed  {path.name}  ({diff:+d} bytes)")
    print(f"\nSummary: {changed}/{len(targets)} cassettes re-scrubbed.")

    # Verify: no cookie leak survives in any header of any target.
    residual = 0
    parse_failures = 0
    for path in targets:
        try:
            data = yaml.load(path.read_text(encoding="utf-8"), Loader=Loader)
        except Exception as exc:  # noqa: BLE001
            # A cassette we just rewrote no longer parses as YAML — treat that as
            # a verification failure, not a silent skip, or the script could exit
            # success after producing an unloadable cassette.
            parse_failures += 1
            print(f"FAILED to parse rewritten cassette {path}: {exc}", file=sys.stderr)
            continue
        if not isinstance(data, dict):
            continue
        for interaction in data.get("interactions") or []:
            if not isinstance(interaction, dict):
                continue
            req = interaction.get("request") or {}
            resp = interaction.get("response") or {}
            for hk, hv in (req.get("headers") or {}).items():
                if isinstance(hk, str) and hk.lower() == "cookie":
                    for v in hv if isinstance(hv, list) else [hv]:
                        if isinstance(v, str) and find_cookie_leaks(v):
                            residual += len(find_cookie_leaks(v))
            for hk, hv in (resp.get("headers") or {}).items():
                if isinstance(hk, str) and hk.lower() == "set-cookie":
                    for v in hv if isinstance(hv, list) else [hv]:
                        if isinstance(v, str) and find_cookie_leaks(v, set_cookie=True):
                            residual += len(find_cookie_leaks(v, set_cookie=True))
    print(f"Residual cookie leaks after re-scrub: {residual}")
    if parse_failures:
        print(f"Unparseable cassettes after re-scrub: {parse_failures}", file=sys.stderr)
    print(f"(known placeholders: {sorted(SCRUB_PLACEHOLDERS)[:3]} ...)")
    return 1 if (residual or parse_failures) else 0


if __name__ == "__main__":
    raise SystemExit(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