artwork

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artwork

type Artwork struct {
	ID          string
	Title       string
	Type        string
	Description string
	Image       image.URLs
	Created     time.Time
	Tags        []string
	Author      user.User

	Width  int64
	Height int64

	PageCount     int64
	CommentCount  int64
	LikeCount     int64
	ViewCount     int64
	BookmarkCount int64

	Pages []Page
}

Artwork data

func (*Artwork) Fetch

func (i *Artwork) Fetch(ctx context.Context) (err error)

Fetch additional data from pixiv single artwork api,

func (*Artwork) FetchPages

func (i *Artwork) FetchPages(ctx context.Context) (err error)

FetchPages get all pages for artwork from pixiv artwork pages api,

func (Artwork) URL added in v0.3.0

func (i Artwork) URL(ctx context.Context) *url.URL

URL to view artwork web page.

type ContentRating added in v0.5.0

type ContentRating string

ContentRating of a artwork

var (
	// all content (default)
	ContentRatingAll ContentRating = ""
	// content that suitable for all ages
	ContentRatingSafe ContentRating = "safe"
	// restricted r18+ content
	ContentRatingR18 ContentRating = "r18"
)

content ratings

type Order added in v0.5.0

type Order string

Order for search result

var (
	// date descending (default)
	OrderDateDSC Order = ""
	// date ascending
	OrderDateASC Order = "date"
)

orders

type Page

type Page struct {
	Image  image.URLs
	Width  int64
	Height int64
}

Page is a artwork page.

type Rank

type Rank struct {
	/* required, possible rank modes:
		- daily (default)
	    - weekly
	    - monthly
	    - rookie
	    - original
	    - male
	    - female
	    - daily_r18
	    - weekly_r18
	    - male_r18
	    - female_r18
	    - r18g
	*/
	Mode string
	/* optional, possible rank content:
	    - all (default)
	    - illust
		- ugoira
		- manga
	*/
	Content string
	Date    time.Time
	Page    int
	Items   []RankItem
}

Rank contains data for one rank page.

func (*Rank) Fetch

func (rank *Rank) Fetch(ctx context.Context) (err error)

Fetch rank

func (Rank) URL added in v0.3.1

func (rank Rank) URL(ctx context.Context) *url.URL

URL to rank page.

func (Rank) URLWithQuery added in v0.4.0

func (rank Rank) URLWithQuery(ctx context.Context, q *url.Values) *url.URL

URLWithQuery to rank page.

type RankItem

type RankItem struct {
	Artwork
	Rank         int
	PreviousRank int
	JSON         gjson.Result
}

RankItem contains artwork and rank info.

type SearchMode added in v0.5.0

type SearchMode string

SearchMode to match artwork

var (
	// exact tag match (default)
	SearchModeTag SearchMode = ""
	// partial tag match
	SearchModePartialTag SearchMode = "s_tag"
	// title or caption match
	SearchModeTitleOrCaption SearchMode = "s_tc"
)

search modes

type SearchOption added in v0.4.0

type SearchOption func(*SearchOptions)

SearchOption mutate SearchOptions

func SearchOptionContentRating added in v0.5.0

func SearchOptionContentRating(rating ContentRating) SearchOption

SearchOptionContentRating filter result by content rating

func SearchOptionMode added in v0.4.2

func SearchOptionMode(mode SearchMode) SearchOption

SearchOptionMode change search mode

func SearchOptionOrder added in v0.4.2

func SearchOptionOrder(order Order) SearchOption

SearchOptionOrder change result order

func SearchOptionPage added in v0.4.0

func SearchOptionPage(page int) SearchOption

SearchOptionPage change page to retrive

func SearchOptionResolution added in v0.5.0

func SearchOptionResolution(
	widthLessThan,
	widthGreaterThan,
	heightLessThan,
	heightGreaterThan int64,
) SearchOption

SearchOptionResolution filter result by original image resolution, use 0 to unset limit.

type SearchOptions added in v0.4.0

type SearchOptions struct {
	Page              int
	Order             Order
	ContentRating     ContentRating
	Mode              SearchMode
	WidthLessThan     int64
	WidthGreaterThan  int64
	HeightLessThan    int64
	HeightGreaterThan int64
}

SearchOptions for Search see SearchOption* functions for documention.

type SearchResult

type SearchResult struct {
	JSON gjson.Result
}

SearchResult holds search data and provide useful methods.

func Search(ctx context.Context, query string, opts ...SearchOption) (result SearchResult, err error)

Search calls pixiv artwork search api.

func (SearchResult) Artworks

func (r SearchResult) Artworks() []Artwork

Artworks appeared in search result.

func (SearchResult) ForEach

func (r SearchResult) ForEach(iterator func(key gjson.Result, value gjson.Result) bool)

ForEach iterates through values. skips advertisement container item.

Jump to

Keyboard shortcuts

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