pikpak

package
v0.0.0-...-cb3a960 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClient = config.DefaultHTTPClient
View Source
var DriveAPIBaseURL = func() *url.URL {
	u, err := url.Parse("https://api-drive.mypikpak.com")
	if err != nil {
		panic(err)
	}
	return u
}()
View Source
var ErrByCode = map[int]string{
	3:    "invalid_argument",
	5:    "not_found",
	8:    "file_space_not_enough",
	9:    "captcha_invalid",
	16:   "unauthenticated",
	4002: "captcha_invalid",
	4022: "invalid_account_or_password",
	4126: "invalid_grant",
}
View Source
var UserAPIBaseURL = func() *url.URL {
	u, err := url.Parse("https://user.mypikpak.com")
	if err != nil {
		panic(err)
	}
	return u
}()
View Source
var WebAlgorithms = []string{
	"fyZ4+p77W1U4zcWBUwefAIFhFxvADWtT1wzolCxhg9q7etmGUjXr",
	"uSUX02HYJ1IkyLdhINEFcCf7l2",
	"iWt97bqD/qvjIaPXB2Ja5rsBWtQtBZZmaHH2rMR41",
	"3binT1s/5a1pu3fGsN",
	"8YCCU+AIr7pg+yd7CkQEY16lDMwi8Rh4WNp5",
	"DYS3StqnAEKdGddRP8CJrxUSFh",
	"crquW+4",
	"ryKqvW9B9hly+JAymXCIfag5Z",
	"Hr08T/NDTX1oSJfHk90c",
	"i",
}

Functions

func TranslateErr

func TranslateErr(err string) core.ErrorCode

func UpstreamErrorWithCause

func UpstreamErrorWithCause(cause error) *core.UpstreamError

Types

type APIClient

type APIClient struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewAPIClient

func NewAPIClient(conf *APIClientConfig) *APIClient

func (APIClient) AddFile

func (c APIClient) AddFile(params *AddFileParams) (APIResponse[AddFileData], error)

func (APIClient) DriveRequest

func (c APIClient) DriveRequest(method, path string, params request.Context, v ResponseEnvelop) (*http.Response, error)

func (APIClient) GetFile

func (c APIClient) GetFile(params *GetFileParams) (APIResponse[GetFileData], error)

func (APIClient) GetUser

func (c APIClient) GetUser(params *GetUserParams) (APIResponse[GetUserData], error)

func (APIClient) GetVIPInfo

func (c APIClient) GetVIPInfo(params *GetVIPInfoParams) (APIResponse[GetVIPInfoData], error)

func (APIClient) ListFiles

func (c APIClient) ListFiles(params *ListFilesParams) (APIResponse[ListFilesData], error)

func (APIClient) ListTasks

func (c APIClient) ListTasks(params *ListTasksParams) (APIResponse[ListTasksData], error)

func (APIClient) Trash

func (c APIClient) Trash(params *TrashParams) (APIResponse[TrashData], error)

func (APIClient) UserRequest

func (c APIClient) UserRequest(method, path string, params request.Context, v ResponseEnvelop) (*http.Response, error)

type APIClientConfig

type APIClientConfig struct {
	APIKey     string
	HTTPClient *http.Client
	UserAgent  string
}

type APIResponse

type APIResponse[T any] struct {
	Header     http.Header
	StatusCode int
	Data       T
}

type AddFileData

type AddFileData struct {
	ResponseContainer
	UploadType string          `json:"upload_type"` // 'UPLOAD_TYPE_URL'
	URL        AddFileDataURL  `json:"url"`
	Task       AddFileDataTask `json:"task"`
}

type AddFileDataTask

type AddFileDataTask struct {
	Kind       string `json:"kind"` // 'drive#task'
	Id         string `json:"id"`
	Name       string `json:"name"`
	Type       string `json:"type"` // 'offline'
	UserId     string `json:"user_id"`
	Statuses   []any  `json:"statuses"`
	StatusSize int    `json:"status_size"`
	Params     struct {
		PredictSpeed string `json:"predict_speed"`
		PredictType  string `json:"predict_type"` // '3'
	} `json:"params"`
	FileId      string    `json:"file_id"`
	FileName    string    `json:"file_name"`
	FileSize    string    `json:"file_size"`
	Message     string    `json:"message"`
	CreatedTime string    `json:"created_time"`
	UpdatedTime string    `json:"updated_time"`
	ThirdTaskId string    `json:"third_task_id"`
	Phase       FilePhase `json:"phase"`
	Progress    int       `json:"progress"`
	IconLink    string    `json:"icon_link"`
	Callback    string    `json:"callback"`
	Space       string    `json:"space"`
}

type AddFileDataURL

