pixivmobile

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOAuthURL added in v1.1.0

func GetOAuthURL() (url string, codeVerifier string)

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

func S256

func S256(bytes []byte) string

Perform a S256 transformation method on a byte array

func VerifyOAuthCode added in v1.1.0

func VerifyOAuthCode(code, codeVerifier string, timeout int) (string, error)

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 OAuthTokenInfo struct {
	AccessToken string    // The access token that will be used to communicate with the Pixiv's Mobile API
	ExpiresAt   time.Time // The time when the access token expires
}

type OauthFlowJson added in v1.1.0

type OauthFlowJson struct {
	RefreshToken string `json:"refresh_token"`
}

type OauthJson added in v1.1.0

type OauthJson 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         UserDetails `json:"user"`
}

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

Jump to

Keyboard shortcuts

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