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/select_ci_account.py

View on GitHub
#!/usr/bin/env python3
"""Select one opaque CI account slot without reading any credentials."""

from __future__ import annotations

import argparse
import json
import sys
from datetime import date
from pathlib import Path

SCHEMA_VERSION = 1
ALLOWED_SLOTS = ("A", "B", "C")
LANE_OFFSETS = {
    "nightly-web-ubuntu": 0,
    "nightly-android-macos": 1,
    "nightly-readonly-windows": 2,
    "rpc-health-web": 2,
    "rpc-health-android": 3,
    "verify-package": 0,
}
_EPOCH = date(1970, 1, 1)


class ConfigurationError(ValueError):
    """The non-secret pool configuration is invalid."""


def utc_epoch_day(value: str) -> int:
    """Return the zero-based UTC epoch day for an ISO calendar date."""
    try:
        parsed = date.fromisoformat(value)
    except (TypeError, ValueError) as exc:
        raise ConfigurationError("rotation day must be an ISO date (YYYY-MM-DD)") from exc
    return (parsed - _EPOCH).days


def parse_enabled_slots(value: str | None) -> tuple[str, ...]:
    """Parse the exact ordered subset of compile-time account aliases."""
    if value is None or not value:
        raise ConfigurationError("NOTEBOOKLM_CI_ACCOUNT_SLOTS is missing or empty")
    # The longest valid spelling is A,B,C. This also rejects whitespace damage
    # before splitting, without accepting a potentially surprising normalization.
    if len(value) > len(",".join(ALLOWED_SLOTS)) or any(char.isspace() for char in value):
        raise ConfigurationError("enabled slots contain whitespace or are overlong")
    slots = value.split(",")
    if any(not slot for slot in slots):
        raise ConfigurationError("enabled slots contain an empty member")
    if any(slot not in ALLOWED_SLOTS for slot in slots):
        raise ConfigurationError("enabled slots must be an ordered subset of A,B,C")
    if len(set(slots)) != len(slots):
        raise ConfigurationError("enabled slots must be distinct")
    canonical_order = tuple(slot for slot in ALLOWED_SLOTS if slot in slots)
    if tuple(slots) != canonical_order:
        raise ConfigurationError("enabled slots must preserve A,B,C order")
    return tuple(slots)


def select_account(
    *,
    enabled_slots: str | None,
    lane: str,
    rotation_day: str,
    manual_base: str = "auto",
) -> dict[str, str]:
    """Return the stable four-field selection record."""
    slots = parse_enabled_slots(enabled_slots)
    if lane not in LANE_OFFSETS:
        raise ConfigurationError("lane is not allowlisted")
    day = utc_epoch_day(rotation_day)
    if manual_base == "auto":
        base_index = day % len(slots)
    else:
        if manual_base not in ALLOWED_SLOTS:
            raise ConfigurationError("manual base must be auto, A, B, or C")
        if manual_base not in slots:
            raise ConfigurationError("manual base slot is not enabled")
        base_index = slots.index(manual_base)
    selected = slots[(base_index + LANE_OFFSETS[lane]) % len(slots)]
    return {
        "account_slot": selected,
        "master_token_secret_name": f"NOTEBOOKLM_MASTER_TOKEN_JSON_{selected}",
        "lane": lane,
        "rotation_day": rotation_day,
    }


def append_github_output(path: Path, record: dict[str, str]) -> None:
    """Append the allowlisted record to an explicitly named GitHub output file."""
    with path.open("a", encoding="utf-8", newline="\n") as stream:
        for key in (
            "account_slot",
            "master_token_secret_name",
            "lane",
            "rotation_day",
        ):
            stream.write(f"{key}={record[key]}\n")


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--enabled-slots", required=True)
    parser.add_argument("--lane", required=True, choices=tuple(LANE_OFFSETS))
    parser.add_argument("--rotation-day", required=True)
    parser.add_argument("--manual-base", default="auto", choices=("auto", *ALLOWED_SLOTS))
    parser.add_argument("--github-output", type=Path)
    parser.add_argument("--json", action="store_true", help="emit compact JSON on stdout")
    return parser


def main(argv: list[str] | None = None) -> int:
    args = build_parser().parse_args(argv)
    try:
        record = select_account(
            enabled_slots=args.enabled_slots,
            lane=args.lane,
            rotation_day=args.rotation_day,
            manual_base=args.manual_base,
        )
        if args.github_output is not None:
            append_github_output(args.github_output, record)
    except (ConfigurationError, OSError) as exc:
        print(f"configuration error: {exc}", file=sys.stderr)
        return 2
    if args.json:
        print(json.dumps(record, separators=(",", ":"), sort_keys=True))
    else:
        print(
            f"Selected account slot {record['account_slot']} for {record['lane']} "
            f"on {record['rotation_day']}"
        )
    return 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