application

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePKCEPair

func GeneratePKCEPair() (verifier, challenge string, err error)

func ParseUID

func ParseUID(raw string) (int64, error)

func RandomURLToken

func RandomURLToken(size int) (string, error)

func ResolveRefreshToken

func ResolveRefreshToken(store auth.AuthStore, requestedUserID int64, requestedToken string, refreshTokenEnv func() string) (string, error)

Types

type AccountAddRequest

type AccountAddRequest struct {
	TokenInput         string
	HTTPSProxyOverride *string
}

type AccountCheckRequest

type AccountCheckRequest struct {
	UserID             int64
	HTTPSProxyOverride *string
}

type AccountListResult

type AccountListResult struct {
	DefaultUserID int64
	Accounts      []AccountResult
}

type AccountResult

type AccountResult struct {
	UserID   int64  `json:"user_id,omitempty"`
	Username string `json:"username,omitempty"`
	Default  bool   `json:"default"`
	HasToken bool   `json:"has_token"`
	Warning  string `json:"warning,omitempty"`
}

type AccountService

type AccountService struct {
	Auth            AuthRepository
	LoadRuntime     func() (config.RuntimeConfig, error)
	RefreshTokenEnv func() string
	NewClient       AuthenticatedPixivFactory
}

func (AccountService) Add

func (AccountService) Check

func (s AccountService) Check(ctx context.Context, userID int64) (AccountResult, error)

func (AccountService) CheckWithRequest

func (s AccountService) CheckWithRequest(ctx context.Context, req AccountCheckRequest) (AccountResult, error)

func (AccountService) List

func (AccountService) Remove

func (s AccountService) Remove(userID int64) (AccountResult, int64, error)

func (AccountService) Use

func (s AccountService) Use(userID int64) (int64, error)

type ArtworkClient

type ArtworkClient interface {
	SearchIllust(context.Context, string, string, string, string, int) (*pixiv.IllustList, error)
	IllustDetail(context.Context, int64) (*pixiv.IllustDetail, error)
	IllustRanking(context.Context, string, string, int) (*pixiv.IllustList, error)
	IllustRecommended(context.Context, int) (*pixiv.IllustList, error)
}

type ArtworkService

type ArtworkService struct {
	Resolver ClientResolver
}

func (ArtworkService) Detail

func (s ArtworkService) Detail(ctx context.Context, clientReq ClientRequest, id int64) (*pixiv.IllustDetail, bool, error)

func (ArtworkService) Ranking

func (ArtworkService) Recommended

func (ArtworkService) Search

type AuthRepository

type AuthRepository interface {
	Load() (auth.AuthStore, error)
	Save(auth.AuthStore) error
}

type AuthenticatedPixivClient

type AuthenticatedPixivClient interface {
	Refresh(context.Context) error
	RefreshTokenValue() string
	UserID() int64
	UserName() string
	UserDetail(context.Context, int64) (*pixiv.User, error)
}

type AuthenticatedPixivFactory

type AuthenticatedPixivFactory func(config.RuntimeConfig) (AuthenticatedPixivClient, error)

type ClientBundle

type ClientBundle struct {
	Auth     AuthenticatedPixivClient
	Artwork  ArtworkClient
	Download DownloadClient
}

type ClientRequest

type ClientRequest struct {
	UserID                   int64
	RefreshToken             string
	HTTPSProxyOverride       *string
	DownloadPathOverride     *string
	FilenameTemplateOverride *string
	JSONOverride             *bool
	NeedsAuth                bool
}

type ClientResolver

type ClientResolver struct {
	Auth            AuthRepository
	LoadRuntime     func() (config.RuntimeConfig, error)
	RefreshTokenEnv func() string
	NewClient       PixivClientFactory
}

func (ClientResolver) Resolve

type ClientSession

type ClientSession struct {
	Client  ClientBundle
	Config  config.RuntimeConfig
	JSONOut bool
}

type ConfigMutationResult

type ConfigMutationResult struct {
	Alias       string
	EnvOverride string
	HasOverride bool
}

type ConfigService

type ConfigService struct {
	Store ConfigStore
}

func (ConfigService) Get

func (s ConfigService) Get(alias string) (config.SettingValue, error)

func (ConfigService) Path

func (s ConfigService) Path() (string, error)

func (ConfigService) Set

func (s ConfigService) Set(alias, raw string) (ConfigMutationResult, error)

func (ConfigService) Unset

func (s ConfigService) Unset(alias string) (ConfigMutationResult, error)

type ConfigStore

type ConfigStore interface {
	Path() (string, error)
	Get(string) (config.SettingValue, error)
	Set(string, string) (ConfigMutationResult, error)
	Unset(string) (ConfigMutationResult, error)
}

type DownloadClient

type DownloadClient interface {
	download.PixivClient
}

type DownloadFactory

type DownloadFactory func(DownloadClient, config.RuntimeConfig) Downloader

type DownloadService

type DownloadService struct {
	Resolver      ClientResolver
	NewDownloader DownloadFactory
}

func (DownloadService) Download

func (s DownloadService) Download(ctx context.Context, clientReq ClientRequest, ids []int64) ([]download.DownloadedArtwork, bool, error)

type Downloader

type Downloader interface {
	Download(context.Context, []int64) ([]download.DownloadedArtwork, error)
}

type LoginCompleteRequest

type LoginCompleteRequest struct {
	Code               string
	Verifier           string
	OAuthBase          string
	UseAfterLogin      bool
	HTTPSProxyOverride *string
}

type LoginService

type LoginService struct {
	Auth        AuthRepository
	LoadRuntime func() (config.RuntimeConfig, error)
	NewOAuth    OAuthClientFactory
}

func (LoginService) Complete

func (LoginService) Start

func (s LoginService) Start() (LoginStart, error)

type LoginStart

type LoginStart struct {
	Verifier  string
	Challenge string
	State     string
}

type OAuthClientFactory

type OAuthClientFactory func(config.RuntimeConfig, string) (OAuthExchanger, error)

type OAuthExchanger

type OAuthExchanger interface {
	ExchangeAuthorizationCode(context.Context, string, string) (OAuthToken, error)
}

type OAuthToken

type OAuthToken struct {
	RefreshToken string
	UserID       int64
	Username     string
}

type PixivClientFactory

type PixivClientFactory func(config.RuntimeConfig) (ClientBundle, error)

type RankingRequest

type RankingRequest struct {
	Client ClientRequest
	Mode   string
	Date   string
	Offset int
}

type RecommendedRequest

type RecommendedRequest struct {
	Client ClientRequest
	Offset int
}

type SearchRequest

type SearchRequest struct {
	Client   ClientRequest
	Word     string
	Target   string
	Sort     string
	Duration string
	Offset   int
}

type Services

type Services struct {
	Account  AccountService
	Config   ConfigService
	Artwork  ArtworkService
	Download DownloadService
	Login    LoginService
}

Jump to

Keyboard shortcuts

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