pikpakgo

package module
v0.0.0-...-981c90c Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 11 Imported by: 0

README

pikpak-go

Implementation pikpak sdk using golang.
This is an unofficial API. If there is any infringement, please contact me to delete it within 24 hours.
If you have any other API requirements, please leave a message and I will use my free time to implement it

features

  • Login
  • FileList
  • GetFile
  • CreateFolder
  • RenameFile
  • BatchDeleteFile
  • BatchTrashFile
  • BatchMoveFile
  • GetDownloadUrl
  • OfflineDownload
  • OfflineList
  • OfflineRetry
  • OfflineRemove
  • WaitForOfflineDownloadComplete
  • EmptyTrash
  • StorageInfo
  • CaptchaToken
  • InviteInfo
  • MeInfo

Work in progress

  • BatchUploadFiles

Reference project

License

This work is released under the MIT license

Documentation

Index

Constants

View Source
const (
	ClientId        = "YUMx5nI8ZU8Ap8pm"
	ClientSecret    = "dbw2OtmVEeuUvIptb1Coygx"
	PikpakUserHost  = "https://user.mypikpak.com"
	PikpakDriveHost = "https://api-drive.mypikpak.com"
	PackageName     = `mypikpak.com`
	ClientVersion   = `1.0.0`

	// AlgoObjectsString this is information from pikpak website js file. searching keyword: calculateCaptchaSign
	// https://mypikpak.com/drive/main.e3f02a36.js
	AlgoObjectsString = `` /* 535-byte string literal not displayed */

)
View Source
const (
	KindOfFolder        = "drive#folder"
	KindOfFile          = "drive#file"
	KindOfFileList      = "drive#fileList"
	KindOfResumable     = "drive#resumable"
	KindOfForm          = "drive#form"
	ThumbnailSizeS      = "SIZE_SMALL"
	ThumbnailSizeM      = "SIZE_MEDIUM"
	ThumbnailSizeL      = "SIZE_LARGE"
	PhaseTypeComplete   = "PHASE_TYPE_COMPLETE"
	PhaseTypeRunning    = "PHASE_TYPE_RUNNING"
	PhaseTypeError      = "PHASE_TYPE_ERROR"
	PhaseTypePending    = "PHASE_TYPE_PENDING"
	UploadTypeURL       = "UPLOAD_TYPE_URL"
	UploadTypeForm      = "UPLOAD_TYPE_FORM"
	UploadTypeResumable = "UPLOAD_TYPE_RESUMABLE"
	FolderTypeDownload  = "DOWNLOAD"
	FileTypeOffline     = "offline"
	CreateTypeRetry     = "RETRY"
	ListLimit           = 100
)

Types of things in Item

Variables

View Source
var (
	ErrSpaceNotEnough                = errors.New("space not enough")
	ErrDailyCreateLimit              = errors.New("daily create limit")
	ErrFileDuplicateName             = errors.New("file duplicate name")
	ErrWaitForOfflineDownloadTimeout = errors.New("wait for offline download timeout")
	ErrFolderNotFound                = errors.New("folder not found")
)
View Source
var (
	AlgoObjects []AlgoObject
)

Functions

This section is empty.

Types

type About

type About struct {
	Kind      string `json:"kind,omitempty"` // "drive#about"
	Quota     *Quota `json:"quota,omitempty"`
	ExpiresAt string `json:"expires_at,omitempty"`
	Quotas    struct {
	} `json:"quotas,omitempty"` // maybe []*Quota?
}

About informs drive status

type AlgoObject

type AlgoObject struct {
	Alg  string `json:"alg"`
	Salt string `json:"salt"`
}

type ArchiveFileList

