Documentation
¶
Index ¶
- func GetOAuthURL() (url string, codeVerifier string)
- func RefreshAccessToken(ctx context.Context, timeout int, refreshToken string) (OAuthTokenInfo, *UserDetails, error)
- func S256(bytes []byte) string
- func VerifyOAuthCode(code, codeVerifier string, timeout int) (string, error)
- type ArtworkJson
- type ArtworksJson
- type IllustJson
- type OAuthTokenInfo
- type OauthFlowJson
- type OauthJson
- type PixivMobile
- func (pixiv *PixivMobile) GetMultipleArtistsPosts(userIds, pageNums []string, artworkType string) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error)
- func (pixiv *PixivMobile) GetMultipleArtworkDetails(artworkIds []string) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error)
- func (pixiv *PixivMobile) SendRequest(reqArgs *httpfuncs.RequestArgs) (*http.Response, error)
- func (pixiv *PixivMobile) SetBaseDlDirPath(dlDirPath string)
- func (pixiv *PixivMobile) SetMainProgBar(mainProgBar progress.ProgressBar)
- func (pixiv *PixivMobile) SetUseCacheDb(useCacheDb bool)
- func (pixiv *PixivMobile) Sleep()
- func (pixiv *PixivMobile) TagSearch(tagName, pageNum string, dlOptions *PixivMobileDlOptions) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error, bool)
- type PixivMobileDlOptions
- func (p *PixivMobileDlOptions) CancelCtx()
- func (p *PixivMobileDlOptions) CtxIsActive() bool
- func (p *PixivMobileDlOptions) GetCancel() context.CancelFunc
- func (p *PixivMobileDlOptions) GetContext() context.Context
- func (p *PixivMobileDlOptions) SetContext(ctx context.Context)
- func (p *PixivMobileDlOptions) ValidateArgs() error
- type UgoiraJson
- type UserDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOAuthURL ¶ added in v1.1.0
Start the OAuth flow to get the refresh token
func RefreshAccessToken ¶ added in v1.1.0
func RefreshAccessToken(ctx context.Context, timeout int, refreshToken string) (OAuthTokenInfo, *UserDetails, error)
Refresh the access token
Types ¶
type ArtworkJson ¶ added in v1.1.0
type ArtworkJson struct {
Illust *IllustJson `json:"illust"`
}
type ArtworksJson ¶ added in v1.1.0
type ArtworksJson struct { Illusts []*IllustJson `json:"illusts"` NextUrl *string `json:"next_url"` }
type IllustJson ¶ added in v1.1.0
type IllustJson struct { Id int `json:"id"` Title string `json:"title"` Type string `json:"type"` User struct { Name string `json:"name"` } `json:"user"` MetaSinglePage struct { OriginalImageUrl string `json:"original_image_url"` } `json:"meta_single_page"` MetaPages []struct { ImageUrls struct { Original string `json:"original"` } `json:"image_urls"` } `json:"meta_pages"` }
type OAuthTokenInfo ¶ added in v1.1.0
type OauthFlowJson ¶ added in v1.1.0
type OauthFlowJson struct {
RefreshToken string `json:"refresh_token"`
}
type PixivMobile ¶
type PixivMobile struct { // Prog bar MainProgBar progress.ProgressBar // contains filtered or unexported fields }
func NewPixivMobile ¶
func NewPixivMobile(refreshToken string, timeout int, ctx context.Context, cancelFunc context.CancelFunc) (*PixivMobile, error)
Get a new PixivMobile structure
func (*PixivMobile) GetMultipleArtistsPosts ¶ added in v1.1.0
func (pixiv *PixivMobile) GetMultipleArtistsPosts(userIds, pageNums []string, artworkType string) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error)
func (*PixivMobile) GetMultipleArtworkDetails ¶
func (pixiv *PixivMobile) GetMultipleArtworkDetails(artworkIds []string) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error)
func (*PixivMobile) SendRequest ¶
func (pixiv *PixivMobile) SendRequest(reqArgs *httpfuncs.RequestArgs) (*http.Response, error)
Sends a request to the Pixiv API and refreshes the access token if required
Returns the JSON interface and errors if any
func (*PixivMobile) SetBaseDlDirPath ¶ added in v1.1.0
func (pixiv *PixivMobile) SetBaseDlDirPath(dlDirPath string)
func (*PixivMobile) SetMainProgBar ¶ added in v1.1.2
func (pixiv *PixivMobile) SetMainProgBar(mainProgBar progress.ProgressBar)
func (*PixivMobile) SetUseCacheDb ¶ added in v1.1.2
func (pixiv *PixivMobile) SetUseCacheDb(useCacheDb bool)
func (*PixivMobile) Sleep ¶
func (pixiv *PixivMobile) Sleep()
This is due to Pixiv's strict rate limiting.
Without delays, the user might get 429 too many requests or the user's account might get suspended.
Additionally, pixiv.net is protected by cloudflare, so to prevent the user's IP reputation from going down, delays are added.
func (*PixivMobile) TagSearch ¶
func (pixiv *PixivMobile) TagSearch(tagName, pageNum string, dlOptions *PixivMobileDlOptions) ([]*httpfuncs.ToDownload, []*ugoira.Ugoira, []error, bool)
Query Pixiv's API (mobile) to get the JSON of a search query Returns the ToDownload slice, Ugoira slice, boolean indicating if there was an error, and boolean indicating if the context was cancelled
type PixivMobileDlOptions ¶
type PixivMobileDlOptions struct { UseCacheDb bool BaseDownloadDirPath string // Sort order of the results. Can be "date_desc" or "date_asc". SortOrder string SearchMode string SearchAiMode int // 0: filter AI works, 1: Display AI works RatingMode string ArtworkType string Configs *configs.Config MobileClient *PixivMobile RefreshToken string Notifier notify.Notifier // Progress indicators MainProgBar progress.ProgressBar DownloadProgressBars *[]*progress.DownloadProgressBar // contains filtered or unexported fields }
PixivToDl is the struct that contains the arguments of Pixiv download options.
func (*PixivMobileDlOptions) CancelCtx ¶ added in v1.1.0
func (p *PixivMobileDlOptions) CancelCtx()
CancelCtx releases the resources used and cancels the context of the PixivMobileDlOptions struct.
func (*PixivMobileDlOptions) CtxIsActive ¶ added in v1.1.0
func (p *PixivMobileDlOptions) CtxIsActive() bool
func (*PixivMobileDlOptions) GetCancel ¶
func (p *PixivMobileDlOptions) GetCancel() context.CancelFunc
func (*PixivMobileDlOptions) GetContext ¶
func (p *PixivMobileDlOptions) GetContext() context.Context
func (*PixivMobileDlOptions) SetContext ¶
func (p *PixivMobileDlOptions) SetContext(ctx context.Context)
func (*PixivMobileDlOptions) ValidateArgs ¶
func (p *PixivMobileDlOptions) ValidateArgs() error
ValidateArgs validates the arguments of the Pixiv download options.
Should be called after initialising the struct.
type UgoiraJson ¶ added in v1.1.0
type UgoiraJson struct { Metadata struct { Frames ugoira.UgoiraFramesJson `json:"frames"` ZipUrls struct { Medium string `json:"medium"` } `json:"zip_urls"` } `json:"ugoira_metadata"` }
type UserDetails ¶ added in v1.1.0
type UserDetails struct { ProfileImageUrls struct { Px16X16 string `json:"px_16x16"` Px50X50 string `json:"px_50x50"` Px170X170 string `json:"px_170x170"` } `json:"profile_image_urls"` 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"` // 0: SFW, 1: R18, 2: R18/R18G IsMailAuthorized bool `json:"is_mail_authorized"` RequirePolicyAgreement bool `json:"require_policy_agreement"` }