Documentation ¶
Index ¶
- Constants
- Variables
- func BoolToInt(b bool) int
- func CheckErr(err error, result ResultWithErr, restyResp *resty.Response) error
- func Date() string
- func GetErr(code int, respBody ...string) error
- type BasicResp
- type BoolInt
- type Credential
- type DownloadData
- type DownloadInfo
- type DownloadReap
- type File
- type FileDownloadUrl
- type FileInfo
- type FileListResp
- type GetFileOption
- type GetFileOptions
- 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) Download(pickCode string) (*DownloadInfo, error)
- func (c *Pan115Client) EnableTrace() *Pan115Client
- func (c *Pan115Client) GenerateSignature(fileID, target string) string
- func (c *Pan115Client) GenerateToken(fileID, preID, timeStamp, fileSize string) string
- func (c *Pan115Client) GetDigestResult(r io.Reader) (*hash.DigestResult, error)
- func (c *Pan115Client) GetOssToken() (*UploadOssTokenResponse, error)
- func (c *Pan115Client) GetRequest() *resty.Request
- func (c *Pan115Client) GetUploadInfo() error
- func (c *Pan115Client) GetUploadTicket(params *UploadOssParams, mimeType string, fileSize int64) (*UploadTicket, error)
- func (c *Pan115Client) ImportCookies(cookies map[string]string, domains ...string)
- func (c *Pan115Client) ImportCredential(cr *Credential) *Pan115Client
- func (c *Pan115Client) List(dirID string, opts ...GetFileOptions) (*[]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
- func (c *Pan115Client) UploadAvailable() (bool, error)
- func (c *Pan115Client) UploadByOss(params *UploadOssParams, r io.Reader, dirID string) error
- func (c *Pan115Client) UploadFastOrByOss(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
- func (c *Pan115Client) UploadSH1(fileSize int64, fileName, dirID, preID, fileID string) (*UploadInitResp, error)
- type ResultWithErr
- type StringFloat64
- type StringInt
- type StringInt64
- type StringTime
- type Time
- type UploadInfoResp
- type UploadInitResp
- type UploadMetaInfo
- type UploadOssParams
- type UploadOssTokenResponse
- type UploadTicket
Constants ¶
View Source
const ( // login 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" // download ApiDownloadGetUrl = "https://proapi.115.com/app/chrome/downurl" // upload ApiUploadInfo = "https://proapi.115.com/app/uploadinfo" ApiUploadInit = "https://uplb.115.com/3.0/initupload.php" ApiUploadOssToken = "https://uplb.115.com/3.0/gettoken.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 ( OssRegionId = "oss-cn-shenzhen" OssEndpoint = "oss-cn-shenzhen.aliyuncs.com" )
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") ErrUploadFailed = errors.New("upload failed") 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") ErrPickCodeNotExist = errors.New("pickcode does not exist") ErrPickCodeisEmpty = errors.New("empty pickcode") ErrUploadSH1Invalid = errors.New("userid/filesize/target/pickcode invalid") )
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 BasicResp ¶ added in v1.0.6
type Credential ¶
func (*Credential) FromCookie ¶
func (cr *Credential) FromCookie(cookie string) error
type DownloadData ¶ added in v1.0.5
type DownloadData map[string]*DownloadInfo
type DownloadInfo ¶ added in v1.0.5
type DownloadInfo struct { FileName string `json:"file_name"` FileSize StringInt64 `json:"file_size"` PickCode string `json:"pick_code"` Url FileDownloadUrl `json:"url"` Header http.Header }
type DownloadReap ¶ added in v1.0.5
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 FileDownloadUrl ¶ added in v1.0.5
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 string `json:"t"` }
type FileListResp ¶ added in v1.0.6
type FileListResp struct { BasicResp 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"` }
func GetFiles ¶ added in v1.0.3
func GetFiles(req *resty.Request, dirID string, opts ...GetFileOptions) (*FileListResp, error)
type GetFileOption ¶ added in v1.0.6
type GetFileOption struct {
// contains filtered or unexported fields
}
func DefaultGetFileOptions ¶ added in v1.0.6
func DefaultGetFileOptions() *GetFileOption
func (*GetFileOption) GetAsc ¶ added in v1.0.6
func (o *GetFileOption) GetAsc() string
func (*GetFileOption) GetOffset ¶ added in v1.0.6
func (o *GetFileOption) GetOffset() string
func (*GetFileOption) GetOrder ¶ added in v1.0.6
func (o *GetFileOption) GetOrder() string
func (*GetFileOption) GetPageSize ¶ added in v1.0.6
func (o *GetFileOption) GetPageSize() string
func (*GetFileOption) GetshowDir ¶ added in v1.0.6
func (o *GetFileOption) GetshowDir() string
type GetFileOptions ¶ added in v1.0.6
type GetFileOptions func(o *GetFileOption)
func WithLimit ¶ added in v1.0.6
func WithLimit(pageSize int64) GetFileOptions
func WithOffset ¶ added in v1.0.6
func WithOffset(offset int64) GetFileOptions
func WithOrder ¶ added in v1.0.6
func WithOrder(order string) GetFileOptions
func WithShowDirEnable ¶ added in v1.0.6
func WithShowDirEnable(e bool) GetFileOptions
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 int64 `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 UserID int64 Userkey string UploadMetaInfo *UploadMetaInfo }
func (*Pan115Client) Delete ¶
func (c *Pan115Client) Delete(fileIDs ...string) error
func (*Pan115Client) Download ¶ added in v1.0.5
func (c *Pan115Client) Download(pickCode string) (*DownloadInfo, error)
func (*Pan115Client) EnableTrace ¶
func (c *Pan115Client) EnableTrace() *Pan115Client
func (*Pan115Client) GenerateSignature ¶ added in v1.0.6
func (c *Pan115Client) GenerateSignature(fileID, target string) string
func (*Pan115Client) GenerateToken ¶ added in v1.0.6
func (c *Pan115Client) GenerateToken(fileID, preID, timeStamp, fileSize string) string
func (*Pan115Client) GetDigestResult ¶ added in v1.0.6
func (c *Pan115Client) GetDigestResult(r io.Reader) (*hash.DigestResult, error)
func (*Pan115Client) GetOssToken ¶ added in v1.0.6
func (c *Pan115Client) GetOssToken() (*UploadOssTokenResponse, error)
func (*Pan115Client) GetRequest ¶
func (c *Pan115Client) GetRequest() *resty.Request
func (*Pan115Client) GetUploadInfo ¶ added in v1.0.6
func (c *Pan115Client) GetUploadInfo() error
func (*Pan115Client) GetUploadTicket ¶ added in v1.0.6
func (c *Pan115Client) GetUploadTicket(params *UploadOssParams, mimeType string, fileSize int64) (*UploadTicket, error)
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) List ¶
func (c *Pan115Client) List(dirID string, opts ...GetFileOptions) (*[]File, error)
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
func (*Pan115Client) UploadAvailable ¶ added in v1.0.6
func (c *Pan115Client) UploadAvailable() (bool, error)
func (*Pan115Client) UploadByOss ¶ added in v1.0.6
func (c *Pan115Client) UploadByOss(params *UploadOssParams, r io.Reader, dirID string) error
func (*Pan115Client) UploadFastOrByOss ¶ added in v1.0.6
func (c *Pan115Client) UploadFastOrByOss(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
func (*Pan115Client) UploadSH1 ¶ added in v1.0.6
func (c *Pan115Client) UploadSH1(fileSize int64, fileName, dirID, preID, fileID string) (*UploadInitResp, error)
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)
type StringTime ¶ added in v1.0.4
type StringTime int64
func (*StringTime) UnmarshalJSON ¶ added in v1.0.4
func (v *StringTime) UnmarshalJSON(b []byte) (err error)
type UploadInfoResp ¶ added in v1.0.6
type UploadInfoResp struct { BasicResp UploadMetaInfo UserID int64 `json:"user_id"` Userkey string `json:"userkey"` }
type UploadInitResp ¶ added in v1.0.6
type UploadInitResp struct { Request string `json:"request"` ErrorCode int `json:"statuscode"` ErrorMsg string `json:"statusmsg"` Status BoolInt `json:"status"` PickCode string `json:"pickcode"` Target string `json:"target"` Version string `json:"version"` // OSS upload fields UploadOssParams // Useless fields FileId int `json:"fileid"` FileInfo string `json:"fileinfo"` }
func (*UploadInitResp) Err ¶ added in v1.0.6
func (r *UploadInitResp) Err(respBody ...string) error
func (*UploadInitResp) Ok ¶ added in v1.0.6
func (r *UploadInitResp) Ok() (bool, error)
type UploadMetaInfo ¶ added in v1.0.6
type UploadMetaInfo struct { AppID int64 `json:"app_id"` AppVersion int64 `json:"app_version"` IspType int64 `json:"isp_type"` MaxDirLevel int64 `json:"max_dir_level"` MaxDirLevelYun int64 `json:"max_dir_level_yun"` MaxFileNum int64 `json:"max_file_num"` MaxFileNumYun int64 `json:"max_file_num_yun"` SizeLimit int64 `json:"size_limit"` SizeLimitYun int64 `json:"size_limit_yun"` TypeLimit []string `json:"type_limit"` UploadAllowed bool `json:"upload_allowed"` UploadAllowedMsg string `json:"upload_allowed_msg"` }
type UploadOssParams ¶ added in v1.0.6
type UploadOssTokenResponse ¶ added in v1.0.6
type UploadOssTokenResponse struct { AccessKeyID string `json:"AccessKeyId"` AccessKeySecret string `json:"AccessKeySecret"` Expiration time.Time `json:"Expiration"` SecurityToken string `json:"SecurityToken"` StatusCode string `json:"StatusCode"` }
func (*UploadOssTokenResponse) Err ¶ added in v1.0.6
func (r *UploadOssTokenResponse) Err(respBody ...string) error
Click to show internal directories.
Click to hide internal directories.