type ArchiveFileList struct {
	Status      string           `json:"status,omitempty"`       // "OK"
	StatusText  string           `json:"status_text,omitempty"`  // ""
	TaskID      string           `json:"task_id,omitempty"`      // ""
	CurrentPath string           `json:"current_path,omitempty"` // ""
	Title       string           `json:"title,omitempty"`
	FileSize    int64            `json:"file_size,omitempty"`
	Gcid        string           `json:"gcid,omitempty"` // same as File.Hash
	Files       []*FileInArchive `json:"files,omitempty"`
}

ArchiveFileList is a response to RequestArchiveFileList

type CaptchaMeta

type CaptchaMeta struct {
	CaptchaSign   string `json:"captcha_sign"`
	ClientVersion string `json:"client_version"`
	PackageName   string `json:"package_name"`
	Timestamp     string `json:"timestamp"`
	UserID        string `json:"user_id"`
}

type DecompressResult

type DecompressResult struct {
	Status       string `json:"status,omitempty"` // "OK"
	StatusText   string `json:"status_text,omitempty"`
	TaskID       string `json:"task_id,omitempty"`   // same as File.Id
	FilesNum     int    `json:"files_num,omitempty"` // number of files in archive
	RedirectLink string `json:"redirect_link,omitempty"`
}

DecompressResult is a response to RequestDecompress

type Error

type Error struct {
	Reason  string `json:"error"` // short description of the reason, e.g. "file_name_empty" "invalid_request"
	Code    int    `json:"error_code"`
	URL     string `json:"error_url,omitempty"`
	Message string `json:"error_description,omitempty"`
	// can have either of `error_details` or `details“
	ErrorDetails []*ErrorDetails `json:"error_details,omitempty"`
	Details      []*ErrorDetails `json:"details,omitempty"`
}

Error details api error from pikpak

func (*Error) Error

func (e *Error) Error() string

Error returns a string for the error and satisfies the error interface

type ErrorDetails

type ErrorDetails struct {
	Type     string `json:"@type,omitempty"`
	Reason   string `json:"reason,omitempty"`
	Domain   string `json:"domain,omitempty"`
	Metadata struct {
	} `json:"metadata,omitempty"` // TODO: undiscovered yet
	Locale       string        `json:"locale,omitempty"` // e.g. "en"
	Message      string        `json:"message,omitempty"`
	StackEntries []interface{} `json:"stack_entries,omitempty"` // TODO: undiscovered yet
	Detail       string        `json:"detail,omitempty"`
}

ErrorDetails contains further details of api error

type File

type File struct {
	Apps              []*FileApp    `json:"apps,omitempty"`
	Audit             *FileAudit    `json:"audit,omitempty"`
	Collection        string        `json:"collection,omitempty"` // TODO
	CreatedTime       Time          `json:"created_time,omitempty"`
	DeleteTime        Time          `json:"delete_time,omitempty"`
	FileCategory      string        `json:"file_category,omitempty"`
	FileExtension     string        `json:"file_extension,omitempty"`
	FolderType        string        `json:"folder_type,omitempty"`
	Hash              string        `json:"hash,omitempty"` // sha1 but NOT a valid file hash. looks like a torrent hash
	IconLink          string        `json:"icon_link,omitempty"`
	ID                string        `json:"id,omitempty"`
	Kind              string        `json:"kind,omitempty"` // "drive#file"
	Links             *FileLinks    `json:"links,omitempty"`
	Md5Checksum       string        `json:"md5_checksum,omitempty"`
	Medias            []*Media      `json:"medias,omitempty"`
	MimeType          string        `json:"mime_type,omitempty"`
	ModifiedTime      Time          `json:"modified_time,omitempty"` // updated when renamed or moved
	Name              string        `json:"name,omitempty"`
	OriginalFileIndex int           `json:"original_file_index,omitempty"` // TODO
	OriginalURL       string        `json:"original_url,omitempty"`
	Params            *FileParams   `json:"params,omitempty"`
	ParentID          string        `json:"parent_id,omitempty"`
	Phase             string        `json:"phase,omitempty"`
	Revision          int           `json:"revision,omitempty,string"`
	Size              int64         `json:"size,omitempty,string"`
	SortName          string        `json:"sort_name,omitempty"`
	Space             string        `json:"space,omitempty"`
	SpellName         []interface{} `json:"spell_name,omitempty"` // TODO maybe list of something?
	Starred           bool          `json:"starred,omitempty"`
	ThumbnailLink     string        `json:"thumbnail_link,omitempty"`
	Trashed           bool          `json:"trashed,omitempty"`
	UserID            string        `json:"user_id,omitempty"`
	UserModifiedTime  Time          `json:"user_modified_time,omitempty"`
	WebContentLink    string        `json:"web_content_link,omitempty"`
	Writable          bool          `json:"writable,omitempty"`
}

