pixiv

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

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

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 10 Imported by: 0

README

pixiv

test Pixiv API for Golang (with Auth supported)

Forked from everpcpc/pixiv Inspired by pixivpy

I applied some changes to meet my purpose.

Useage

api := pixiv.AppPixivAPI()
api.BaseAPI.HookAccessToken(func(token string) { fmt.Println(token) })
api.BaseAPI.Login("#Username","@Password")
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

This section is empty.

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"`
}

Account struct

type AccountProfileImages

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

AccountProfileImages struct

type AppPixiv

type AppPixiv struct {
	BaseAPI *BasePixiv
	// contains filtered or unexported fields
}

AppPixiv AppPixivAPI

func AppPixivAPI

func AppPixivAPI() *AppPixiv

AppPixivAPI AppPixiv

func (*AppPixiv) IllustComments

func (api *AppPixiv) IllustComments(IllustID uint64, offset int, IncludeTotalComments bool) (*IllustCommentsResponse, int, error)

IllustComments get the comments of an Illust

func (*AppPixiv) IllustDetail

func (api *AppPixiv) IllustDetail(id uint64) (*Illust, error)

IllustDetail gets the detail of an illust

func (*AppPixiv) IllustFollow

func (api *AppPixiv) IllustFollow(restrict string, offset int) ([]Illust, int, error)

IllustFollow restrict: [public, private]

func (*AppPixiv) IllustRanking

func (api *AppPixiv) IllustRanking(Mode string, Date string, offset int) (*IllustsResponse, int, error)

IllustRanking ("day", "", 0)

func (*AppPixiv) IllustRecommended

func (api *AppPixiv) IllustRecommended(contentType string, includeRankingLabel bool, maxBookmarkIDForRecommend uint64, minBookmarkIDForRecentIllust uint64, offset int, includeRankingIllusts bool, reqAuth bool) (*IllustsResponse, int, error)

IllustRecommended ("illust", true, 0, 0, 0, true, true)

func (*AppPixiv) IllustRelated

func (api *AppPixiv) IllustRelated(IllustID uint64, offset int) (*IllustsResponse, int, error)

IllustRelated get the related illusts of an Illust

func (*AppPixiv) SearchIllust

func (api *AppPixiv) SearchIllust(Word string, searchTarget string, sort string, startDate string, endDate string, duration string, offset int) (*IllustsResponse, int, error)

SearchIllust ("Sagiri", "partial_match_for_tags", "date_desc", "", "", "", 0)

func (*AppPixiv) SearchUser

func (api *AppPixiv) SearchUser(Word string, sort string, duration string, offset int) (*UserResponse, int, error)

SearchUser ("Quan_", "date_desc", "", 0)

func (*AppPixiv) TrendingTagsIllust

func (api *AppPixiv) TrendingTagsIllust() (*TrendingTagsIllustResponse, error)

TrendingTagsIllust ("day", "", 0)

func (*AppPixiv) UgoiraMetadata

func (api *AppPixiv) UgoiraMetadata(illustID uint64) (*UgoiraMetadataResponse, error)

UgoiraMetadata ("day", "", 0)

func (*AppPixiv) UserBookmarksIllust

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

UserBookmarksIllust restrict: [public, private]

func (*AppPixiv) UserDetail

func (api *AppPixiv) UserDetail(uid uint64) (*UserDetail, error)

UserDetail gets users information

func (*AppPixiv) UserIllusts

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

UserIllusts type: [illust, manga]

type AuthInfo

type AuthInfo struct {
	AccessToken  string   `json:"access_token"`
	ExpiresIn    int      `json:"expires_in"`
	TokenType    string   `json:"token_type"`
	Scope        string   `json:"scope"`
	RefreshToken string   `json:"refresh_token"`
	User         *Account `json:"user"`
	DeviceToken  string   `json:"device_token"`
}

type AuthParams

type AuthParams struct {
	GetSecureURL int    `url:"get_secure_url,omitempty"`
	ClientID     string `url:"client_id,omitempty"`
	ClientSecret string `url:"client_secret,omitempty"`
	GrantType    string `url:"grant_type,omitempty"`
	Username     string `url:"username,omitempty"`
	Password     string `url:"password,omitempty"`
	RefreshToken string `url:"refresh_token,omitempty"`
}

type BasePixiv

type BasePixiv struct {
	AccessToken  string
	UserID       string
	RefreshToken string

	TokenDeadline    time.Time
	AccessChangeHook func(string)
	// contains filtered or unexported fields
}

BasePixiv struct

func BasePixivAPI

func BasePixivAPI() *BasePixiv

BasePixivAPI is basic tools which will be called by others

func (*BasePixiv) Auth

func (api *BasePixiv) Auth(params *AuthParams) (*AuthInfo, error)

Auth requires authParams

func (*BasePixiv) HookAccessToken

func (api *BasePixiv) HookAccessToken(token func(string))

HookAccessToken call a function when the AccessToken changed

func (*BasePixiv) Login

func (api *BasePixiv) Login(username, password string) (*AuthInfo, error)

Login can login

func (*BasePixiv) SetAuth

func (api *BasePixiv) SetAuth(AccessToken string, RefreshToken string)

SetAuth requires AccessToken and RefreshToken to auth

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 IllustComments

type IllustComments struct {
	ID            int           `json:"id"`
	Comment       string        `json:"comment"`
	Date          time.Time     `json:"date"`
	User          User          `json:"user"`
	ParentComment ParentComment `json:"parent_comment"`
}

