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, bookTitle string, bookAuthor *string) (Book, error)
- func (c *Client) GetBooksByIds(ctx context.Context, bookIds []string) ([]Book, error)
- func (c *Client) SearchBooks(ctx context.Context, bookTitle string, bookAuthor *string) ([]Book, error)
- func (c *Client) URL() *url.URL
- type Edition
- type Genres
- type Series
- type SeriesBook
- type Work
Constants ¶
View Source
const ( DefaultGoodreadsUrl = "https://www.goodreads.com" DefaultAPIKey = "ckvsiSDsuqh7omh74ZZ6Q" // Read only API key kindly provided by LazyLibrarian )
Variables ¶
View Source
var ( DefaultClient = &Client{ client: http.DefaultClient, goodreadsUrl: utils.CloneURL(defaultGoodreadsUrl), apiKey: DefaultAPIKey, } BookSearchTypeTitle = bookSearchTypeEnum.Add(BookSearchType{"title"}) BookSearchTypeAuthor = bookSearchTypeEnum.Add(BookSearchType{"author"}) BookSearchTypes = bookSearchTypeEnum.Enum() )
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"`
Title string `xml:"title"`
Author string `xml:"author>name"`
}
func (*BookOverview) Sanitise ¶
func (b *BookOverview) Sanitise()
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 ¶
func (c *Client) GetBookByTitle(ctx context.Context, bookTitle string, bookAuthor *string) (Book, error)
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 ¶
func (c *Client) SearchBooks(ctx context.Context, bookTitle string, bookAuthor *string) ([]Book, error)
SearchBooks search for a book by its title and optionally an author (which can give better results) https://www.goodreads.com/api/index#search.books
type Edition ¶
type Edition struct {
Id string `xml:"id"`
ISBN *string `xml:"isbn13"`
Title 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 string `xml:"publication_year"`
PublicationMonth string `xml:"publication_month"`
PublicationDay string `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 {
Title 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"`
}
func (Work) AverageRating ¶
Click to show internal directories.
Click to hide internal directories.