File is a basic element representing a single file object

There are two types of download links, 1) one from File.WebContentLink or File.Links.ApplicationOctetStream.URL and 2) the other from File.Medias[].Link.URL. Empirically, 2) is less restrictive to multiple concurrent range-requests for a single file, i.e. supports for higher `--multi-thread-streams=N`. However, it is not generally applicable as it is only for meadia.

type FileApp

type FileApp struct {
	ID            string        `json:"id,omitempty"`   // "decompress" for rar files
	Name          string        `json:"name,omitempty"` // decompress" for rar files
	Access        []interface{} `json:"access,omitempty"`
	Link          string        `json:"link,omitempty"` // "https://mypikpak.com/drive/decompression/{File.Id}?gcid={File.Hash}\u0026wv-style=topbar%3Ahide"
	RedirectLink  string        `json:"redirect_link,omitempty"`
	VipTypes      []interface{} `json:"vip_types,omitempty"`
	NeedMoreQuota bool          `json:"need_more_quota,omitempty"`
	IconLink      string        `json:"icon_link,omitempty"`
	IsDefault     bool          `json:"is_default,omitempty"`
	Params        struct {
	} `json:"params,omitempty"` // TODO
	CategoryIds []interface{} `json:"category_ids,omitempty"`
	AdSceneType int           `json:"ad_scene_type,omitempty"`
	Space       string        `json:"space,omitempty"`
	Links       struct {
	} `json:"links,omitempty"` // TODO
}

FileApp includes parameters for instant open

type FileAudit

type FileAudit struct {
	Status  string `json:"status,omitempty"` // "STATUS_OK"
	Message string `json:"message,omitempty"`
	Title   string `json:"title,omitempty"`
}

FileAudit contains audit information for the file

type FileInArchive

type FileInArchive struct {
	Index    int    `json:"index,omitempty"`
	Filename string `json:"filename,omitempty"`
	Filesize string `json:"filesize,omitempty"`
	MimeType string `json:"mime_type,omitempty"`
	Gcid     string `json:"gcid,omitempty"`
	Kind     string `json:"kind,omitempty"`
	IconLink string `json:"icon_link,omitempty"`
	Path     string `json:"path,omitempty"`
}

FileInArchive is a basic element in archive

type FileLinks struct {
	ApplicationOctetStream *Link `json:"application/octet-stream,omitempty"`
}

FileLinks includes links to file at backend

type FileList

type FileList struct {
	Kind            string  `json:"kind,omitempty"` // drive#fileList
	Files           []*File `json:"files,omitempty"`
	NextPageToken   string  `json:"next_page_token"`
	Version         string  `json:"version,omitempty"`
	VersionOutdated bool    `json:"version_outdated,omitempty"`
}

FileList contains a list of File elements

type FileParams

type FileParams struct {
	Duration     int64  `json:"duration,omitempty,string"` // in seconds
	Height       int    `json:"height,omitempty,string"`
	Platform     string `json:"platform,omitempty"` // "Upload"
	PlatformIcon string `json:"platform_icon,omitempty"`
	URL          string `json:"url,omitempty"`
	Width        int    `json:"width,omitempty,string"`
}

FileParams includes parameters for instant open

