internal

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://www.goodreads.com"

Variables

This section is empty.

Functions

func AddToShelf

func AddToShelf(b *Browser, bookID string, shelfName string) error

AddToShelf navigates to a book page and adds it to the specified shelf.

func ConfigPath

func ConfigPath() string

func Login

func Login(b *Browser, cfg *Config) error

Login authenticates with Goodreads via Amazon's OpenID flow using rod.

func Logout

func Logout() error

Logout removes the session file.

func MarkCurrentlyReading

func MarkCurrentlyReading(b *Browser, bookID string) error

MarkCurrentlyReading adds a book to the "currently-reading" shelf.

func MarkRead

func MarkRead(b *Browser, bookID string) error

MarkRead adds a book to the "read" shelf.

func PostNewTopic

func PostNewTopic(b *Browser, topicURL string, subject string, message string, bookID string, authorID string) error

PostNewTopic creates a new discussion topic in a Goodreads group. The topicURL should be the full new-topic URL including context_id, context_type, and folder_id.

func PostReply

func PostReply(b *Browser, topicID string, message string, bookID string, authorID string) error

PostReply posts a comment to an existing Goodreads discussion topic.

func SessionPath

func SessionPath() string

Types

type Book

type Book struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Author      string `json:"author"`
	Rating      string `json:"rating"`
	URL         string `json:"url"`
	ImageURL    string `json:"image_url"`
	Description string `json:"description"`
}

type Browser

type Browser struct {
	Rod  *rod.Browser
	Page *rod.Page
}

Browser wraps a rod browser and page for Goodreads interactions.

func NewBrowser

func NewBrowser(headless bool) (*Browser, error)

NewBrowser launches a Chrome instance and navigates to goodreads.com. Set headless to false to see the browser for debugging.

func (*Browser) Close

func (b *Browser) Close()

Close cleans up the browser.

func (*Browser) IsLoggedIn

func (b *Browser) IsLoggedIn() bool

IsLoggedIn checks if the user is logged in by looking for user-specific elements.

func (*Browser) LoadCookies

func (b *Browser) LoadCookies() error

LoadCookies loads cookies from the session file into the browser.

func (*Browser) SaveCookies

func (b *Browser) SaveCookies() error

SaveCookies persists browser cookies to the session file.

type Client

type Client struct {
	HTTP *http.Client
}

Client is a plain HTTP client for operations that don't need a browser (e.g. search).

func NewClient

func NewClient() (*Client, error)

NewClient creates a new HTTP client, loading cookies from the rod session file if available.

func (*Client) Search

func (c *Client) Search(query string) ([]Book, error)

Search calls the Goodreads autocomplete endpoint and returns matching books.

type Config

type Config struct {
	Email    string `yaml:"email"`
	Password string `yaml:"password"`
}

func LoadConfig

func LoadConfig() (*Config, error)

type ReadingProgress

type ReadingProgress struct {
	BookID      string `json:"book_id"`
	CurrentPage int    `json:"current_page"`
	TotalPages  int    `json:"total_pages"`
	Percent     int    `json:"percent"`
}

type Shelf

type Shelf struct {
	Name      string `json:"name"`
	BookCount int    `json:"book_count"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL