Documentation
¶
Overview ¶
Package api provides the NotebookLM API client.
Package api provides test helpers for debugging and development
Index ¶
- func AssertProjectValid(t *testing.T, p *pb.Project)
- func AssertSourceValid(t *testing.T, s *pb.Source)
- func DebugDirectRequest(t *testing.T)
- func DebugHTTPRecorder(t *testing.T)
- func GenerateMockResponse(rpcID string, data interface{}) string
- func TestDataPath(filename string) string
- type AudioOverviewResult
- type ChunkedResponseParser
- func (p *ChunkedResponseParser) DebugPrint()
- func (p *ChunkedResponseParser) ParseJSONArray() ([]interface{}, error)
- func (p *ChunkedResponseParser) ParseListProjectsResponse() ([]*pb.Project, error)
- func (p *ChunkedResponseParser) SanitizeResponse(input string) string
- func (p *ChunkedResponseParser) TryParseAsJSONArray() ([]interface{}, error)
- func (p *ChunkedResponseParser) WithDebug(debug bool) *ChunkedResponseParser
- type Client
- func (c *Client) ActOnSources(projectID string, action string, sourceIDs []string) error
- func (c *Client) AddSourceFromBase64(projectID string, content, filename, contentType string) (string, error)
- func (c *Client) AddSourceFromFile(projectID string, filepath string, contentType ...string) (string, error)
- func (c *Client) AddSourceFromReader(projectID string, r io.Reader, filename string, contentType ...string) (string, error)
- func (c *Client) AddSourceFromText(projectID string, content, title string) (string, error)
- func (c *Client) AddSourceFromURL(projectID string, url string) (string, error)
- func (c *Client) AddSources(projectID string, sources []*pb.SourceInput) (*pb.Project, error)
- func (c *Client) AddYouTubeSource(projectID, videoID string) (string, error)
- func (c *Client) CheckSourceFreshness(sourceID string) (*pb.CheckSourceFreshnessResponse, error)
- func (c *Client) CreateAudioOverview(projectID string, instructions string) (*AudioOverviewResult, error)
- func (c *Client) CreateNote(projectID string, title string, initialContent string) (*Note, error)
- func (c *Client) CreateProject(title string, emoji string) (*Notebook, error)
- func (c *Client) CreateVideoOverview(projectID string, instructions string) (*VideoOverviewResult, error)
- func (c *Client) DeleteAudioOverview(projectID string) error
- func (c *Client) DeleteNotes(projectID string, noteIDs []string) error
- func (c *Client) DeleteProjects(projectIDs []string) error
- func (c *Client) DeleteSources(projectID string, sourceIDs []string) error
- func (c *Client) DownloadAudioOverview(projectID string) (*AudioOverviewResult, error)
- func (c *Client) DownloadVideoOverview(projectID string) (*VideoOverviewResult, error)
- func (c *Client) DownloadVideoWithAuth(videoURL, filename string) error
- func (c *Client) GenerateDocumentGuides(projectID string) (*pb.GenerateDocumentGuidesResponse, error)
- func (c *Client) GenerateFreeFormStreamed(projectID string, prompt string, sourceIDs []string) (*pb.GenerateFreeFormStreamedResponse, error)
- func (c *Client) GenerateFreeFormStreamedWithCallback(projectID string, prompt string, sourceIDs []string, ...) error
- func (c *Client) GenerateMagicView(projectID string, sourceIDs []string) (*pb.GenerateMagicViewResponse, error)
- func (c *Client) GenerateNotebookGuide(projectID string) (*pb.GenerateNotebookGuideResponse, error)
- func (c *Client) GenerateOutline(projectID string) (*pb.GenerateOutlineResponse, error)
- func (c *Client) GenerateReportSuggestions(projectID string) (*pb.GenerateReportSuggestionsResponse, error)
- func (c *Client) GenerateSection(projectID string) (*pb.GenerateSectionResponse, error)
- func (c *Client) GetAudioOverview(projectID string) (*AudioOverviewResult, error)
- func (c *Client) GetNotes(projectID string) ([]*Note, error)
- func (c *Client) GetProject(projectID string) (*Notebook, error)
- func (c *Client) GetProjectWithContext(ctx context.Context, projectID string) (*Notebook, error)
- func (c *Client) GetVideoOverview(projectID string) (*VideoOverviewResult, error)
- func (c *Client) ListArtifacts(projectID string) ([]*pb.Artifact, error)
- func (c *Client) ListAudioOverviews(projectID string) ([]*AudioOverviewResult, error)
- func (c *Client) ListRecentlyViewedProjects() ([]*Notebook, error)
- func (c *Client) ListVideoOverviews(projectID string) ([]*VideoOverviewResult, error)
- func (c *Client) LoadSource(sourceID string) (*pb.Source, error)
- func (c *Client) MutateNote(projectID string, noteID string, content string, title string) (*Note, error)
- func (c *Client) MutateProject(projectID string, updates *pb.Project) (*Notebook, error)
- func (c *Client) MutateSource(sourceID string, updates *pb.Source) (*pb.Source, error)
- func (c *Client) RefreshSource(sourceID string) (*pb.Source, error)
- func (c *Client) RemoveRecentlyViewedProject(projectID string) error
- func (c *Client) RenameArtifact(artifactID, newTitle string) (*pb.Artifact, error)
- func (c *Client) SetUseDirectRPC(use bool)
- func (c *Client) ShareAudio(projectID string, shareOption ShareOption) (*ShareAudioResult, error)
- func (c *Client) ShareProject(projectID string, settings *pb.ShareSettings) (*pb.ShareProjectResponse, error)
- func (c *Client) StartDraft(projectID string) (*pb.StartDraftResponse, error)
- func (c *Client) StartSection(projectID string) (*pb.StartSectionResponse, error)
- type Note
- type Notebook
- type ShareAudioResult
- type ShareOption
- type VideoOverviewResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertProjectValid ¶
AssertProjectValid validates a project has required fields
func AssertSourceValid ¶
AssertSourceValid validates a source has required fields
func DebugDirectRequest ¶
DebugDirectRequest is a helper function for debugging direct API requests It can be used to test raw batchexecute protocol interactions
func DebugHTTPRecorder ¶
DebugHTTPRecorder is a helper function for debugging HTTP recording issues It can be called from tests when needed for troubleshooting
func GenerateMockResponse ¶
GenerateMockResponse creates a mock batchexecute response for testing
func TestDataPath ¶
TestDataPath returns the path to test data files
Types ¶
type AudioOverviewResult ¶
type AudioOverviewResult struct {
ProjectID string
AudioID string
Title string
AudioData string // Base64 encoded audio data
IsReady bool
}
AudioOverviewResult represents an audio overview response
func (*AudioOverviewResult) GetAudioBytes ¶
func (r *AudioOverviewResult) GetAudioBytes() ([]byte, error)
GetAudioBytes returns the decoded audio data
func (*AudioOverviewResult) SaveAudioToFile ¶
func (r *AudioOverviewResult) SaveAudioToFile(filename string) error
SaveAudioToFile saves audio data to a file
type ChunkedResponseParser ¶
type ChunkedResponseParser struct {
Raw string
Debug bool
// contains filtered or unexported fields
}
ChunkedResponseParser is a specialized parser for NotebookLM's chunked response format which parses the special format used for the ListRecentlyViewedProjects response
func NewChunkedResponseParser ¶
func NewChunkedResponseParser(raw string) *ChunkedResponseParser
NewChunkedResponseParser creates a new parser for the given raw response
func (*ChunkedResponseParser) DebugPrint ¶
func (p *ChunkedResponseParser) DebugPrint()
DebugPrint prints the chunked response analysis for debugging
func (*ChunkedResponseParser) ParseJSONArray ¶
func (p *ChunkedResponseParser) ParseJSONArray() ([]interface{}, error)
ParseJSONArray parses a JSON array from the response with robust error handling
func (*ChunkedResponseParser) ParseListProjectsResponse ¶
func (p *ChunkedResponseParser) ParseListProjectsResponse() ([]*pb.Project, error)
ParseListProjectsResponse extracts projects from the raw response with fallback mechanisms
func (*ChunkedResponseParser) SanitizeResponse ¶
func (p *ChunkedResponseParser) SanitizeResponse(input string) string
SanitizeResponse removes any trailing or invalid content from the response This is particularly useful for handling trailing digits like "25" in the error case
func (*ChunkedResponseParser) TryParseAsJSONArray ¶
func (p *ChunkedResponseParser) TryParseAsJSONArray() ([]interface{}, error)
TryParseAsJSONArray attempts to extract and parse a JSON array from the response This is a fallback approach for the specific error in the requirements
func (*ChunkedResponseParser) WithDebug ¶
func (p *ChunkedResponseParser) WithDebug(debug bool) *ChunkedResponseParser
WithDebug enables debug output for this parser
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles NotebookLM API interactions.
func CreateMockClient ¶
CreateMockClient creates a client configured for testing with mock responses
func New ¶
func New(authToken, cookies string, opts ...batchexecute.Option) *Client
New creates a new NotebookLM API client.
func (*Client) ActOnSources ¶
func (*Client) AddSourceFromBase64 ¶
func (*Client) AddSourceFromFile ¶
func (*Client) AddSourceFromReader ¶
func (*Client) AddSourceFromText ¶
func (*Client) AddSourceFromURL ¶
func (*Client) AddSources ¶
func (*Client) AddYouTubeSource ¶
func (*Client) CheckSourceFreshness ¶
func (c *Client) CheckSourceFreshness(sourceID string) (*pb.CheckSourceFreshnessResponse, error)
func (*Client) CreateAudioOverview ¶
func (c *Client) CreateAudioOverview(projectID string, instructions string) (*AudioOverviewResult, error)
func (*Client) CreateNote ¶
func (*Client) CreateProject ¶
func (*Client) CreateVideoOverview ¶
func (c *Client) CreateVideoOverview(projectID string, instructions string) (*VideoOverviewResult, error)
func (*Client) DeleteAudioOverview ¶
func (*Client) DeleteProjects ¶
func (*Client) DeleteSources ¶
func (*Client) DownloadAudioOverview ¶
func (c *Client) DownloadAudioOverview(projectID string) (*AudioOverviewResult, error)
DownloadAudioOverview attempts to download the actual audio file by trying different request types until it finds one with audio data
func (*Client) DownloadVideoOverview ¶
func (c *Client) DownloadVideoOverview(projectID string) (*VideoOverviewResult, error)
DownloadVideoOverview attempts to download video overview data
func (*Client) DownloadVideoWithAuth ¶
DownloadVideoWithAuth downloads a video using the client's authentication
func (*Client) GenerateDocumentGuides ¶
func (c *Client) GenerateDocumentGuides(projectID string) (*pb.GenerateDocumentGuidesResponse, error)
func (*Client) GenerateFreeFormStreamed ¶
func (*Client) GenerateFreeFormStreamedWithCallback ¶
func (c *Client) GenerateFreeFormStreamedWithCallback(projectID string, prompt string, sourceIDs []string, callback func(chunk string) bool) error
GenerateFreeFormStreamedWithCallback streams the response and calls the callback for each chunk
func (*Client) GenerateMagicView ¶
func (*Client) GenerateNotebookGuide ¶
func (c *Client) GenerateNotebookGuide(projectID string) (*pb.GenerateNotebookGuideResponse, error)
func (*Client) GenerateOutline ¶
func (c *Client) GenerateOutline(projectID string) (*pb.GenerateOutlineResponse, error)
func (*Client) GenerateReportSuggestions ¶
func (c *Client) GenerateReportSuggestions(projectID string) (*pb.GenerateReportSuggestionsResponse, error)
func (*Client) GenerateSection ¶
func (c *Client) GenerateSection(projectID string) (*pb.GenerateSectionResponse, error)
func (*Client) GetAudioOverview ¶
func (c *Client) GetAudioOverview(projectID string) (*AudioOverviewResult, error)
func (*Client) GetProjectWithContext ¶
GetProjectWithContext is like GetProject but accepts a context for cancellation
func (*Client) GetVideoOverview ¶
func (c *Client) GetVideoOverview(projectID string) (*VideoOverviewResult, error)
GetVideoOverview attempts to get a video overview for a notebook Since there's no official GetVideoOverview RPC endpoint, we try alternative approaches
func (*Client) ListArtifacts ¶
ListArtifacts returns artifacts for a project using direct RPC
func (*Client) ListAudioOverviews ¶
func (c *Client) ListAudioOverviews(projectID string) ([]*AudioOverviewResult, error)
ListAudioOverviews returns audio overviews for a notebook
func (*Client) ListRecentlyViewedProjects ¶
func (*Client) ListVideoOverviews ¶
func (c *Client) ListVideoOverviews(projectID string) ([]*VideoOverviewResult, error)
ListVideoOverviews returns video overviews for a notebook
func (*Client) MutateNote ¶
func (*Client) MutateProject ¶
func (*Client) MutateSource ¶
func (*Client) RemoveRecentlyViewedProject ¶
func (*Client) RenameArtifact ¶
RenameArtifact renames an artifact using the rc3d8d RPC endpoint
func (*Client) SetUseDirectRPC ¶
SetUseDirectRPC configures whether to use direct RPC calls
func (*Client) ShareAudio ¶
func (c *Client) ShareAudio(projectID string, shareOption ShareOption) (*ShareAudioResult, error)
ShareAudio shares an audio overview with optional public access
func (*Client) ShareProject ¶
func (c *Client) ShareProject(projectID string, settings *pb.ShareSettings) (*pb.ShareProjectResponse, error)
ShareProject shares a project with specified settings
func (*Client) StartDraft ¶
func (c *Client) StartDraft(projectID string) (*pb.StartDraftResponse, error)
func (*Client) StartSection ¶
func (c *Client) StartSection(projectID string) (*pb.StartSectionResponse, error)
type ShareAudioResult ¶
type ShareAudioResult struct {
}
ShareAudioResult represents the response from sharing audio
type ShareOption ¶
type ShareOption int
ShareOption represents audio sharing visibility options
const ( )
type VideoOverviewResult ¶
type VideoOverviewResult struct {
ProjectID string
VideoID string
Title string
VideoData string // Base64 encoded or URL
IsReady bool
}
func (*VideoOverviewResult) SaveVideoToFile ¶
func (r *VideoOverviewResult) SaveVideoToFile(filename string) error
SaveVideoToFile saves video data to a file Handles both base64 encoded data and URLs NOTE: For URL downloads, use client.DownloadVideoWithAuth() for proper authentication