type FileTreeNode

type FileTreeNode struct {
	Paths []string
	File  *File
}

type Filters

type Filters struct {
	Phase        map[string]string `json:"phase,omitempty"`         // "in" or "eq"
	Trashed      map[string]bool   `json:"trashed,omitempty"`       // "eq"
	Kind         map[string]string `json:"kind,omitempty"`          // "eq"
	Starred      map[string]bool   `json:"starred,omitempty"`       // "eq"
	ModifiedTime map[string]string `json:"modified_time,omitempty"` // "gt" or "lt"
}

Filters contains parameters for filters when listing.

possible operators * in: a list of comma-separated string * eq: "true" or "false" * gt or lt: time format string, e.g. "2023-01-28T10:56:49.757+08:00"

func (*Filters) Set

func (f *Filters) Set(field, operator, value string)

Set sets filter values using field name, operator and corresponding value

type Form

type Form struct {
	Headers    struct{} `json:"headers"`
	Kind       string   `json:"kind"`   // "drive#form"
	Method     string   `json:"method"` // "POST"
	MultiParts struct {
		OSSAccessKeyID string `json:"OSSAccessKeyId"`
		Signature      string `json:"Signature"`
		Callback       string `json:"callback"`
		Key            string `json:"key"`
		Policy         string `json:"policy"`
		XUserData      string `json:"x:user_data"`
	} `json:"multi_parts"`
	URL string `json:"url"`
}

Form contains parameters for upload by multipart/form-data

type InviteInfo

type InviteInfo struct {
	CheckFreeSend string `json:"check_free_send"`
	Data          struct {
		Expire string `json:"expire"`
		Status string `json:"status"`
		Type   string `json:"type"`
		UserID string `json:"user_id"`
	} `json:"data"`
	FreeDays    int  `json:"free_days"`
	InvitedDays int  `json:"invited_days"`
	Updated     bool `json:"updated"`
}
type Link struct {
	URL    string `json:"url"`
	Token  string `json:"token"`
	Expire Time   `json:"expire"`
	Type   string `json:"type,omitempty"`
}

Link contains a download URL for opening files

func (*Link) Valid

func (l *Link) Valid() bool

Valid reports whether l is non-nil, has an URL, and is not expired.

type MeInfo

type MeInfo struct {
	Sub       string `json:"sub"`
	Name      string `json:"name"`
	Picture   string `json:"picture"`
	Email     string `json:"email"`
	Providers []struct {
		ID             string `json:"id"`
		ProviderUserID string `json:"provider_user_id"`
		Name           string `json:"name"`
	} `json:"providers"`
	Password          string    `json:"password"`
	Status            string    `json:"status"`
	CreatedAt         time.Time `json:"created_at"`
	PasswordUpdatedAt time.Time `json:"password_updated_at"`
}

type Media

type Media struct {
	MediaID   string `json:"media_id,omitempty"`
	MediaName string `json:"media_name,omitempty"`
	Video     struct {
		Height     int    `json:"height,omitempty"`
		Width      int    `json:"width,omitempty"`
		Duration   int64  `json:"duration,omitempty"`
		BitRate    int    `json:"bit_rate,omitempty"`
		FrameRate  int    `json:"frame_rate,omitempty"`
		VideoCodec string `json:"video_codec,omitempty"`
		AudioCodec string `json:"audio_codec,omitempty"`
		VideoType  string `json:"video_type,omitempty"`
	} `json:"video,omitempty"`
	Link           *Link         `json:"link,omitempty"`
	NeedMoreQuota  bool          `json:"need_more_quota,omitempty"`
	VipTypes       []interface{} `json:"vip_types,omitempty"` // TODO maybe list of something?
	RedirectLink   string        `json:"redirect_link,omitempty"`
	IconLink       string        `json:"icon_link,omitempty"`
	IsDefault      bool          `json:"is_default,omitempty"`
	Priority       int           `json:"priority,omitempty"`
	IsOrigin       bool          `json:"is_origin,omitempty"`
	ResolutionName string        `json:"resolution_name,omitempty"`
	IsVisible      bool          `json:"is_visible,omitempty"`
	Category       string        `json:"category,omitempty"`
}

