pixiv

package module
v0.0.0-...-ee699aa Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 11 Imported by: 0

README

Pixiv API wrapper for golang (v2)

Acknowledgments: I've refer upbit/pixivpy for auth procedure.

Documentation

Index

Constants

View Source
const (
	DefaultAPIEndpoint    = "https://app-api.pixiv.net"
	DefaultRateLimitEvery = 1 * time.Second
	DefaultRateLimitBurst = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	ClientID        string `json:"client_id"`
	ClientSecret    string `json:"client_secret"`
	Username        string `json:"username"`
	Password        string `json:"password"`
	SignatureSecret string `json:"signature_secret"`
}

type Comment

type Comment struct {
	ID         uint64 `json:"id"`
	Comment    string `json:"comment"`
	Date       string `json:"date"`
	User       *User  `json:"user"`
	HasReplies bool   `json:"has_replies"`
}

func FetchCommentList

func FetchCommentList(ctx context.Context, session Session, path, query string) ([]*Comment, string, error)

func UnmarshalCommentList

func UnmarshalCommentList(r io.Reader) ([]*Comment, string, error)

type Illust

type Illust struct {
	Item
	// illust / manga
	Type  string   `json:"type"`
	Tools []string `json:"tools"`

	Width  int `json:"width"`
	Height int `json:"height"`
	// Series <unknown type> `json:"series"`
	SanityLevel int `json:"sanity_level"`
	// appears when page_count > 1
	MetaPages []*MetaPage `json:"meta_pages"`
	// appears when page_count == 1
	MetaSinglePage *MetaSinglePage `json:"meta_single_page"`
}

func FetchIllustList

func FetchIllustList(ctx context.Context, session Session, path, query string) ([]*Illust, string, error)

func UnmarshalIllustList

func UnmarshalIllustList(r io.Reader) ([]*Illust, string, error)

type ImageUrls

type ImageUrls map[string]string

type Item

type Item struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	// html(like?) document
	Caption   string    `json:"caption"`
	Restrict  int       `json:"restrict"`
	User      User      `json:"user"`
	Tags      []Tag     `json:"tags"`
	ImageUrls ImageUrls `json:"image_urls"`
	// use time.RFC3339 to decode
	CreateDate     string `json:"create_date"`
	PageCount      int    `json:"page_count"`
	TotalView      int    `json:"total_view"`
	TotalBookmarks int    `json:"total_bookmarks"`
	IsBookmarked   bool   `json:"is_bookmarked"`
	IsMuted        bool   `json:"is_muted"`
	Visible        bool   `json:"visible"`
}

type MetaPage

type MetaPage struct {
	ImageUrls ImageUrls `json:"image_urls"`
}

type MetaSinglePage

type MetaSinglePage struct {
	OriginalImageUrl string `json:"original_image_url"`
}

type MockClient

type MockClient struct {
	Delegate *http.Client
}

func (*MockClient) Get

func (m *MockClient) Get(base, query string) (*http.Response, error)

func (*MockClient) Post

func (m *MockClient) Post(base, query string, body io.Reader) (*http.Response, error)

type Novel

type Novel struct {
	Item
	TextLength int `json:"text_length"`
}

type OAuthSession

type OAuthSession struct {
	Endpoint string
	Limiter  *rate.Limiter
	// contains filtered or unexported fields
}

A client for Pixiv smartphone apis

func NewOAuthClient

func NewOAuthClient(auth *AuthConfig) (*OAuthSession, error)

func (*OAuthSession) Get

func (s *OAuthSession) Get(ctx context.Context, base, query string) (*http.Response, error)

func (*OAuthSession) Post

func (s *OAuthSession) Post(ctx context.Context, base, query, contentType string, body io.Reader) (*http.Response, error)

type OAuthTokenSource

type OAuthTokenSource struct {
	// contains filtered or unexported fields
}

func (*OAuthTokenSource) Token

func (o *OAuthTokenSource) Token() (*oauth2.Token, error)

type Session

type Session interface {
	Get(ctx context.Context, base, query string) (*http.Response, error)
	Post(ctx context.Context, base, query, contentType string, body io.Reader) (*http.Response, error)
}

type Tag

type Tag struct {
	Name string `json:"name"`
}

type TrendingTag

type TrendingTag struct {
	Tag    string  `json:"tag"`
	Illust *Illust `json:"illust"`
}

type User

type User struct {
	ID               uint32    `json:"id"`
	Name             string    `json:"name"`
	Account          string    `json:"account"`
	ProfileImageUrls ImageUrls `json:"profile_image_urls"`

	IsFollowed bool   `json:"is_followed,omitempty"`
	Comment    string `json:"comment,omitempty"`
}

type UserDetails

type UserDetails struct {
	User             *User                  `json:"user"`
	Profile          map[string]interface{} `json:"profile"`
	ProfilePublicity map[string]interface{} `json:"profile_publicity"`
	Workspace        map[string]interface{} `json:"workspace"`
}

type UserPreview

type UserPreview struct {
	User    *User     `json:"user"`
	Illusts []*Illust `json:"illusts"`
	Novels  []*Novel  `json:"novels"`
	IsMuted bool      `json:"is_muted"`
}

func FetchUserPreviewList

func FetchUserPreviewList(ctx context.Context, session Session, path, query string) ([]*UserPreview, string, error)

func UnmarshalUserPreviewList

func UnmarshalUserPreviewList(r io.Reader) ([]*UserPreview, string, error)

Directories

Path Synopsis
api
v1
v2
cmd

Jump to

Keyboard shortcuts

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