pixiv

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

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 11 Imported by: 0

README

pixiv

test codecov Go Report Card godoc

Pixiv API for Golang (with Auth supported)

Inspired by pixivpy

example

account, err := pixiv.Login("username", "password")
app := pixiv.NewApp()
user, err := app.UserDetail(uid)
illusts, next, err := app.UserIllusts(uid, "illust", 0)
illusts, next, err := app.UserBookmarksIllust(uid, "public", 0, "")
illusts, next, err := app.IllustFollow("public", 0)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HookAuth

func HookAuth(f func(string, string, time.Time) error)

HookAuth add a hook with (token, refreshToken, tokenDeadline) after a successful auth. Prividing a way to store the latest token.

Types

type Account

type Account struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	Account          string `json:"account"`
	MailAddress      string `json:"mail_address"`
	IsPremium        bool   `json:"is_premium"`
	XRestrict        int    `json:"x_restrict"`
	IsMailAuthorized bool   `json:"is_mail_authorized"`

	ProfileImage AccountProfileImages `json:"profile_image_urls"`
}

func LoadAuth

func LoadAuth(token, refreshToken string, tokenDeadline time.Time) (*Account, error)

func Login

func Login(username, password string) (*Account, error)

type AccountProfileImages

type AccountProfileImages struct {
	Px16  string `json:"px_16x16"`
	Px50  string `json:"px_50x50"`
	Px170 string `json:"px_170x170"`
}

type AppPixivAPI

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

AppPixivAPI -- App-API (6.x - app-api.pixiv.net)

func NewApp

func NewApp() *AppPixivAPI

func (*AppPixivAPI) Download

func (a *AppPixivAPI) Download(id uint64, path string) ([]int64, []error)

Download a specific picture from pixiv id

func (*AppPixivAPI) IllustDetail

func (a *AppPixivAPI) IllustDetail(id uint64) (*Illust, error)

IllustDetail get a detailed illust with id

func (*AppPixivAPI) IllustFollow

func (a *AppPixivAPI) IllustFollow(restrict string, offset int) ([]Illust, int, error)

IllustFollow restrict: [public, private]

func (*AppPixivAPI) UserBookmarksIllust

func (a *AppPixivAPI) UserBookmarksIllust(uid uint64, restrict string, maxBookmarkID int, tag string) ([]Illust, int, error)

UserBookmarksIllust restrict: [public, private]

func (*AppPixivAPI) UserDetail

func (a *AppPixivAPI) UserDetail(uid uint64) (*UserDetail, error)

func (*AppPixivAPI) UserIllusts

func (a *AppPixivAPI) UserIllusts(uid uint64, _type string, offset int) ([]Illust, int, error)

UserIllusts type: [illust, manga]

type Illust

type Illust struct {
	ID          uint64   `json:"id"`
	Title       string   `json:"title"`
	Type        string   `json:"type"`
	Images      Images   `json:"image_urls"`
	Caption     string   `json:"caption"`
	Restrict    int      `json:"restrict"`
	User        User     `json:"user"`
	Tags        []Tag    `json:"tags"`
	Tools       []string `json:"tools"`
	CreateData  string   `json:"create_data"`
	PageCount   int      `json:"page_count"`
	Width       int      `json:"width"`
	Height      int      `json:"height"`
	SanityLevel int      `json:"sanity_level"`
	// TODO:
	// Series `json:"series"`
	MetaSinglePage MetaSinglePage `json:"meta_single_page"`
	MetaPages      []MetaPage     `json:"meta_pages"`
	TotalView      int            `json:"total_view"`
	TotalBookmarks int            `json:"total_bookmarks"`
	IsBookmarked   bool           `json:"is_bookmarked"`
	Visible        bool           `json:"visible"`
	IsMuted        bool           `json:"is_muted"`
	TotalComments  int            `json:"total_comments"`
}

type Images

type Images struct {
	SquareMedium string `json:"square_medium"`
	Medium       string `json:"medium"`
	Large        string `json:"large"`
	Original     string `json:"original"`
}

type MetaPage

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

type MetaSinglePage

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

type Perror

type Perror struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

type Tag

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

type User

type User struct {
	ID         uint64 `json:"id"`
	Name       string `json:"name"`
	Account    string `json:"account"`
	Comment    string `json:"comment"`
	IsFollowed bool   `json:"is_followed"`

	ProfileImages UserImages `json:"profile_image_urls"`
}

type UserDetail

type UserDetail struct {
	User *User `json:"user"`
}

type UserImages

type UserImages struct {
	Medium string `json:"medium"`
}

Jump to

Keyboard shortcuts

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