Media contains info about supported version of media, e.g. original, transcoded, etc

type NewFile

type NewFile struct {
	File       *File      `json:"file,omitempty"`
	Form       *Form      `json:"form,omitempty"`
	Resumable  *Resumable `json:"resumable,omitempty"`
	Task       *Task      `json:"task,omitempty"`        // null in this case
	UploadType string     `json:"upload_type,omitempty"` // "UPLOAD_TYPE_FORM" or "UPLOAD_TYPE_RESUMABLE"
}

NewFile is a response to RequestNewFile

type NewTask

type NewTask struct {
	UploadType string `json:"upload_type,omitempty"` // "UPLOAD_TYPE_URL"
	File       *File  `json:"file,omitempty"`        // null in this case
	Task       *Task  `json:"task,omitempty"`
	URL        *URL   `json:"url,omitempty"` // {"kind": "upload#url"}
}

NewTask is a response to RequestNewTask

type PikPakClient

type PikPakClient struct {
	// contains filtered or unexported fields
}

func NewPikPakClient

func NewPikPakClient(username, password string) (*PikPakClient, error)

func (*PikPakClient) About

func (c *PikPakClient) About() (*About, error)

func (*PikPakClient) BatchDeleteFiles

func (c *PikPakClient) BatchDeleteFiles(ids []string) error

func (*PikPakClient) BatchMoveFiles

func (c *PikPakClient) BatchMoveFiles(ids []string, folderId string) error

func (*PikPakClient) BatchTrashFiles

func (c *PikPakClient) BatchTrashFiles(ids []string) error

func (*PikPakClient) CaptchaToken

func (c *PikPakClient) CaptchaToken(action string) error

func (*PikPakClient) CreateFolder

func (c *PikPakClient) CreateFolder(name string, parentId string) (*File, error)

func (*PikPakClient) EmptyTrash

func (c *PikPakClient) EmptyTrash() error

func (*PikPakClient) FileExists

func (c *PikPakClient) FileExists(absPath string) (bool, error)

func (*PikPakClient) FileList

func (c *PikPakClient) FileList(limit int, parentId string, nextPageToken string) (*FileList, error)

func (*PikPakClient) FileListAll

func (c *PikPakClient) FileListAll(fileId string) ([]*File, error)

func (*PikPakClient) FolderPathToID

func (c *PikPakClient) FolderPathToID(absPath string, autoCreate bool) (string, error)

FolderPathToID the path format: /home/test

func (*PikPakClient) GetDownloadUrl

func (c *PikPakClient) GetDownloadUrl(id string) (string, error)

func (*PikPakClient) GetFile

func (c *PikPakClient) GetFile(id string) (*File, error)

func (*PikPakClient) InviteInfo

func (c *PikPakClient) InviteInfo() (*InviteInfo, error)

func (*PikPakClient) Login

func (c *PikPakClient) Login() error

func (*PikPakClient) Logout

func (c *PikPakClient) Logout() error

func (*PikPakClient) Me

func (c *PikPakClient) Me() (*MeInfo, error)

func (*PikPakClient) OfflineDownload

func (c *PikPakClient) OfflineDownload(name string, fileUrl string, parentId string) (*NewTask, error)

func (*PikPakClient) OfflineList

func (c *PikPakClient) OfflineList(limit int, nextPageToken string) (*TaskList, error)

func (*PikPakClient) OfflineListIterator

func (c *PikPakClient) OfflineListIterator(callback func(task *Task) bool) error

func (*PikPakClient) OfflineRemove

func (c *PikPakClient) OfflineRemove(taskId []string, deleteFiles bool) error