type AddFileDataURL struct {
	Kind string `json:"kind"` // 'upload#url'
}

type AddFileParams

type AddFileParams struct {
	Ctx
	Kind       FileKind         `json:"kind"`
	URL        AddFileParamsURL `json:"url"`
	UploadType string           `json:"upload_type"`
	FolderType string           `json:"folder_type"`
	Name       string           `json:"name,omitempty"`
	ParentId   string           `json:"parent_id,omitempty"`
}

type AddFileParamsURL

type AddFileParamsURL struct {
	URL string `json:"url"`
}

type AuthState

type AuthState struct {
	AccessToken  string `json:"atok"`
	RefreshToken string `json:"rtok"`
	UserId       string `json:"uid"`
	ExpiresAt    int64  `json:"exp"`
	CaptchaToken string `json:"-"`
}

func (AuthState) IsAuthed

func (as AuthState) IsAuthed() bool

func (AuthState) IsExpired

func (as AuthState) IsExpired() bool

func (AuthState) IsExpiring

func (as AuthState) IsExpiring() bool

type CaptchaToken

type CaptchaToken struct {
	Token     string
	ExpiresAt int64
}

func (CaptchaToken) IsExpiring

func (ct CaptchaToken) IsExpiring() bool

type Context

type Context interface {
	PreparePikpakHeader(header *http.Header)
}

type Ctx

type Ctx struct {
	request.Ctx
	// contains filtered or unexported fields
}

func (Ctx) GetDeviceId

func (ctx Ctx) GetDeviceId() string

func (Ctx) GetUser

func (ctx Ctx) GetUser() *PikpakUser

func (Ctx) PreparePikpakHeader

func (ctx Ctx) PreparePikpakHeader(header *http.Header)

type ErrorDetail

type ErrorDetail struct {
	Type         string `json:"@type"`
	StackEntries []any  `json:"stack_entries"`
	Detail       string `json:"detail"`
}

type File

type File struct {
	Apps  []any `json:"apps"`
	Audit struct {
		Message string `json:"message"`
		Status  string `json:"status"` // 'STATUS_OK'
		Title   string `json:"title"`
	} `json:"audit"`
	CreatedTime       string      `json:"created_time"`
	DeleteTime        string      `json:"delete_time"`
	FileCategory      string      `json:"file_category"`  // 'ARCHIVE' | 'OTHER'
	FileExtension     string      `json:"file_extension"` // '.zip'
	FolderType        string      `json:"folder_type"`    // 'NORMAL' | 'DOWNLOAD'
	Hash              string      `json:"hash"`
	IconLink          string      `json:"icon_link"`
	Id                string      `json:"id"`
	Kind              FileKind    `json:"kind"`
	Links             struct{}    `json:"links"`
	MD5Checksum       string      `json:"md5_checksum"`
	Medias            []FileMedia `json:"medias"`
	MimeType          string      `json:"mime_type"` // 'application/zip'
	ModifiedTime      string      `json:"modified_time"`
	Name              string      `json:"name"`
	OriginalFileIndex int         `json:"original_file_index"`
	OriginalUrl       string      `json:"original_url"`
	Params            struct {
		GlobalFileKind  string `json:"global_file_kind,omitempty"` // '1'
		GlobalFileRoot  string `json:"global_file_root,omitempty"`
		GlobalFileToken string `json:"global_file_token,omitempty"`
		PlatformIcon    string `json:"platform_icon"`
		URL             string `json:"url"`
	} `json:"params"`
	ParentId         string    `json:"parent_id"`
	Phase            FilePhase `json:"phase"`
	ReferenceEvents  []any     `json:"reference_events"`
	Revision         string    `json:"revision"` // '0'
	Size             string    `json:"size"`
	SortName         string    `json:"sort_name"`
	Space            string    `json:"space"`
	SpellName        []any     `json:"spell_name"`
	Starred          bool      `json:"starred"`
	Tags             []any     `json:"tags"`
	ThumbnailLink    string    `json:"thumbnail_link"`
	Trashed          bool      `json:"trashed"`
	UserId           string    `json:"user_id"`
	UserModifiedTime string    `json:"user_modified_time"`
	WebContentLink   string    `json:"web_content_link"`
	Writable         bool      `json:"writable"`
}

type FileKind

type FileKind string
const (
	FileKindFile   FileKind = "drive#file"
	FileKindFolder FileKind = "drive#folder"
)

type FileMedia

