Documentation
¶
Index ¶
- Constants
- Variables
- func NewTSVWriter(w io.Writer) (writer *csv.Writer)
- func ReplaceCamelCase(fileName string) string
- func ReplaceUnderscore(fileName string) (string, bool)
- func ReplaceWS(fileName string) (string, bool)
- func TrimSuffix(fileName string) string
- func WriteOLTSV(outputFile string, responses []OLResponse) error
- type Docs
- type OLResponse
Constants ¶
const OpenLibURI = "https://openlibrary.org/search.json"
Variables ¶
var CommonSuffixes = []string{".cbr",
".cbz",
".cb7",
".epub",
".mobi",
".pdf",
".txt",
".zip"}
CommonSuffixes contains some ebook suffixes
Functions ¶
func NewTSVWriter ¶
NewTSVWriter creates a new TSV writer
func ReplaceCamelCase ¶
ReplaceCamelCase reads a string and adds a "+" after each capital letter and returns the string
func ReplaceUnderscore ¶
ReplaceUnderscore reads a string and replaces all underscores with "+" and returns the string
func ReplaceWS ¶
ReplaceWS reads a string and if it has white spaces it replaces them with "+" and return the string
func TrimSuffix ¶
TrimSuffix removes some common file suffixes
func WriteOLTSV ¶
func WriteOLTSV(outputFile string, responses []OLResponse) error
WriteOLTSV writes OLResponses to a tsv file
Types ¶
type Docs ¶
type Docs struct { Key string `json:"key"` Type string `json:"type"` Seed []string `json:"seed"` Title string `json:"title"` Title_suggest string `json:"title_suggest"` Has_fulltext bool `json:"has_fulltext"` Edition_count int `json:"edition_count"` Edition_key []string `json:"edition_key"` Publish_date []string `json:"publish_date"` Publish_year []int `json:"publish_year"` First_publish_year int `json:"first_publish_year"` Number_of_pages_median int `json:"number_of_pages_median"` ISBN []string `json:"isbn"` Last_modified_i int `json:"last_modified_i"` Ebook_count_i int `json:"ebook_count_i"` Cover_edition_key string `json:"cover_edition_i"` Cover_i int `json:"cover_i"` Publisher []string `json:"publisher"` Language []string `json:"language"` Author_key []string `json:"author_key"` Author_name []string `json:"author_name"` Id_goodreads []string `json:"id_goodreads"` Id_librarything []string `json:"id_librarything"` Publisher_facet []string `json:"publisher_facet"` Version int `json:"_version_"` Author_facet []string `json:"author_facet"` }
Docs is a struct for the docs key returned by the OpenLibrary API
type OLResponse ¶
type OLResponse struct { NumFound int `json:"numFound"` Start int `json:"start"` NumFoundExact bool `json:"numFoundExact"` Docs []Docs `json:"docs"` }
OLResponse is a struct for the response returned by the OpenLibrary API
func AskOpenLibrary ¶
func AskOpenLibrary(title string) (OLResponse, error)
AskOpenLibrary sends the title to Open Librarie's API and reads the json response and unmarshals it into olresponse.