func (*PikPakClient) OfflineRemoveAll

func (c *PikPakClient) OfflineRemoveAll(phases []string, deleteFiles bool) error

OfflineRemoveAll remove offline tasks

  • phase PhaseTypeError...

func (*PikPakClient) OfflineRetry

func (c *PikPakClient) OfflineRetry(taskId string) error

func (*PikPakClient) RemoveFolder

func (c *PikPakClient) RemoveFolder(absPath string) error

func (*PikPakClient) RenameFile

func (c *PikPakClient) RenameFile(id string, name string) (*File, error)

func (*PikPakClient) WaitForOfflineDownloadComplete

func (c *PikPakClient) WaitForOfflineDownloadComplete(taskId string, timeout time.Duration, progressFn func(*Task)) (*Task, error)

func (*PikPakClient) WalkDir

func (c *PikPakClient) WalkDir(fileId string, fn func(file *File) bool) error

type Quota

type Quota struct {
	Kind           string `json:"kind,omitempty"`                    // "drive#quota"
	Limit          int64  `json:"limit,omitempty,string"`            // limit in bytes
	Usage          int64  `json:"usage,omitempty,string"`            // bytes in use
	UsageInTrash   int64  `json:"usage_in_trash,omitempty,string"`   // bytes in trash but this seems not working
	PlayTimesLimit int64  `json:"play_times_limit,omitempty,string"` // maybe in seconds
	PlayTimesUsage int64  `json:"play_times_usage,omitempty,string"` // maybe in seconds
}

Quota informs drive quota

type RequestArchiveFileList

type RequestArchiveFileList struct {
	Gcid     string `json:"gcid,omitempty"`     // same as api.File.Hash
	Path     string `json:"path,omitempty"`     // "" by default
	Password string `json:"password,omitempty"` // "" by default
	FileID   string `json:"file_id,omitempty"`
}

RequestArchiveFileList is to request for a list of files in archive

POST https://api-drive.mypikpak.com/decompress/v1/list

type RequestBatch

type RequestBatch struct {
	Ids []string          `json:"ids,omitempty"`
	To  map[string]string `json:"to,omitempty"`
}

RequestBatch is to request for batch actions

type RequestDecompress

type RequestDecompress struct {
	Gcid          string           `json:"gcid,omitempty"`     // same as File.Hash
	Password      string           `json:"password,omitempty"` // ""
	FileID        string           `json:"file_id,omitempty"`
	Files         []*FileInArchive `json:"files,omitempty"` // can request selected files to be decompressed
	DefaultParent bool             `json:"default_parent,omitempty"`
}

RequestDecompress is to request for decompress of archive files

type RequestFileList

type RequestFileList struct {
	ParentId      string `json:"parent_id,omitempty"`
	ThumbnailSize string `json:"thumbnail_size,omitempty"`
	Limit         string `json:"limit,omitempty"`
	WithAudit     string `json:"with_audit,omitempty"`
	PageToken     string `json:"page_token,omitempty"`
	Filters       string `json:"filters,omitempty"`
}

type RequestGetCaptcha

type RequestGetCaptcha struct {
	Action      string      `json:"action"`
	ClientID    string      `json:"client_id"`
	DeviceID    string      `json:"device_id"`
	Meta        CaptchaMeta `json:"meta"`
	RedirectURI string      `json:"redirect_uri"`
}

type RequestLogin

type RequestLogin struct {
	ClientId     string `json:"client_id,omitempty"`
	ClientSecret string `json:client_secret,omitempty`
	Username     string `json:"username,omitempty"`
	Password     string `json:"password,omitempty"`
}

------------------------------------------------------------

type RequestLogout

type RequestLogout struct {
	Token string `json:"token,omitempty"`
}

type RequestNewFile