type FileMedia struct {
	MediaId   string `json:"media_id"`
	MediaName string `json:"media_name"`
	Video     struct {
		Height     int    `json:"height"`
		Width      int    `json:"width"`
		Duration   int    `json:"duration"`
		BitRate    int    `json:"bit_rate"`
		FrameRate  int    `json:"frame_rate"`
		VideoCodec string `json:"video_codec"`
		AudioCodec string `json:"audio_codec"`
		VideoType  string `json:"video_type"`
		HDRType    string `json:"hdr_type"` // 'HDR10'
	} `json:"video"`
	Link struct {
		URL    string `json:"url"`
		Token  string `json:"token"`
		Expire string `json:"expire"`
		Type   string `json:"type"`
	} `json:"link"`
	NeedMoreQuota  bool   `json:"need_more_quota"`
	VIPTypes       []any  `json:"vip_types"`
	RedirectLink   string `json:"redirect_link"`
	IconLink       string `json:"icon_link"`
	ExtIcon        string `json:"ext_icon"`
	IsDefault      bool   `json:"is_default"`
	Priority       int    `json:"priority"`
	IsOrigin       bool   `json:"is_origin"`
	ResolutionName string `json:"resolution_name"` // '480P'
	IsVisible      bool   `json:"is_visible"`
	Category       string `json:"category"` // 'category_origin' | 'category_transcode'
}

type FilePhase

type FilePhase string
const (
	FilePhaseRunning  FilePhase = "PHASE_TYPE_RUNNING"
	FilePhaseError    FilePhase = "PHASE_TYPE_ERROR"
	FilePhaseComplete FilePhase = "PHASE_TYPE_COMPLETE"
	FilePhasePending  FilePhase = "PHASE_TYPE_PENDING"
)

type GetFileData

type GetFileData struct {
	ResponseContainer
	File
}

type GetFileParams

type GetFileParams struct {
	Ctx
	FileId string
}

type GetUserData

type GetUserData struct {
	ResponseContainer
	CreatedAt         time.Time             `json:"created_at"`
	Email             string                `json:"email"`
	Name              string                `json:"name"`
	PasswordUpdatedAt time.Time             `json:"password_updated_at"`
	Sub               string                `json:"sub"`
	Providers         []GetUserDataProvider `json:"providers"`
}

type GetUserDataProvider

type GetUserDataProvider struct {
	Id             string `json:"id"`
	ProviderUserId string `json:"provider_user_id"`
	Name           string `json:"name"`
}

type GetUserParams

type GetUserParams struct {
	Ctx
}

type GetVIPInfoData

type GetVIPInfoData struct {
	Expire    string                  `json:"expire"`
	ExtType   string                  `json:"ext_type"`
	FeeRecord string                  `json:"fee_record"` // 'no_record'
	Kind      int                     `json:"kind"`       // 1 / 0
	Status    string                  `json:"status"`     // 'ok' / 'invalid'
	Type      VIPType                 `json:"type"`       // 'platinum' / 'novip'
	UserId    string                  `json:"user_id"`
	VIPItem   []GetVIPInfoDataVIPItem `json:"vipItem"`
}

type GetVIPInfoDataVIPItem

type GetVIPInfoDataVIPItem struct {
	Description string `json:"description"`
	Expire      string `json:"expire"`
	Status      string `json:"status"` // 'ok' / 'invalid'
	SurplusDay  int    `json:"surplus_day,omitempty"`
	Type        string `json:"type"` // 'regional'
}

type GetVIPInfoParams

type GetVIPInfoParams struct {
	Ctx
}

type ListFilesData

type ListFilesData struct {
	ResponseContainer
	Files           []File `json:"files"` // 'drive#fileList'
	Kind            string `json:"kind"`
	NextPageToken   string `json:"next_page_token"`
	SyncTime        string `json:"sync_time"`
	Version         string `json:"version"`
	VersionOutdated bool   `json:"version_outdated"`
}

type ListFilesParams

type ListFilesParams struct {
	Ctx
	ThumbnailSize string
	Limit         int
	ParentId      string
	WithAudit     bool
	PageToken     string
	Filters       map[string]map[string]any
}

type ListTasksData

type ListTasksData struct {
	ResponseContainer
	ExpiresIn     int    `json:"expires_in"`
	NextPageToken string `json:"next_page_token"`
	Tasks         []Task `json:"tasks"`
}

type ListTasksParams

type ListTasksParams struct {
	Ctx
	With          string
	Type          string // 'offline'
	ThumbnailSize string
	Limit         int // default 10000
	Filters       map[string]map[string]any
	PageToken     string
}
type LockedFileLink string

type LoginParams

type LoginParams struct {
	Ctx
}

type PikpakUser

type PikpakUser struct {
	Username string
	Password string
}

func (PikpakUser) GetDeviceId

func (u PikpakUser) GetDeviceId() string

type ResponseContainer

