Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EXIF ¶
type EXIF struct {
Copyright string `json:"copyright,omitempty"`
}
EXIF is the metadata of an image What other fields do we need???
type ElasticSearch ¶
type ElasticSearch struct { Client *elastic.Client Index string Type string Bulk *elastic.BulkProcessor NSFWThreshold float64 }
ElasticSearch hold connection and index settings
func (*ElasticSearch) Setup ¶
func (e *ElasticSearch) Setup() error
Setup will create our image index
func (*ElasticSearch) Uncrawled ¶
Uncrawled finds images that haven't been crawled recently/yet We also aggregate by domain, which is equivalent to selecting unique domains so that we don't overload a domain. The subaggregation will then return 1 result for each domain.
func (*ElasticSearch) Upsert ¶
func (e *ElasticSearch) Upsert(img *Image) error
Upsert updates an image link or inserts it if it doesn't exist NOTE: Elasticsearch has a 512-byte limit on an insert operation. Upsert does not have that limit.
type Image ¶
type Image struct { ID string `json:"id"` Domain string `json:"domain"` Alt string `json:"alt,omitempty"` NSFW float64 `json:"nsfw_score,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` EXIF Classification map[string]float64 `json:"classification,omitempty"` MIME string `json:"mime,omitempty"` Crawled string `json:"crawled,omitempty"` Base64 string `json:"base64,omitempty"` }
Image is a link to an image
func (*Image) SimplifyMIME ¶
SimplifyMIME strips unnecessary info from MIME image/jpg -> jpg
type PixabayResponse ¶
type PixabayResponse struct { TotalHits int64 `json:"totalHits"` Hits []struct { LargeImageURL string `json:"largeImageURL"` WebformatHeight int `json:"webformatHeight"` WebformatWidth int `json:"webformatWidth"` Likes int `json:"likes"` ImageWidth int `json:"imageWidth"` ID int `json:"id"` UserID int `json:"user_id"` Views int `json:"views"` Comments int `json:"comments"` PageURL string `json:"pageURL"` ImageHeight int `json:"imageHeight"` WebformatURL string `json:"webformatURL"` Type string `json:"type"` PreviewHeight int `json:"previewHeight"` Tags string `json:"tags"` Downloads int64 `json:"downloads"` User string `json:"user"` Favorites int `json:"favorites"` ImageSize int64 `json:"imageSize"` PreviewWidth int `json:"previewWidth"` UserImageURL string `json:"userImageURL"` PreviewURL string `json:"previewURL"` } `json:"hits"` Total int64 `json:"total"` }
PixabayResponse is the raw API response from Pixabay
type Provider ¶
type Provider string
Provider is an image source
const PixabayProvider Provider = "Pixabay"
PixabayProvider is an image provider
type Results ¶
type Results struct { Provider Provider Count int64 `json:"count"` Page string `json:"page"` Previous string `json:"previous"` Next string `json:"next"` Last string `json:"last"` Pagination []string `json:"pagination"` Images []*Image `json:"images"` }
Results are the image results from a query