type RequestNewFile struct {
	// always required
	Kind       string `json:"kind"` // "drive#folder" or "drive#file"
	Name       string `json:"name"`
	ParentID   string `json:"parent_id"`
	FolderType string `json:"folder_type"`
	// only when uploading a new file
	Hash       string            `json:"hash,omitempty"`      // sha1sum
	Resumable  map[string]string `json:"resumable,omitempty"` // {"provider": "PROVIDER_ALIYUN"}
	Size       int64             `json:"size,omitempty"`
	UploadType string            `json:"upload_type,omitempty"` // "UPLOAD_TYPE_FORM" or "UPLOAD_TYPE_RESUMABLE"
}

RequestNewFile is to request for creating a new `drive#folder` or `drive#file`

type RequestNewTask

type RequestNewTask struct {
	Kind       string `json:"kind,omitempty"` // "drive#file"
	Name       string `json:"name,omitempty"`
	ParentID   string `json:"parent_id,omitempty"`
	UploadType string `json:"upload_type,omitempty"` // "UPLOAD_TYPE_URL"
	URL        *URL   `json:"url,omitempty"`         // {"url": downloadUrl}
	FolderType string `json:"folder_type,omitempty"` // "" if parent_id else "DOWNLOAD"
}

RequestNewTask is to request for creating a new task like offline downloads

Name and ParentID can be left empty.

type RequestShare

type RequestShare struct {
	FileIds        []string `json:"file_ids,omitempty"`
	ShareTo        string   `json:"share_to,omitempty"`         // "publiclink",
	ExpirationDays int      `json:"expiration_days,omitempty"`  // -1 = 'forever'
	PassCodeOption string   `json:"pass_code_option,omitempty"` // "NOT_REQUIRED"
}

RequestShare is to request for file share

type RequestTaskList

type RequestTaskList struct {
	ThumbnailSize string `json:"thumbnail_size,omitempty"`
	Limit         string `json:"limit,omitempty"`
	NextPageToken string `json:"next_page_token,omitempty"`
	Filters       string `json:"filters,omitempty"`
	FileType      string `json:"type,omitempty"`
}

type RequestTaskRetry

type RequestTaskRetry struct {
	Id         string `json:"id"`
	Type       string `json:"type"`
	CreateType string `json:"create_type"`
}

type ResponseGetCaptcha

type ResponseGetCaptcha struct {
	CaptchaToken string `json:"captcha_token"`
	ExpiresIn    int    `json:"expires_in"`
}

type ResponseLogin

type ResponseLogin struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	Sub          string `json:"sub"`
}

type Resumable

type Resumable struct {
	Kind     string           `json:"kind,omitempty"`     // "drive#resumable"
	Provider string           `json:"provider,omitempty"` // e.g. "PROVIDER_ALIYUN"
	Params   *ResumableParams `json:"params,omitempty"`
}

Resumable contains parameters for upload by resumable

type ResumableParams

type ResumableParams struct {
	AccessKeyID     string `json:"access_key_id,omitempty"`
	AccessKeySecret string `json:"access_key_secret,omitempty"`
	Bucket          string `json:"bucket,omitempty"`
	Endpoint        string `json:"endpoint,omitempty"`
	Expiration      Time   `json:"expiration,omitempty"`
	Key             string `json:"key,omitempty"`
	SecurityToken   string `json:"security_token,omitempty"`
}

ResumableParams specifies resumable paramegers

type Share

type Share struct {
	ShareID   string `json:"share_id,omitempty"`
	ShareURL  string `json:"share_url,omitempty"`
	PassCode  string `json:"pass_code,omitempty"`
	ShareText string `json:"share_text,omitempty"`
}

Share is a response to RequestShare

used in PublicLink()

type Task