type ResponseContainer struct {
	Err        string        `json:"error"`
	ErrCode    int           `json:"error_code"`
	ErrDesc    string        `json:"error_description"`
	ErrURL     string        `json:"error_url"`
	ErrDetails []ErrorDetail `json:"error_details"`
}

func (*ResponseContainer) Error

func (e *ResponseContainer) Error() string

func (*ResponseContainer) GetError

func (r *ResponseContainer) GetError() *ResponseContainer

func (*ResponseContainer) HasError

func (r *ResponseContainer) HasError() bool

type ResponseEnvelop

type ResponseEnvelop interface {
	HasError() bool
	GetError() *ResponseContainer
}

type StoreClient

type StoreClient struct {
	Name store.StoreName
	// contains filtered or unexported fields
}

func NewStoreClient

func NewStoreClient(config *StoreClientConfig) *StoreClient

func (*StoreClient) AddMagnet

func (s *StoreClient) AddMagnet(params *store.AddMagnetParams) (*store.AddMagnetData, error)

func (*StoreClient) CheckMagnet

func (s *StoreClient) CheckMagnet(params *store.CheckMagnetParams) (*store.CheckMagnetData, error)
func (s *StoreClient) GenerateLink(params *store.GenerateLinkParams) (*store.GenerateLinkData, error)

func (*StoreClient) GetMagnet

func (s *StoreClient) GetMagnet(params *store.GetMagnetParams) (*store.GetMagnetData, error)

func (*StoreClient) GetName

func (s *StoreClient) GetName() store.StoreName

func (*StoreClient) GetUser

func (s *StoreClient) GetUser(params *store.GetUserParams) (*store.User, error)

func (*StoreClient) GetWebz

func (s *StoreClient) GetWebz(params *store.GetWebzParams) (*store.GetWebzData, error)

func (*StoreClient) ListMagnets

func (s *StoreClient) ListMagnets(params *store.ListMagnetsParams) (*store.ListMagnetsData, error)

func (*StoreClient) ListWebz

func (s *StoreClient) ListWebz(params *store.ListWebzParams) (*store.ListWebzData, error)

func (*StoreClient) RemoveMagnet

func (s *StoreClient) RemoveMagnet(params *store.RemoveMagnetParams) (*store.RemoveMagnetData, error)

type StoreClientConfig

type StoreClientConfig struct {
	HTTPClient *http.Client
	UserAgent  string
}

type Task

type Task struct {
	Callback    string `json:"callback"`
	CreatedTime string `json:"created_time"`
	FileId      string `json:"file_id"`
	FileName    string `json:"file_name"`
	FileSize    string `json:"file_size"`
	IconLink    string `json:"icon_link"`
	Id          string `json:"id"`
	Kind        string `json:"kind"`
	Message     string `json:"message"`
	Name        string `json:"name"`
	Params      struct {
		Age         string `json:"age"`
		MimeType    string `json:"mime_type"`
		PredictType string `json:"predict_type"` // '1'
		URL         string `json:"url"`
	} `json:"params"`
	Phase             FilePhase `json:"phase"`
	Progress          int       `json:"progress"`
	ReferenceResource struct {
		Type  string `json:"@type"`
		Audit struct {
			Message string `json:"message"`
			Status  string `json:"status"` // 'STATUS_OK'
			Title   string `json:"title"`
		} `json:"audit"`
		Hash     string `json:"hash"`
		IconLink string `json:"icon_link"`
		Id       string `json:"id"`
		Kind     string `json:"kind"`
		Medias   []any  `json:"medias"`
		MimeType string `json:"mime_type"`
		Name     string `json:"name"`
		Params   struct {
			PlatformIcon string `json:"platform_icon"`
			URL          string `json:"url"`
		} `json:"params"`
		ParentId      string    `json:"parent_id"`
		Phase         FilePhase `json:"phase"`
		Size          string    `json:"size"`
		Space         string    `json:"space"`
		Starred       bool      `json:"starred"`
		Tags          []any     `json:"tags"`
		ThumbnailLink string    `json:"thumbnail_link"`
	}
	Space       string `json:"space"`
	StatusSize  int    `json:"status_size"`
	Statuses    []any  `json:"statuses"`
	ThirdTaskId string `json:"third_task_id"`
	Type        string `json:"type"` // 'offline'
	UpdatedTime string `json:"updated_time"`
	UserId      string `json:"user_id"`
}

type TrashData

type TrashData struct {
	ResponseContainer
	TaskId string `json:"task_id"`
}

type TrashParams

type TrashParams struct {
	Ctx
	Ids []string `json:"ids"`
}

type VIPType

type VIPType string
const (
	VIPTypePlatinum VIPType = "platinum"
	VIPTypeNovip    VIPType = "novip"
)

Jump to

Keyboard shortcuts

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