type IllustCommentsParams

type IllustCommentsParams struct {
	IllustID             uint64 `url:"illust_id,omitemtpy"`
	Offset               int    `url:"offset,omitempty"`
	IncludeTotalComments bool   `url:"include_total_comments,omitempty"`
}

IllustCommentsParams is used by function IllustComments

type IllustCommentsResponse

type IllustCommentsResponse struct {
	TotalComments int              `json:"total_comments"`
	Comments      []IllustComments `json:"comments"`
	NextURL       string           `json:"next_url"`
}

type IllustRankingParams

type IllustRankingParams struct {
	Mode   string `url:"mode,omitemtpy"`
	Date   string `url:"date,omitempty"`
	Filter string `url:"filter,omitempty"`
	Offset int    `url:"offset,omitempty"`
}

IllustRankingParams IllustRanking

type IllustRecommendedParams

type IllustRecommendedParams struct {
	ContentType string `url:"content_type,omitemtpy"`

	Filter                       string `url:"filter,omitempty"`
	MaxBookmarkIDForRecommend    uint64 `url:"max_bookmark_id_for_recommend,omitempty"`
	MinBookmarkIDForRecentIllust uint64 `url:"min_bookmark_id_for_recent_illust,omitempty"`
	Offset                       int    `url:"offset,omitempty"`
	IncludeRankingIllusts        bool   `url:"include_ranking_illusts,omitempty"`
	// contains filtered or unexported fields
}

IllustRecommendedParams IllustRecommended

type IllustRelatedParams

type IllustRelatedParams struct {
	IllustID uint64 `url:"illust_id,omitemtpy"`
	Offset   int    `url:"offset,omitempty"`
	Filter   string `url:"filter,omitempty"`
}

type IllustResponse

type IllustResponse struct {
	Illust Illust `json:"illust"`
}

type IllustsResponse

type IllustsResponse struct {
	Illusts []Illust `json:"illusts"`
	NextURL string   `json:"next_url"`
}

type Images

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

type LoginError

type LoginError struct {
	HasError bool              `json:"has_error"`
	Errors   map[string]Perror `json:"errors"`
}

type LoginResponse

type LoginResponse struct {
	Response *AuthInfo `json:"response"`
}

type MetaPage

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

type MetaSinglePage

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

type ParentComment

type ParentComment struct {
}

type Perror

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

type PixivError

type PixivError struct {
	Message            string            `json:"message"`
	Reason             string            `json:"reason"`
	UserMessage        string            `json:"user_message"`
	UserMessageDetails UserMessageDetail `json:"user_message_details"`
}

type PixivResponseError

type PixivResponseError struct {
	Error PixivError `json:"error"`
}

PixivResponseError PixivResponseError

type SearchIllustParams

type SearchIllustParams struct {
	Word         string `url:"word,omitempty"`
	SearchTarget string `url:"search_target,omitempty"`
	Sort         string `url:"sort,omitempty"`
	StartDate    string `url:"start_date,omitempty"`
	EndDate      string `url:"end_date,omitempty"`
	Duration     string `url:"duration,omitempty"`
	Offset       int    `url:"offset,omitempty"`
	Filter       string `url:"filter,omitempty"`
}

type SearchUserParams

type SearchUserParams struct {
	Word     string `url:"word,omitempty"`
	Sort     string `url:"sort,omitempty"`
	Duration string `url:"duration,omitempty"`
	Offset   int    `url:"offset,omitempty"`
	Filter   string `url:"filter,omitempty"`
}

type Tag

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

type TrendingTagsIllust

type TrendingTagsIllust struct {
	TranslatedName string `json:"translated_name"`
	Tag            string `json:"tag"`
	Illust         Illust `json:"illust"`
}

type TrendingTagsIllustParams

type TrendingTagsIllustParams struct {
	Filter string `url:"filter,omitempty"`
}

TrendingTagsIllustParams TrendingTagsIllust

type TrendingTagsIllustResponse

type TrendingTagsIllustResponse struct {
	TrendTags []TrendingTagsIllust `json:"trend_tags"`
}

type UgoiraMetadata

type UgoiraMetadata struct {
	Frames  []UgoiraMetadataFrame `json:"frames"`
	ZipUrls UgoiraMetadataZipUrls `json:"zip_urls"`
}

type UgoiraMetadataFrame

type UgoiraMetadataFrame struct {
	Delay int    `json:"delay"`
	File  string `json:"file"`
}

type UgoiraMetadataParams

type UgoiraMetadataParams struct {
	IllustID uint64 `url:"illust_id,omitempty"`
}

type UgoiraMetadataResponse

type UgoiraMetadataResponse struct {
	UgoiraMetadata UgoiraMetadata `json:"ugoira_metadata"`
}

type UgoiraMetadataZipUrls

type UgoiraMetadataZipUrls struct {
	Medium   string `json:"medium"`
	Large    string `json:"large"`
	Original string `json:"original"`
}

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"`
}

type UserMessageDetail

type UserMessageDetail struct {
}

type UserPreviews

type UserPreviews struct {
	User    *User    `json:"user"`
	Illusts []Illust `json:"illusts"`
	IsMuted bool     `json:"is_muted"`
}

type UserResponse

type UserResponse struct {
	UserPreviews []UserPreviews `json:"user_previews"`
	NextURL      string         `json:"next_url"`
}

Jump to

Keyboard shortcuts

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