type Task struct {
	Kind              string        `json:"kind,omitempty"` // "drive#task"
	ID                string        `json:"id,omitempty"`   // task id?
	Name              string        `json:"name,omitempty"` // torrent name?
	Type              string        `json:"type,omitempty"` // "offline"
	UserID            string        `json:"user_id,omitempty"`
	Statuses          []interface{} `json:"statuses,omitempty"`    // TODO
	StatusSize        int           `json:"status_size,omitempty"` // TODO
	Params            *TaskParams   `json:"params,omitempty"`      // TODO
	FileID            string        `json:"file_id,omitempty"`
	FileName          string        `json:"file_name,omitempty"`
	FileSize          string        `json:"file_size,omitempty"`
	Message           string        `json:"message,omitempty"` // e.g. "Saving"
	CreatedTime       Time          `json:"created_time,omitempty"`
	UpdatedTime       Time          `json:"updated_time,omitempty"`
	ThirdTaskID       string        `json:"third_task_id,omitempty"` // TODO
	Phase             string        `json:"phase,omitempty"`         // e.g. "PHASE_TYPE_RUNNING"
	Progress          int           `json:"progress,omitempty"`
	IconLink          string        `json:"icon_link,omitempty"`
	Callback          string        `json:"callback,omitempty"`
	ReferenceResource interface{}   `json:"reference_resource,omitempty"` // TODO
	Space             string        `json:"space,omitempty"`
}

Task is a basic element representing a single task such as offline download and upload

type TaskList

type TaskList struct {
	Tasks         []*Task `json:"tasks,omitempty"` // "drive#task"
	NextPageToken string  `json:"next_page_token"`
	ExpiresIn     int     `json:"expires_in,omitempty"`
}

TaskList contains a list of Task elements

type TaskParams

type TaskParams struct {
	Age          string `json:"age,omitempty"`
	PredictSpeed string `json:"predict_speed,omitempty"`
	PredictType  string `json:"predict_type,omitempty"`
	URL          string `json:"url,omitempty"`
}

TaskParams includes parameters informing status of Task

type Time

type Time time.Time

Time represents date and time information for the pikpak API, by using RFC3339

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() (out []byte, err error)

MarshalJSON turns a Time into JSON (in UTC)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON turns JSON into a Time

type URL

type URL struct {
	Kind string `json:"kind,omitempty"` // e.g. "upload#url"
	URL  string `json:"url,omitempty"`
}

URL is a basic form of URL

type User

type User struct {
	Sub               string          `json:"sub,omitempty"`       // userid for internal use
	Name              string          `json:"name,omitempty"`      // Username
	Picture           string          `json:"picture,omitempty"`   // URL to Avatar image
	Email             string          `json:"email,omitempty"`     // redacted email address
	Providers         *[]UserProvider `json:"providers,omitempty"` // OAuth provider
	PhoneNumber       string          `json:"phone_number,omitempty"`
	Password          string          `json:"password,omitempty"` // "SET" if configured
	Status            string          `json:"status,omitempty"`   // "ACTIVE"
	CreatedAt         Time            `json:"created_at,omitempty"`
	PasswordUpdatedAt Time            `json:"password_updated_at,omitempty"`
}

User contains user account information

GET https://user.mypikpak.com/v1/user/me

type UserProvider

type UserProvider struct {
	ID             string `json:"id,omitempty"` // e.g. "google.com"
	ProviderUserID string `json:"provider_user_id,omitempty"`
	Name           string `json:"name,omitempty"` // username
}

UserProvider details third-party authentication

type VIP

type VIP struct {
	Result      string `json:"result,omitempty"` // "ACCEPTED"
	Message     string `json:"message,omitempty"`
	RedirectURI string `json:"redirect_uri,omitempty"`
	Data        struct {
		Expire Time   `json:"expire,omitempty"`
		Status string `json:"status,omitempty"`  // "invalid" or "ok"
		Type   string `json:"type,omitempty"`    // "novip" or "platinum"
		UserID string `json:"user_id,omitempty"` // same as User.Sub
	} `json:"data,omitempty"`
}

VIP includes subscription details about premium account

GET https://api-drive.mypikpak.com/drive/v1/privilege/vip

Jump to

Keyboard shortcuts

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