Documentation ¶
Index ¶
- Constants
- Variables
- func BoolToInt(b bool) int
- func CheckErr(err error, result ResultWithErr, restyResp *resty.Response) error
- func GetErr(code int, respBody ...string) error
- type BasicResponse
- type BoolInt
- type Credential
- type File
- type FileInfo
- type FileListResponse
- type IntString
- type Label
- type LabelColor
- type LabelInfo
- type LoginResp
- type MkdirResp
- type Option
- type Pan115Client
- func (c *Pan115Client) Copy(dirID string, fileIDs ...string) error
- func (c *Pan115Client) Delete(fileIDs ...string) error
- func (c *Pan115Client) EnableTrace() *Pan115Client
- func (c *Pan115Client) GetRequest() *resty.Request
- func (c *Pan115Client) ImportCookies(cookies map[string]string, domains ...string)
- func (c *Pan115Client) ImportCredential(cr *Credential) *Pan115Client
- func (c *Pan115Client) List(dirID string) (*[]File, error)
- func (c *Pan115Client) LoginCheck() error
- func (c *Pan115Client) Mkdir(parentID string, name string) (string, error)
- func (c *Pan115Client) Move(dirID string, fileIDs ...string) error
- func (c *Pan115Client) NewRequest() *resty.Request
- func (c *Pan115Client) Rename(fileID, newName string) error
- func (c *Pan115Client) SetCookies(cs ...*http.Cookie) *Pan115Client
- func (c *Pan115Client) SetDebug(d bool) *Pan115Client
- func (c *Pan115Client) SetHttpClient(httpClient *http.Client) *Pan115Client
- func (c *Pan115Client) SetProxy(proxy string) *Pan115Client
- func (c *Pan115Client) SetUserAgent(userAgent string) *Pan115Client
- type ResultWithErr
- type StringFloat64
- type StringInt
- type StringInt64
- type Time
Constants ¶
View Source
const ( ApiLoginCheck = "https://passportapi.115.com/app/1.0/web/1.0/check/sso" // dir ApiDirAdd = "https://webapi.115.com/files/add" // file ApiFileDelete = "https://webapi.115.com/rb/delete" ApiFileMove = "https://webapi.115.com/files/move" ApiFileCopy = "https://webapi.115.com/files/copy" ApiFileRename = "https://webapi.115.com/files/batch_rename" ApiFileList = "https://webapi.115.com/files" ApiFileListByName = "https://aps.115.com/natsort/files.php" )
View Source
const ( UADefalut = "Mozilla/5.0" UA115Browser = "Mozilla/5.0 115Browser/23.9.3.2" UA115Disk = "Mozilla/5.0 115disk/30.1.0" UAIosApp = "Mozilla/5.0; Darwin/10.0; UDown/30.1.0" )
View Source
const ( CookieDomain115 = ".115.com" CookieDomainAnxia = ".anxia.com" CookieUrl = "https://115.com" CookieNameUid = "UID" CookieNameCid = "CID" CookieNameSeid = "SEID" )
View Source
const ( FileOrderByTime = "user_ptime" FileOrderByType = "file_type" FileOrderBySize = "file_size" FileOrderByName = "file_name" FileListLimit = int64(56) )
Variables ¶
View Source
var ( ErrNotLogin = errors.New("user not login") ErrOfflineInvalidLink = errors.New("invalid download link") ErrOfflineTaskExisted = errors.New("offline task existed") ErrOrderNotSupport = errors.New("file order not supported") ErrPasswordIncorrect = errors.New("password incorrect") ErrLoginTwoStepVerify = errors.New("requires two-step verification") ErrAccountNotBindMobile = errors.New("account not binds mobile") ErrCredentialInvalid = errors.New("credential invalid") ErrSessionExited = errors.New("session exited") ErrQrcodeExpired = errors.New("qrcode expired") // ErrUnexpected is the fall-back error whose code is not handled. ErrUnexpected = errors.New("unexpected error") // ErrExist means an item which you want to create is already existed. ErrExist = errors.New("target already exists") // ErrNotExist means an item which you find is not existed. ErrNotExist = errors.New("target does not exist") ErrInvalidCursor = errors.New("invalid cursor") ErrUploadTooLarge = errors.New("upload reach the limit") ErrImportDirectory = errors.New("can not import directory") ErrDownloadEmpty = errors.New("can not get download URL") ErrDownloadDirectory = errors.New("can not download directory") ErrDownloadFileNotExistOrHasDeleted = errors.New("target file does not exist or has deleted") ErrDownloadFileTooBig = errors.New("target file is too big to download") ErrVideoNotReady = errors.New("video is not ready") ErrWrongParams = errors.New("wrong parameters") ErrRepeatLogin = errors.New("repeat login") )
View Source
var ( LabelColors = []string{ "#000000", "#FF4B30", "#F78C26", "#FFC032", "#43BA80", "#2670FC", "#8B69FE", "#CCCCCC", } LabelColorMap = map[string]int{ "#000000": 0, "#FF4B30": 1, "#F78C26": 2, "#FFC032": 3, "#43BA80": 4, "#2670FC": 5, "#8B69FE": 6, "#CCCCCC": 7, } )
View Source
var (
ErrBadCookie = errors.New("bad cookie")
)
cookie err
Functions ¶
func CheckErr ¶
func CheckErr(err error, result ResultWithErr, restyResp *resty.Response) error
Types ¶
type BasicResponse ¶
type BasicResponse struct { Errno StringInt `json:"errno,omitempty"` ErrNo int `json:"errNo,omitempty"` Error string `json:"error,omitempty"` State bool `json:"state,omitempty"` Errtype string `json:"errtype,omitempty"` }
func (*BasicResponse) Err ¶
func (resp *BasicResponse) Err(respBody ...string) error
type Credential ¶
func (*Credential) FromCookie ¶
func (cr *Credential) FromCookie(cookie string) error
type File ¶
type File struct { // Marks is the file a directory. IsDirectory bool // Unique identifier of the file on the cloud storage. FileID string // FileID of the parent directory. ParentID string // Base name of the file. Name string // Size in bytes of the file. Size int64 // IDentifier used for downloading or playing the file. PickCode string // SHA1 hash of file content, in HEX format. Sha1 string // Is file stared Star bool // File labels Labels []*Label // Create time of the file. CreateTime time.Time // Update time of the file. UpdateTime time.Time }
type FileInfo ¶
type FileInfo struct { AreaID IntString `json:"aid"` CategoryID string `json:"cid"` FileID string `json:"fid"` ParentID string `json:"pid"` Name string `json:"n"` Type string `json:"ico"` Size StringInt64 `json:"s"` Sha1 string `json:"sha"` PickCode string `json:"pc"` IsStar StringInt `json:"m"` Labels []*LabelInfo `json:"fl"` CreateTime StringInt64 `json:"tp"` UpdateTime StringInt64 `json:"te"` }
type FileListResponse ¶
type FileListResponse struct { BasicResponse AreaID string `json:"aid"` CategoryID IntString `json:"cid"` Count int `json:"count"` Order string `json:"order"` IsAsc int `json:"is_asc"` Offset int `json:"offset"` Limit int `json:"limit"` PageSize int `json:"page_size"` Files []FileInfo `json:"data"` }
type Label ¶
type Label struct { ID string Name string Color LabelColor }
type LabelColor ¶
type LabelColor int
type LoginResp ¶
type LoginResp struct { Code int `json:"code"` CheckSsd bool `json:"check_ssd"` Data struct { Expire int `json:"expire"` Link string `json:"link"` UserID int `json:"user_id"` } `json:"data"` Errno int `json:"errno"` Error string `json:"error"` Message string `json:"message"` State int `json:"state"` Expire int `json:"expire"` }
type Option ¶
type Option func(c *Pan115Client)
func WithClient ¶ added in v1.0.3
func WithRestyClient ¶ added in v1.0.3
func WithRestyClient(resty *resty.Client) Option
type Pan115Client ¶
type Pan115Client struct { Client *resty.Client Request *resty.Request }
func (*Pan115Client) Delete ¶
func (c *Pan115Client) Delete(fileIDs ...string) error
func (*Pan115Client) EnableTrace ¶
func (c *Pan115Client) EnableTrace() *Pan115Client
func (*Pan115Client) GetRequest ¶
func (c *Pan115Client) GetRequest() *resty.Request
func (*Pan115Client) ImportCookies ¶
func (c *Pan115Client) ImportCookies(cookies map[string]string, domains ...string)
func (*Pan115Client) ImportCredential ¶
func (c *Pan115Client) ImportCredential(cr *Credential) *Pan115Client
func (*Pan115Client) LoginCheck ¶
func (c *Pan115Client) LoginCheck() error
func (*Pan115Client) Mkdir ¶
func (c *Pan115Client) Mkdir(parentID string, name string) (string, error)
func (*Pan115Client) NewRequest ¶
func (c *Pan115Client) NewRequest() *resty.Request
func (*Pan115Client) Rename ¶
func (c *Pan115Client) Rename(fileID, newName string) error
func (*Pan115Client) SetCookies ¶
func (c *Pan115Client) SetCookies(cs ...*http.Cookie) *Pan115Client
func (*Pan115Client) SetDebug ¶
func (c *Pan115Client) SetDebug(d bool) *Pan115Client
func (*Pan115Client) SetHttpClient ¶
func (c *Pan115Client) SetHttpClient(httpClient *http.Client) *Pan115Client
func (*Pan115Client) SetProxy ¶
func (c *Pan115Client) SetProxy(proxy string) *Pan115Client
func (*Pan115Client) SetUserAgent ¶
func (c *Pan115Client) SetUserAgent(userAgent string) *Pan115Client
type ResultWithErr ¶
type StringFloat64 ¶
type StringFloat64 float64
StringFloat64 uses for json field which maybe a string or a float64.
func (*StringFloat64) UnmarshalJSON ¶
func (v *StringFloat64) UnmarshalJSON(b []byte) (err error)
type StringInt ¶
type StringInt int64
StringInt uses for json field which maybe a string or an int.
func (*StringInt) UnmarshalJSON ¶
type StringInt64 ¶
type StringInt64 int64
StringInt64 uses for json field which maybe a string or an int64.
func (*StringInt64) UnmarshalJSON ¶
func (v *StringInt64) UnmarshalJSON(b []byte) (err error)
Click to show internal directories.
Click to hide internal directories.