Documentation
¶
Index ¶
- func ParseCapacityString(capacityStr string) int64
- type AlipanBatchResult
- type AlipanService
- func (a *AlipanService) DeleteFiles(fileList []string) (*TransferResult, error)
- func (a *AlipanService) GetFiles(pdirFid string) (*TransferResult, error)
- func (a *AlipanService) GetServiceType() ServiceType
- func (a *AlipanService) GetUserInfo(cookie string) (*UserInfo, error)
- func (a *AlipanService) Transfer(shareID string) (*TransferResult, error)
- func (a *AlipanService) UpdateConfig(config *PanConfig)
- type AlipanShareInfo
- type AlipanShareResult
- type AlipanShareToken
- type BaiduPanService
- func (b *BaiduPanService) DeleteFiles(fileList []string) (*TransferResult, error)
- func (b *BaiduPanService) GetFiles(pdirFid string) (*TransferResult, error)
- func (b *BaiduPanService) GetServiceType() ServiceType
- func (b *BaiduPanService) GetUserInfo(cookie string) (*UserInfo, error)
- func (b *BaiduPanService) Transfer(shareID string) (*TransferResult, error)
- type BasePanService
- func (b *BasePanService) ExecuteWithRetry(executeFunc func() ([]byte, error), maxRetries int, retryDelay time.Duration) ([]byte, error)
- func (b *BasePanService) ExtractFileName(urlStr string) string
- func (b *BasePanService) GetConfig() *PanConfig
- func (b *BasePanService) GetHeader(key string) string
- func (b *BasePanService) HTTPDelete(requestURL string) ([]byte, error)
- func (b *BasePanService) HTTPGet(requestURL string, queryParams map[string]string) ([]byte, error)
- func (b *BasePanService) HTTPPost(requestURL string, data interface{}, queryParams map[string]string) ([]byte, error)
- func (b *BasePanService) HTTPPut(requestURL string, data interface{}) ([]byte, error)
- func (b *BasePanService) IsValidURL(urlStr string) bool
- func (b *BasePanService) ParseJSONResponse(data []byte, v interface{}) error
- func (b *BasePanService) SanitizeFileName(fileName string) string
- func (b *BasePanService) SetHeader(key, value string)
- func (b *BasePanService) SetHeaders(headers map[string]string)
- type PanConfig
- type PanFactory
- func (f *PanFactory) CreatePanService(url string, config *PanConfig) (PanService, error)
- func (f *PanFactory) CreatePanServiceByType(serviceType ServiceType, config *PanConfig) (PanService, error)
- func (f *PanFactory) GetAlipanService(config *PanConfig) PanService
- func (f *PanFactory) GetBaiduService(config *PanConfig) PanService
- func (f *PanFactory) GetQuarkService(config *PanConfig) PanService
- func (f *PanFactory) GetUCService(config *PanConfig) PanService
- type PanService
- type PasswordResult
- type QuarkPanService
- func (q *QuarkPanService) DeleteFiles(fileList []string) (*TransferResult, error)
- func (q *QuarkPanService) GetCookie() string
- func (q *QuarkPanService) GetFiles(pdirFid string) (*TransferResult, error)
- func (q *QuarkPanService) GetServiceType() ServiceType
- func (q *QuarkPanService) GetUserInfo(cookie string) (*UserInfo, error)
- func (q *QuarkPanService) SetCookie(cookie string)
- func (q *QuarkPanService) Transfer(shareID string) (*TransferResult, error)
- func (q *QuarkPanService) UpdateConfig(config *PanConfig)
- type SaveResult
- type ServiceType
- type ShareBtnResult
- type ShareResult
- type StokenResult
- type TaskResult
- type TransferResult
- type UCService
- func (u *UCService) DeleteFiles(fileList []string) (*TransferResult, error)
- func (u *UCService) GetFiles(pdirFid string) (*TransferResult, error)
- func (u *UCService) GetServiceType() ServiceType
- func (u *UCService) GetUserInfo(cookie string) (*UserInfo, error)
- func (u *UCService) Transfer(shareID string) (*TransferResult, error)
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseCapacityString ¶
ParseCapacityString 解析容量字符串为字节数
Types ¶
type AlipanBatchResult ¶
type AlipanService ¶
type AlipanService struct {
*BasePanService
// contains filtered or unexported fields
}
AlipanService 阿里云盘服务
func NewAlipanService ¶
func NewAlipanService(config *PanConfig) *AlipanService
NewAlipanService 创建阿里云盘服务(单例模式)
func (*AlipanService) DeleteFiles ¶
func (a *AlipanService) DeleteFiles(fileList []string) (*TransferResult, error)
DeleteFiles 删除文件
func (*AlipanService) GetFiles ¶
func (a *AlipanService) GetFiles(pdirFid string) (*TransferResult, error)
GetFiles 获取文件列表
func (*AlipanService) GetServiceType ¶
func (a *AlipanService) GetServiceType() ServiceType
GetServiceType 获取服务类型
func (*AlipanService) GetUserInfo ¶
func (a *AlipanService) GetUserInfo(cookie string) (*UserInfo, error)
GetUserInfo 获取用户信息
func (*AlipanService) Transfer ¶
func (a *AlipanService) Transfer(shareID string) (*TransferResult, error)
Transfer 转存分享链接
func (*AlipanService) UpdateConfig ¶
func (a *AlipanService) UpdateConfig(config *PanConfig)
UpdateConfig 更新配置(线程安全)
type AlipanShareInfo ¶
type AlipanShareInfo struct {
FileID string `json:"file_id"`
} `json:"file_infos"`
}
定义阿里云盘相关的结构体
type AlipanShareResult ¶
type AlipanShareResult struct {
}
type AlipanShareToken ¶
type AlipanShareToken struct {
}
type BaiduPanService ¶
type BaiduPanService struct {
*BasePanService
}
BaiduPanService 百度网盘服务
func NewBaiduPanService ¶
func NewBaiduPanService(config *PanConfig) *BaiduPanService
NewBaiduPanService 创建百度网盘服务
func (*BaiduPanService) DeleteFiles ¶
func (b *BaiduPanService) DeleteFiles(fileList []string) (*TransferResult, error)
DeleteFiles 删除文件
func (*BaiduPanService) GetFiles ¶
func (b *BaiduPanService) GetFiles(pdirFid string) (*TransferResult, error)
GetFiles 获取文件列表
func (*BaiduPanService) GetServiceType ¶
func (b *BaiduPanService) GetServiceType() ServiceType
GetServiceType 获取服务类型
func (*BaiduPanService) GetUserInfo ¶
func (b *BaiduPanService) GetUserInfo(cookie string) (*UserInfo, error)
GetUserInfo 获取用户信息
func (*BaiduPanService) Transfer ¶
func (b *BaiduPanService) Transfer(shareID string) (*TransferResult, error)
Transfer 转存分享链接
type BasePanService ¶
type BasePanService struct {
// contains filtered or unexported fields
}
BasePanService 基础网盘服务
func NewBasePanService ¶
func NewBasePanService(config *PanConfig) *BasePanService
NewBasePanService 创建基础网盘服务
func (*BasePanService) ExecuteWithRetry ¶
func (b *BasePanService) ExecuteWithRetry(executeFunc func() ([]byte, error), maxRetries int, retryDelay time.Duration) ([]byte, error)
ExecuteWithRetry 带重试的请求执行
func (*BasePanService) ExtractFileName ¶
func (b *BasePanService) ExtractFileName(urlStr string) string
ExtractFileName 从URL中提取文件名
func (*BasePanService) GetHeader ¶
func (b *BasePanService) GetHeader(key string) string
GetHeader 获取请求头
func (*BasePanService) HTTPDelete ¶
func (b *BasePanService) HTTPDelete(requestURL string) ([]byte, error)
HTTPDelete 发送DELETE请求
func (*BasePanService) HTTPPost ¶
func (b *BasePanService) HTTPPost(requestURL string, data interface{}, queryParams map[string]string) ([]byte, error)
HTTPPost 发送POST请求
func (*BasePanService) HTTPPut ¶
func (b *BasePanService) HTTPPut(requestURL string, data interface{}) ([]byte, error)
HTTPPut 发送PUT请求
func (*BasePanService) IsValidURL ¶
func (b *BasePanService) IsValidURL(urlStr string) bool
IsValidURL 验证URL格式
func (*BasePanService) ParseJSONResponse ¶
func (b *BasePanService) ParseJSONResponse(data []byte, v interface{}) error
ParseJSONResponse 解析JSON响应
func (*BasePanService) SanitizeFileName ¶
func (b *BasePanService) SanitizeFileName(fileName string) string
SanitizeFileName 清理文件名
func (*BasePanService) SetHeader ¶
func (b *BasePanService) SetHeader(key, value string)
SetHeader 设置请求头
func (*BasePanService) SetHeaders ¶
func (b *BasePanService) SetHeaders(headers map[string]string)
SetHeaders 批量设置请求头
type PanConfig ¶
type PanConfig struct {
URL string `json:"url"`
Code string `json:"code"`
IsType int `json:"isType"` // 0: 转存并分享后的资源信息, 1: 直接获取资源信息
ExpiredType int `json:"expiredType"` // 1: 分享永久, 2: 临时
AdFid string `json:"adFid"` // 夸克专用 - 分享时带上这个文件的fid
Stoken string `json:"stoken"`
Cookie string `json:"cookie"`
}
PanConfig 网盘配置
type PanFactory ¶
type PanFactory struct{}
PanFactory 网盘工厂
func (*PanFactory) CreatePanService ¶
func (f *PanFactory) CreatePanService(url string, config *PanConfig) (PanService, error)
CreatePanService 根据URL创建对应的网盘服务
func (*PanFactory) CreatePanServiceByType ¶
func (f *PanFactory) CreatePanServiceByType(serviceType ServiceType, config *PanConfig) (PanService, error)
CreatePanServiceByType 根据服务类型创建对应的网盘服务
func (*PanFactory) GetAlipanService ¶
func (f *PanFactory) GetAlipanService(config *PanConfig) PanService
GetAlipanService 获取阿里云盘服务单例
func (*PanFactory) GetBaiduService ¶
func (f *PanFactory) GetBaiduService(config *PanConfig) PanService
GetBaiduService 获取百度网盘服务单例
func (*PanFactory) GetQuarkService ¶
func (f *PanFactory) GetQuarkService(config *PanConfig) PanService
GetQuarkService 获取夸克网盘服务单例
func (*PanFactory) GetUCService ¶
func (f *PanFactory) GetUCService(config *PanConfig) PanService
GetUCService 获取UC网盘服务单例
type PanService ¶
type PanService interface {
// Transfer 转存分享链接
Transfer(shareID string) (*TransferResult, error)
// GetFiles 获取文件列表
GetFiles(pdirFid string) (*TransferResult, error)
// DeleteFiles 删除文件
DeleteFiles(fileList []string) (*TransferResult, error)
// GetUserInfo 获取用户信息
GetUserInfo(cookie string) (*UserInfo, error)
// GetServiceType 获取服务类型
GetServiceType() ServiceType
}
PanService 网盘服务接口
type PasswordResult ¶
type QuarkPanService ¶
type QuarkPanService struct {
*BasePanService
// contains filtered or unexported fields
}
QuarkPanService 夸克网盘服务
func NewQuarkPanService ¶
func NewQuarkPanService(config *PanConfig) *QuarkPanService
NewQuarkPanService 创建夸克网盘服务(单例模式)
func (*QuarkPanService) DeleteFiles ¶
func (q *QuarkPanService) DeleteFiles(fileList []string) (*TransferResult, error)
DeleteFiles 删除文件
func (*QuarkPanService) GetCookie ¶ added in v1.0.9
func (q *QuarkPanService) GetCookie() string
GetCookie 获取当前Cookie
func (*QuarkPanService) GetFiles ¶
func (q *QuarkPanService) GetFiles(pdirFid string) (*TransferResult, error)
GetFiles 获取文件列表
func (*QuarkPanService) GetServiceType ¶
func (q *QuarkPanService) GetServiceType() ServiceType
GetServiceType 获取服务类型
func (*QuarkPanService) GetUserInfo ¶
func (q *QuarkPanService) GetUserInfo(cookie string) (*UserInfo, error)
GetUserInfo 获取用户信息
func (*QuarkPanService) SetCookie ¶ added in v1.0.9
func (q *QuarkPanService) SetCookie(cookie string)
SetCookie 设置Cookie
func (*QuarkPanService) Transfer ¶
func (q *QuarkPanService) Transfer(shareID string) (*TransferResult, error)
Transfer 转存分享链接
func (*QuarkPanService) UpdateConfig ¶
func (q *QuarkPanService) UpdateConfig(config *PanConfig)
UpdateConfig 更新配置(线程安全)
type SaveResult ¶
type SaveResult struct {
TaskID string `json:"task_id"`
}
type ServiceType ¶
type ServiceType int
ServiceType 定义网盘服务类型
const ( Quark ServiceType = iota Alipan BaiduPan UC NotFound Xunlei )
func ExtractServiceType ¶
func ExtractServiceType(url string) ServiceType
ExtractServiceType 从URL中提取服务类型
func ExtractShareId ¶
func ExtractShareId(url string) (string, ServiceType)
ExtractShareId 从URL中提取分享ID
type ShareBtnResult ¶
type ShareBtnResult struct {
}
type ShareResult ¶
type StokenResult ¶
定义各种结果结构体
type TaskResult ¶
type TransferResult ¶
type TransferResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
Title string `json:"title,omitempty"`
Fid string `json:"fid,omitempty"`
}
TransferResult 转存结果
func SuccessResult ¶
func SuccessResult(message string, data interface{}) *TransferResult
SuccessResult 创建成功结果
type UCService ¶
type UCService struct {
*BasePanService
}
UCService UC网盘服务
func (*UCService) DeleteFiles ¶
func (u *UCService) DeleteFiles(fileList []string) (*TransferResult, error)
DeleteFiles 删除文件
func (*UCService) GetFiles ¶
func (u *UCService) GetFiles(pdirFid string) (*TransferResult, error)
GetFiles 获取文件列表
func (*UCService) GetServiceType ¶
func (u *UCService) GetServiceType() ServiceType
GetServiceType 获取服务类型
func (*UCService) GetUserInfo ¶
GetUserInfo 获取用户信息