Documentation
¶
Index ¶
- Constants
- Variables
- func BookIds(books []BookOverview) []string
- func BookTitles(books []BookOverview) []string
- type AuthorDetails
- type AuthorSummary
- type Book
- type BookOverview
- type BookSearchType
- type Client
- func (c *Client) GetBookById(ctx context.Context, bookId string) (Book, error)
- func (c *Client) GetBookByTitle(ctx context.Context, title string, author *string) (Book, error)
- func (c *Client) GetBooksByIds(ctx context.Context, bookIds []string) ([]Book, error)
- func (c *Client) SearchBooks(ctx context.Context, title string, author *string) ([]Book, error)
- func (c *Client) URL() *url.URL
- type Edition
- type Genres
- type Series
- type SeriesBook
- type Work
Constants ¶
const ( DefaultGoodreadsUrl = "https://www.goodreads.com" DefaultAPIKey = "ckvsiSDsuqh7omh74ZZ6Q" // Read only API key kindly provided by LazyLibrarian )
Variables ¶
var ( BookSearchTypeTitle = bookSearchTypeEnum.Add(BookSearchType{"title"}) BookSearchTypeAuthor = bookSearchTypeEnum.Add(BookSearchType{"author"}) BookSearchTypeAll = bookSearchTypeEnum.Add(BookSearchType{"all"}) BookSearchTypes = bookSearchTypeEnum.Enum() )
var ( DefaultClient = &Client{ client: http.DefaultClient, goodreadsUrl: utils.CloneURL(defaultGoodreadsUrl), apiKey: DefaultAPIKey, } )
Functions ¶
func BookIds ¶
func BookIds(books []BookOverview) []string
func BookTitles ¶
func BookTitles(books []BookOverview) []string
Types ¶
type AuthorDetails ¶
type AuthorDetails struct { Role string `xml:"role"` ImageURL string `xml:"image_url"` SmallImageURL string `xml:"small_image_url"` Link string `xml:"link"` AverageRating string `xml:"average_rating"` RatingsCount string `xml:"ratings_count"` TextReviewsCount string `xml:"text_reviews_count"` // contains filtered or unexported fields }
type AuthorSummary ¶
type AuthorSummary struct {
// contains filtered or unexported fields
}
type Book ¶
type Book struct { Work Work `xml:"work"` BestEdition Edition // Unmarshalled using the custom unmarshaler below Authors []AuthorDetails `xml:"authors>author"` Series []SeriesBook `xml:"series_works>series_work"` Genres Genres `xml:"popular_shelves"` // The first "genre" shelves }
func (*Book) UnmarshalXML ¶
type BookOverview ¶
type BookOverview struct { Id string `xml:"id"` FullTitle string `xml:"title"` Author string `xml:"author>name"` }
func (BookOverview) Subtitle ¶ added in v0.2.0
func (o BookOverview) Subtitle() string
Subtitle is the subtitle part of the full title with any series removed.
func (BookOverview) Title ¶
func (o BookOverview) Title() string
Title is the full title with any subtitle and series removed.
type BookSearchType ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates a new goodreads client. If client is nil, the default http client will be used. If goodreads url is nil or unset, the default goodreads url will be used. Will return an error if the goodreads url is invalid.
func (*Client) GetBookById ¶
GetBookById gets a book by its id. https://www.goodreads.com/api/index#book.show
func (*Client) GetBookByTitle ¶
GetBookByTitle gets a book by its title and optionally an author (which can give a better match) https://www.goodreads.com/api/index#book.title
func (*Client) GetBooksByIds ¶
func (*Client) SearchBooks ¶
SearchBooks search for a book by its title and optionally an author (which can give better ordered results). Returns the first 10 pages of books. See: https://www.goodreads.com/api/index#search.books
type Edition ¶
type Edition struct { Id string `xml:"id"` ISBN *string `xml:"isbn13"` FullTitle string `xml:"title"` Description string `xml:"description"` NumPages string `xml:"num_pages"` ImageURL string `xml:"image_url"` URL string `xml:"url"` Format string `xml:"format"` PublicationYear int `xml:"publication_year"` PublicationMonth int `xml:"publication_month"` PublicationDay int `xml:"publication_day"` Publisher string `xml:"publisher"` CountryCode string `xml:"country_code"` Language string `xml:"language_code"` }
type Series ¶
type SeriesBook ¶
func (*SeriesBook) Sanitise ¶
func (s *SeriesBook) Sanitise()
type Work ¶
type Work struct { FullTitle string `xml:"original_title"` MediaType string `xml:"media_type"` EditionsCount int `xml:"books_count"` // Publication PublicationYear int `xml:"original_publication_year"` PublicationMonth int `xml:"original_publication_month"` PublicationDay int `xml:"original_publication_day"` // Ratings RatingsSum int `xml:"ratings_sum"` RatingsCount int `xml:"ratings_count"` ReviewsCount int `xml:"text_reviews_count"` RatingDistribution string `xml:"rating_dist"` }