Documentation
¶
Index ¶
- Variables
- type AddBookmarkOptions
- type AppAPI
- func (api *AppAPI) ForceAuth() (*RespAuth, error)
- func (api *AppAPI) NewAuthorizedRequest(method, url string, data url.Values) (*http.Request, error)
- func (api *AppAPI) SetLanguage(languages []string)
- func (api *AppAPI) SetProxy(p string) error
- func (api *AppAPI) SetRefreshToken(token string)
- func (api *AppAPI) SetUser(username, password string)
- func (api *AppAPI) TokenExpired() bool
- type BookmarkQuery
- type Comment
- type CommentService
- type ErrAppAPI
- type ErrAuth
- type FollowingQuery
- type Illust
- type IllustQuery
- type IllustService
- func (s *IllustService) AddBookmark(illustID int, restrict Restrict, opts *AddBookmarkOptions) error
- func (s *IllustService) AddHistory(illustIDs []int) error
- func (s *IllustService) Comments(illustID int) (*RespComments, error)
- func (s *IllustService) DeleteBookmark(illustID int) error
- func (s *IllustService) Detail(illustID int) (*RespIllust, error)
- func (s *IllustService) NewFromAll(opts *NewIllustsQuery) (*RespIllusts, error)
- func (s *IllustService) NewFromFollowings(restrict Restrict) (*RespIllusts, error)
- func (s *IllustService) NewFromMyPixiv() (*RespIllusts, error)
- func (s *IllustService) Related(illustID int, opts *RelatedQuery) (*RespIllusts, error)
- func (s *IllustService) UgoiraMetadata(illustID int) (*RespUgoiraMetadata, error)
- type ImageURLs
- type NewIllustsQuery
- type Novel
- type NovelMarker
- type NovelService
- func (s *NovelService) AddBookmark(novelID int, restrict Restrict, opts *AddBookmarkOptions) error
- func (s *NovelService) AddHistory(novelIDs []int) error
- func (s *NovelService) Comments(novelID int) (*RespComments, error)
- func (s *NovelService) DeleteBookmark(novelID int) error
- func (s *NovelService) Detail(novelID int) (*RespNovel, error)
- func (s *NovelService) Text(novelID int) (*RespNovelText, error)
- type Profile
- type RecommendUsersQuery
- type RelatedQuery
- type RespAuth
- type RespBookmarkTags
- type RespComments
- type RespIllust
- type RespIllusts
- type RespNovel
- type RespNovelText
- type RespNovels
- type RespUgoiraMetadata
- type RespUserDetail
- type RespUserPreviews
- type Restrict
- type Series
- type Tag
- type Type
- type User
- type UserDetailQuery
- type UserPreview
- type UserService
- func (s *UserService) BookmarkedIllusts(userID int, restrict Restrict, opts *BookmarkQuery) (*RespIllusts, error)
- func (s *UserService) BookmarkedNovels(userID int, restrict Restrict, opts *BookmarkQuery) (*RespNovels, error)
- func (s *UserService) Detail(userID int, opts *UserDetailQuery) (*RespUserDetail, error)
- func (s *UserService) Followings(userID int, opts *FollowingQuery) (*RespUserPreviews, error)
- func (s *UserService) IllustBookmarkTags(restrict Restrict) (*RespBookmarkTags, error)
- func (s *UserService) Illusts(userID int, opts *IllustQuery) (*RespIllusts, error)
- func (s *UserService) NovelBookmarkTags(restrict Restrict) (*RespBookmarkTags, error)
- func (s *UserService) Novels(userID int) (*RespNovels, error)
- func (s *UserService) Recommend(opts *RecommendUsersQuery) (*RespUserPreviews, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrSetProxyUnsupportedTransport = errors.New("pixiv: can only set proxy for *http.Transport") ErrSetProxyUnsupportedProtocol = errors.New("pixiv: unsupported proxy protocol") )
Proxy setting errors
var (
ErrEmptyNextURL = errors.New("empty next_url")
)
Functions ¶
This section is empty.
Types ¶
type AddBookmarkOptions ¶
type AddBookmarkOptions struct {
Tags []string `url:"tags[],omitempty"`
}
AddBookmarkOptions defines form body in AddBookmark.
type AppAPI ¶
type AppAPI struct { ClientID, ClientSecret, HashSecret, BaseURL, DeviceToken string BaseHeader http.Header AuthURL, Username, Password, RefreshToken, AccessToken string TokenExpireAt time.Time TokenExpiryDelta time.Duration // Contains details of login user. AuthResponse *RespAuth Client *http.Client // *http.Client with *Transport that can authorize requests automatically User *UserService Illust *IllustService Novel *NovelService Comment *CommentService // contains filtered or unexported fields }
AppAPI defines the Pixiv App-API client with config.
func NewWithClient ¶
NewWithClient returns new PixivAppAPI with the given http.Client.
func (*AppAPI) ForceAuth ¶ added in v0.1.1
ForceAuth gets new access_token with given username and password or refresh_token wether it expires.
func (*AppAPI) NewAuthorizedRequest ¶ added in v0.1.1
NewAuthorizedRequest sets auth and other headers and body of a new request with given method, url and form data.
func (*AppAPI) SetLanguage ¶
SetLanguage sets Accept-Language header to the given languages. This affects the language of tag translations and messages.
func (*AppAPI) SetProxy ¶
SetProxy sets the proxy with the given URI. Supports SOCKS5 or HTTP proxy.
func (*AppAPI) SetRefreshToken ¶
SetRefreshToken sets the refresh_token for auth.
func (*AppAPI) TokenExpired ¶ added in v0.1.1
TokenExpired checks if the token has expired
type BookmarkQuery ¶
type BookmarkQuery struct {
Filter string `url:"filter,omitempty"` //for_ios
}
BookmarkQuery defines url query struct in fetching bookmark.
type Comment ¶
type Comment struct { ID int `json:"id"` Comment string `json:"comment"` Date time.Time `json:"date"` User User `json:"user"` HasReplies bool `json:"has_replies"` }
Comment is embedded in RespComments
type CommentService ¶
type CommentService service
CommentService fetches comments.
func (*CommentService) RepliesIllust ¶
func (s *CommentService) RepliesIllust(commentID int) (*RespComments, error)
RepliesIllust fetches illust comment replies.
func (*CommentService) RepliesNovel ¶
func (s *CommentService) RepliesNovel(commentID int) (*RespComments, error)
RepliesNovel fetches novel comment replies.
type ErrAppAPI ¶
type ErrAppAPI struct { Errors struct { UserMessage string `json:"user_message"` Message string `json:"message"` Reason string `json:"reason"` } `json:"error"` // contains filtered or unexported fields }
ErrAppAPI is the error from app-api.pixiv.net
type ErrAuth ¶
type ErrAuth struct { HasError bool `json:"has_error"` Errors struct { System struct { Code int `json:"code"` Message string `json:"message"` } `json:"system"` } `json:"errors"` // contains filtered or unexported fields }
ErrAuth is the error from POST https://oauth.secure.pixiv.net/auth/token
type FollowingQuery ¶
type FollowingQuery struct {
Restrict Restrict `url:"restrict,omitempty"`
}
FollowingQuery defines url query struct in fetching user's followings.
type Illust ¶
type Illust struct { ID int `json:"id"` Title string `json:"title"` Type string `json:"type"` // Deprecated: Only contains the image URLs of the first page. // Use MetaSinglePage or MetaPages instead. ImageURLs ImageURLs `json:"image_urls"` Caption string `json:"caption"` Restrict int `json:"restrict"` User User `json:"user"` Tags []Tag `json:"tags"` Tools []string `json:"tools"` CreateDate time.Time `json:"create_date"` PageCount int `json:"page_count"` Width int `json:"width"` Height int `json:"height"` SanityLevel int `json:"sanity_level"` XRestrict int `json:"x_restrict"` Series Series `json:"series"` MetaSinglePage struct { OriginalImageURL string `json:"original_image_url,omitempty"` } `json:"meta_single_page"` MetaPages []struct { ImageURLs ImageURLs `json:"image_urls"` } `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"` }
Illust is embedded in RespIllusts
type IllustQuery ¶
type IllustQuery struct { Filter string `url:"filter,omitempty"` Type string `url:"type,omitempty"` Offset int `url:"offset,omitempty"` }
IllustQuery defines url query struct in fetching user's illusts.
type IllustService ¶
type IllustService service
IllustService does ops with illust.
func (*IllustService) AddBookmark ¶
func (s *IllustService) AddBookmark(illustID int, restrict Restrict, opts *AddBookmarkOptions) error
AddBookmark adds illust to public or private bookmark.
func (*IllustService) AddHistory ¶
func (s *IllustService) AddHistory(illustIDs []int) error
AddHistory adds illust browsing history.
func (*IllustService) Comments ¶
func (s *IllustService) Comments(illustID int) (*RespComments, error)
Comments fetches comments of the illust.
func (*IllustService) DeleteBookmark ¶
func (s *IllustService) DeleteBookmark(illustID int) error
DeleteBookmark deletes illust from public and private bookmark
func (*IllustService) Detail ¶
func (s *IllustService) Detail(illustID int) (*RespIllust, error)
Detail fetches illust's detail by it's id.
The API seems not used in Pixiv's app.
func (*IllustService) NewFromAll ¶
func (s *IllustService) NewFromAll(opts *NewIllustsQuery) (*RespIllusts, error)
NewFromAll fetches new illusts from everyone.
func (*IllustService) NewFromFollowings ¶
func (s *IllustService) NewFromFollowings(restrict Restrict) (*RespIllusts, error)
NewFromFollowings fetches new illusts from followings.
func (*IllustService) NewFromMyPixiv ¶
func (s *IllustService) NewFromMyPixiv() (*RespIllusts, error)
NewFromMyPixiv fetches new illusts from my-pixiv.
func (*IllustService) Related ¶
func (s *IllustService) Related(illustID int, opts *RelatedQuery) (*RespIllusts, error)
Related fetches related illusts.
func (*IllustService) UgoiraMetadata ¶
func (s *IllustService) UgoiraMetadata(illustID int) (*RespUgoiraMetadata, error)
UgoiraMetadata fetches ugoira metadata.
type ImageURLs ¶
type ImageURLs struct { SquareMedium string `json:"square_medium"` Medium string `json:"medium"` Large string `json:"large"` Original string `json:"original,omitempty"` }
ImageURLs is embedded in Illust, MetaPage, Novel
type NewIllustsQuery ¶
type NewIllustsQuery struct { ContentType string `url:"content_type,omitempty"` Filter string `url:"filter,omitempty"` }
NewIllustsQuery defines url query of new illusts from everyone.
type Novel ¶
type Novel struct { ID int `json:"id"` Title string `json:"title"` Caption string `json:"caption"` Restrict int `json:"restrict"` XRestrict int `json:"x_restrict"` ImageURLs ImageURLs `json:"image_urls"` CreateDate time.Time `json:"create_date"` Tags []Tag `json:"tags"` PageCount int `json:"page_count"` TextLength int `json:"text_length"` User User `json:"user"` Series Series `json:"series"` IsBookmarked bool `json:"is_bookmarked"` TotalBookmarks int `json:"total_bookmarks"` TotalView int `json:"total_view"` Visible bool `json:"visible"` TotalComments int `json:"total_comments"` IsMuted bool `json:"is_muted"` IsMypixivOnly bool `json:"is_mypixiv_only"` IsXRestricted bool `json:"is_x_restricted"` }
Novel is embedded in RespNovelText, RespNovels
type NovelMarker ¶
type NovelMarker struct {
Page int `json:"page"`
}
NovelMarker is embedded in RespNovelText
type NovelService ¶
type NovelService service
NovelService does ops with novels.
func (*NovelService) AddBookmark ¶
func (s *NovelService) AddBookmark(novelID int, restrict Restrict, opts *AddBookmarkOptions) error
AddBookmark adds novel to public or private bookmark.
func (*NovelService) AddHistory ¶
func (s *NovelService) AddHistory(novelIDs []int) error
AddHistory adds novel browsing history.
func (*NovelService) Comments ¶
func (s *NovelService) Comments(novelID int) (*RespComments, error)
Comments fetches comments of the novel.
func (*NovelService) DeleteBookmark ¶
func (s *NovelService) DeleteBookmark(novelID int) error
DeleteBookmark deletes novel from public and private bookmark
func (*NovelService) Detail ¶
func (s *NovelService) Detail(novelID int) (*RespNovel, error)
Detail fetches novel's detail by it's id.
The API seems not used in Pixiv's app.
func (*NovelService) Text ¶
func (s *NovelService) Text(novelID int) (*RespNovelText, error)
Text fetches text of the novel.
type Profile ¶
type Profile struct { Webpage string `json:"webpage"` Gender string `json:"gender"` // Format: 1999-04-10 Birth string `json:"birth"` // Deprecated: Use Birth instead. // Format: 04-10 BirthDay string `json:"birth_day"` // Deprecated: Use Birth instead. BirthYear int `json:"birth_year"` Region string `json:"region"` AddressID int `json:"address_id"` CountryCode string `json:"country_code"` Job string `json:"job"` JobID int `json:"job_id"` TotalFollowUsers int `json:"total_follow_users"` TotalMypixivUsers int `json:"total_mypixiv_users"` TotalIllusts int `json:"total_illusts"` TotalManga int `json:"total_manga"` TotalNovels int `json:"total_novels"` TotalIllustBookmarksPublic int `json:"total_illust_bookmarks_public"` TotalIllustSeries int `json:"total_illust_series"` TotalNovelSeries int `json:"total_novel_series"` BackgroundImageURL string `json:"background_image_url"` TwitterAccount string `json:"twitter_account"` TwitterURL string `json:"twitter_url"` PawooURL string `json:"pawoo_url"` IsPremium bool `json:"is_premium"` IsUsingCustomProfileImage bool `json:"is_using_custom_profile_image"` }
Profile is embedded in RespUserDetail
type RecommendUsersQuery ¶
type RecommendUsersQuery struct {
Filter string `url:"filter,omitempty"` //for_ios
}
RecommendUsersQuery defines url query struct in fetching recommend users.
type RelatedQuery ¶
type RelatedQuery struct {
Filter string `url:"filter,omitempty"`
}
RelatedQuery defines url query of related illusts.
type RespAuth ¶
type RespAuth struct { Response 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 struct { ProfileImageURLs struct { PX16X16 string `json:"px_16x16"` PX50X50 string `json:"px_50x50"` PX170X170 string `json:"px_170x170"` } `json:"profile_image_urls"` // The ID in original response is of the type string 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"` RequirePolicyAgreement bool `json:"require_policy_agreement"` } `json:"user"` DeviceToken string `json:"device_token"` } `json:"response"` }
RespAuth is the response from POST https://oauth.secure.pixiv.net/auth/token
type RespBookmarkTags ¶
type RespBookmarkTags struct { BookmarkTags []struct { Count int `json:"count"` Name string `json:"name"` } `json:"bookmark_tags"` NextURL string // contains filtered or unexported fields }
RespBookmarkTags is the response from:
/v1/user/bookmark-tags/illust
type RespComments ¶
type RespComments struct { Comments []Comment `json:"comments"` NextURL string `json:"next_url"` // contains filtered or unexported fields }
RespComments is the response from:
/v2/illust/comments?illust_id=... /v2/novel/comments?novel_id=... /v1/illust/comment/replies?comment_id=...
func (*RespComments) NextComments ¶
func (r *RespComments) NextComments() (*RespComments, error)
NextComments fetches NextURL with API.
type RespIllust ¶
type RespIllust struct {
Illust Illust `json:"illust"`
}
RespIllust is the response from:
/v1/illust/detail?illust_id=...
type RespIllusts ¶
type RespIllusts struct { Illusts []Illust `json:"illusts"` NextURL string `json:"next_url"` // contains filtered or unexported fields }
RespIllusts is the response from:
/v2/illust/mypixiv /v1/illust/new?content_type=... /v1/user/illusts?user_id=...&type=...
func (*RespIllusts) NextIllusts ¶
func (r *RespIllusts) NextIllusts() (*RespIllusts, error)
NextIllusts fetches NextURL with API.
type RespNovel ¶
type RespNovel struct {
Novel Novel `json:"novel"`
}
RespNovel is the response from:
/v2/novel/detail?novel_id=...
type RespNovelText ¶
type RespNovelText struct { NovelMarker NovelMarker `json:"novel_marker"` NovelText string `json:"novel_text"` SeriesPrev *Novel `json:"series_prev"` SeriesNext *Novel `json:"series_next"` }
RespNovelText is the response from:
/v1/novel/text?novel_id=...
type RespNovels ¶
type RespNovels struct { Novels []Novel `json:"novels"` RankingNovels []Novel `json:"ranking_novels"` // PrivacyPolicy PrivacyPolicy `json:"privacy_policy"` NextURL string `json:"next_url"` // contains filtered or unexported fields }
RespNovels is the response from:
/v1/user/novels?user_id=... /v1/user/bookmarks/novel?user_id=...&restrict=...
func (*RespNovels) NextNovels ¶
func (r *RespNovels) NextNovels() (*RespNovels, error)
NextNovels fetches NextURL with API.
type RespUgoiraMetadata ¶
type RespUgoiraMetadata struct { UgoiraMetadata struct { ZipURLs struct { Medium string `json:"medium"` } `json:"zip_urls"` Frames []struct { File string `json:"file"` Delay int `json:"delay"` } `json:"frames"` } `json:"ugoira_metadata"` }
RespUgoiraMetadata is the response from:
/v1/ugoira/metadata?illust_id=...
type RespUserDetail ¶
type RespUserDetail struct { User User `json:"user"` Profile Profile `json:"profile"` // All fields here except Pawoo are all "private" or "public" ProfilePublicity struct { Gender string `json:"gender"` Region string `json:"region"` BirthDay string `json:"birth_day"` BirthYear string `json:"birth_year"` Job string `json:"job"` Pawoo bool `json:"pawoo"` } `json:"profile_publicity"` Workspace map[string]string `json:"workspace"` }
RespUserDetail is the response from:
/v1/user/detail?user_id=...
type RespUserPreviews ¶
type RespUserPreviews struct { UserPreviews []UserPreview `json:"user_previews"` NextURL string `json:"next_url"` // contains filtered or unexported fields }
RespUserPreviews is the response from:
/v1/user/following?restrict=...&user_id=...
func (*RespUserPreviews) NextFollowing ¶
func (r *RespUserPreviews) NextFollowing() (*RespUserPreviews, error)
NextFollowing fetches NextURL with API.
type Restrict ¶
type Restrict string
Restrict defines the restrict query field in fetching bookmark. It can be "public" or "private".
type Tag ¶
type Tag struct { Name string `json:"name"` TranslatedName string `json:"translated_name"` AddedByUploadedUser *bool `json:"added_by_uploaded_user"` }
Tag is embedded in Illust, Novel
type User ¶
type User struct { ID int `json:"id"` Name string `json:"name"` Account string `json:"account"` ProfileImageURLs struct { Medium string `json:"medium"` } `json:"profile_image_urls"` Comment string `json:"comment"` IsFollowed bool `json:"is_followed"` }
User may be embedded in Illust, Novel, Comment
type UserDetailQuery ¶
type UserDetailQuery struct {
Filter string `url:"filter,omitempty"` //for_ios
}
UserDetailQuery defines url query struct in fetching user's detail.
type UserPreview ¶
type UserPreview struct { User User `json:"user"` Illusts []Illust `json:"illusts"` Novels []Novel `json:"novels"` IsMuted bool `json:"is_muted"` }
UserPreview contains last 3 illusts and novels of a user.
type UserService ¶
type UserService service
UserService does the fetching with user.
func (*UserService) BookmarkedIllusts ¶
func (s *UserService) BookmarkedIllusts(userID int, restrict Restrict, opts *BookmarkQuery) (*RespIllusts, error)
BookmarkedIllusts fetches user's bookmarked illusts.
func (*UserService) BookmarkedNovels ¶
func (s *UserService) BookmarkedNovels(userID int, restrict Restrict, opts *BookmarkQuery) (*RespNovels, error)
BookmarkedNovels fetches user's bookmarked novels.
func (*UserService) Detail ¶
func (s *UserService) Detail(userID int, opts *UserDetailQuery) (*RespUserDetail, error)
Detail fetches user profile from /v1/user/detail
func (*UserService) Followings ¶
func (s *UserService) Followings(userID int, opts *FollowingQuery) (*RespUserPreviews, error)
Followings fetches user's followings.
func (*UserService) IllustBookmarkTags ¶
func (s *UserService) IllustBookmarkTags(restrict Restrict) (*RespBookmarkTags, error)
IllustBookmarkTags fetches user's illust bookmark tags.
func (*UserService) Illusts ¶
func (s *UserService) Illusts(userID int, opts *IllustQuery) (*RespIllusts, error)
Illusts fetches user's illusts.
func (*UserService) NovelBookmarkTags ¶
func (s *UserService) NovelBookmarkTags(restrict Restrict) (*RespBookmarkTags, error)
NovelBookmarkTags fetches user's novel bookmark tags.
func (*UserService) Novels ¶
func (s *UserService) Novels(userID int) (*RespNovels, error)
Novels fetches user's novels.
func (*UserService) Recommend ¶
func (s *UserService) Recommend(opts *RecommendUsersQuery) (*RespUserPreviews, error)
Recommend fetches recommend users.