Documentation
¶
Index ¶
- Constants
- Variables
- func BuildCustomUserAgent(deviceID, appName, sdkVersion, clientVersion, packageName string) string
- func EncryptPassword(password string) string
- func GetAction(method string, url string) string
- type Addition
- type CaptchaTokenRequest
- type CaptchaTokenResponse
- type Common
- func (c *Common) GetCaptchaSign() (timestamp, sign string)
- func (c *Common) GetCaptchaToken() string
- func (c *Common) GetCreditKey() string
- func (c *Common) RefreshCaptchaTokenAtLogin(action, userID string) error
- func (c *Common) RefreshCaptchaTokenInLogin(action, username string) error
- func (c *Common) Request(url, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)
- func (c *Common) SetCaptchaToken(captchaToken string)
- func (c *Common) SetCreditKey(creditKey string)
- func (c *Common) SetDeviceID(deviceID string)
- type CoreLoginRequest
- type CoreLoginResp
- type CustomTime
- type ErrResp
- type ExpertAddition
- type FileList
- type Files
- func (c *Files) CreateTime() time.Time
- func (c *Files) GetHash() utils.HashInfo
- func (c *Files) GetID() string
- func (c *Files) GetName() string
- func (c *Files) GetPath() string
- func (c *Files) GetSize() int64
- func (c *Files) GetSpace() string
- func (c *Files) IsDir() bool
- func (c *Files) ModTime() time.Time
- func (c *Files) Thumb() string
- type Link
- type LoginReviewResp
- type OfflineDownloadResp
- type OfflineListResp
- type OfflineTask
- type Params
- type ReviewData
- type SignInRequest
- type ThunderBrowser
- type ThunderBrowserExpert
- func (x *ThunderBrowserExpert) Config() driver.Config
- func (x *ThunderBrowserExpert) Drop(ctx context.Context) error
- func (x *ThunderBrowserExpert) GetAddition() driver.Additional
- func (x *ThunderBrowserExpert) Init(ctx context.Context) (err error)
- func (x *ThunderBrowserExpert) SetTokenResp(token *TokenResp)
- type TokenResp
- type UploadTaskResponse
- type XunLeiBrowserCommon
- func (xc *XunLeiBrowserCommon) Copy(ctx context.Context, srcObj, dstDir model.Obj) error
- func (xc *XunLeiBrowserCommon) CoreLogin(username string, password string) (sessionID string, err error)
- func (xc *XunLeiBrowserCommon) DeleteOfflineTasks(ctx context.Context, taskIDs []string) error
- func (xc *XunLeiBrowserCommon) GetSafeAccessToken(safePassword string) (string, error)
- func (xc *XunLeiBrowserCommon) IsLogin() bool
- func (xc *XunLeiBrowserCommon) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)
- func (xc *XunLeiBrowserCommon) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error)
- func (xc *XunLeiBrowserCommon) Login(username, password string) (*TokenResp, error)
- func (xc *XunLeiBrowserCommon) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error
- func (xc *XunLeiBrowserCommon) Move(ctx context.Context, srcObj, dstDir model.Obj) error
- func (xc *XunLeiBrowserCommon) OfflineDownload(ctx context.Context, fileUrl string, parentDir model.Obj, fileName string) (*OfflineTask, error)
- func (xc *XunLeiBrowserCommon) OfflineList(ctx context.Context, nextPageToken string) ([]OfflineTask, error)
- func (xc *XunLeiBrowserCommon) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, ...) error
- func (xc *XunLeiBrowserCommon) RefreshToken(refreshToken string) (*TokenResp, error)
- func (xc *XunLeiBrowserCommon) Remove(ctx context.Context, obj model.Obj) error
- func (xc *XunLeiBrowserCommon) Rename(ctx context.Context, srcObj model.Obj, newName string) error
- func (xc *XunLeiBrowserCommon) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)
- func (xc *XunLeiBrowserCommon) SetCoreTokenResp(tr *CoreLoginResp)
- func (xc *XunLeiBrowserCommon) SetRefreshTokenFunc(fn func() error)
- func (xc *XunLeiBrowserCommon) SetSpaceTokenResp(spaceToken string)
- func (xc *XunLeiBrowserCommon) SetTokenResp(tr *TokenResp)
Constants ¶
View Source
const ( API_URL = "https://x-api-pan.xunlei.com/drive/v1" FILE_API_URL = API_URL + "/files" TASK_API_URL = API_URL + "/tasks" XLUSER_API_BASE_URL = "https://xluser-ssl.xunlei.com" XLUSER_API_URL = XLUSER_API_BASE_URL + "/v1" )
View Source
const ( ClientID = "ZUBzD9J_XPXfn7f7" ClientSecret = "yESVmHecEe6F0aou69vl-g" ClientVersion = "1.40.0.7208" PackageName = "com.xunlei.browser" DownloadUserAgent = "AndroidDownloadManager/13 (Linux; U; Android 13; M2004J7AC Build/SP1A.210812.016)" SdkVersion = "509300" )
View Source
const ( FOLDER = "drive#folder" FILE = "drive#file" RESUMABLE = "drive#resumable" )
View Source
const ( UPLOAD_TYPE_UNKNOWN = "UPLOAD_TYPE_UNKNOWN" //UPLOAD_TYPE_FORM = "UPLOAD_TYPE_FORM" UPLOAD_TYPE_RESUMABLE = "UPLOAD_TYPE_RESUMABLE" UPLOAD_TYPE_URL = "UPLOAD_TYPE_URL" )
View Source
const ( ThunderDriveSpace = "" ThunderDriveSafeSpace = "SPACE_SAFE" ThunderBrowserDriveSpace = "SPACE_BROWSER" ThunderBrowserDriveSafeSpace = "SPACE_BROWSER_SAFE" ThunderDriveFolderType = "DEFAULT_ROOT" ThunderBrowserDriveSafeFolderType = "BROWSER_SAFE" ThunderBrowserDriveFluentPlayFolderType = "SPACE_FAVORITE" // 流畅播文件夹标识 )
View Source
const ( SignProvider = "access_end_point_token" APPID = "22062" APPKey = "a5d7416858147a4ab99573872ffccef8" )
Variables ¶
View Source
var Algorithms = []string{
"Cw4kArmKJ/aOiFTxnQ0ES+D4mbbrIUsFn",
"HIGg0Qfbpm5ThZ/RJfjoao4YwgT9/M",
"u/PUD",
"OlAm8tPkOF1qO5bXxRN2iFttuDldrg",
"FFIiM6sFhWhU7tIMVUKOF7CUv/KzgwwV8FE",
"yN",
"4m5mglrIHksI6wYdq",
"LXEfS7",
"T+p+C+F2yjgsUtiXWU/cMNYEtJI4pq7GofW",
"14BrGIEMXkbvFvZ49nDUfVCRcHYFOJ1BP1Y",
"kWIH3Row",
"RAmRTKNCjucPWC",
}
Functions ¶
func BuildCustomUserAgent ¶
Types ¶
type Addition ¶
type Addition struct {
driver.RootID
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
SafePassword string `json:"safe_password" required:"true"` // 超级保险箱密码
CaptchaToken string `json:"captcha_token"`
CreditKey string `json:"credit_key" help:"credit key,used for login"` // 信任密钥
DeviceID string `json:"device_id" default:""` // 登录设备ID
UseVideoUrl bool `json:"use_video_url" default:"false"`
// 离线下载是否使用 流畅播(Fluent Play)接口
UseFluentPlay bool `json:"use_fluent_play" default:"false" help:"use fluent play for offline download,only magnet links supported"`
RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"`
}
type CaptchaTokenRequest ¶
type CaptchaTokenRequest struct {
Action string `json:"action"`
CaptchaToken string `json:"captcha_token"`
ClientID string `json:"client_id"`
DeviceID string `json:"device_id"`
Meta map[string]string `json:"meta"`
RedirectUri string `json:"redirect_uri"`
}
* 验证码Token *
type CaptchaTokenResponse ¶
type Common ¶
type Common struct {
// 签名相关,二选一
Algorithms []string
Timestamp, CaptchaSign string
// 必要值,签名相关
DeviceID string
ClientID string
ClientSecret string
ClientVersion string
PackageName string
UserAgent string
DownloadUserAgent string
UseVideoUrl bool
UseFluentPlay bool
RemoveWay string
// contains filtered or unexported fields
}
func (*Common) GetCaptchaSign ¶
GetCaptchaSign 获取验证码签名
func (*Common) GetCaptchaToken ¶
func (*Common) GetCreditKey ¶
func (*Common) RefreshCaptchaTokenAtLogin ¶
RefreshCaptchaTokenAtLogin 刷新验证码token(登录后)
func (*Common) RefreshCaptchaTokenInLogin ¶
RefreshCaptchaTokenInLogin 刷新验证码token(登录时)
func (*Common) Request ¶
func (c *Common) Request(url, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)
Request 只有基础信息的请求
func (*Common) SetCaptchaToken ¶
func (*Common) SetCreditKey ¶
func (*Common) SetDeviceID ¶
type CoreLoginRequest ¶
type CoreLoginRequest struct {
ProtocolVersion string `json:"protocolVersion"`
SequenceNo string `json:"sequenceNo"`
PlatformVersion string `json:"platformVersion"`
IsCompressed string `json:"isCompressed"`
Appid string `json:"appid"`
ClientVersion string `json:"clientVersion"`
PeerID string `json:"peerID"`
AppName string `json:"appName"`
SdkVersion string `json:"sdkVersion"`
Devicesign string `json:"devicesign"`
NetWorkType string `json:"netWorkType"`
ProviderName string `json:"providerName"`
DeviceModel string `json:"deviceModel"`
DeviceName string `json:"deviceName"`
OSVersion string `json:"OSVersion"`
Creditkey string `json:"creditkey"`
Hl string `json:"hl"`
UserName string `json:"userName"`
PassWord string `json:"passWord"`
VerifyKey string `json:"verifyKey"`
VerifyCode string `json:"verifyCode"`
IsMd5Pwd string `json:"isMd5Pwd"`
}
type CoreLoginResp ¶
type CoreLoginResp struct {
Account string `json:"account"`
Creditkey string `json:"creditkey"`
/* Error string `json:"error"`
ErrorCode string `json:"errorCode"`
ErrorDescription string `json:"error_description"`*/
ExpiresIn int `json:"expires_in"`
IsCompressed string `json:"isCompressed"`
IsSetPassWord string `json:"isSetPassWord"`
KeepAliveMinPeriod string `json:"keepAliveMinPeriod"`
KeepAlivePeriod string `json:"keepAlivePeriod"`
LoginKey string `json:"loginKey"`
NickName string `json:"nickName"`
PlatformVersion string `json:"platformVersion"`
ProtocolVersion string `json:"protocolVersion"`
SecureKey string `json:"secureKey"`
SequenceNo string `json:"sequenceNo"`
SessionID string `json:"sessionID"`
Timestamp string `json:"timestamp"`
UserID string `json:"userID"`
UserName string `json:"userName"`
UserNewNo string `json:"userNewNo"`
Version string `json:"version"`
}
type CustomTime ¶
func (*CustomTime) UnmarshalJSON ¶
func (ct *CustomTime) UnmarshalJSON(b []byte) error
type ErrResp ¶
type ExpertAddition ¶
type ExpertAddition struct {
driver.RootID
LoginType string `json:"login_type" type:"select" options:"user,refresh_token" default:"user"`
SignType string `json:"sign_type" type:"select" options:"algorithms,captcha_sign" default:"algorithms"`
// 登录方式1
Username string `json:"username" required:"true" help:"login type is user,this is required"`
Password string `json:"password" required:"true" help:"login type is user,this is required"`
// 登录方式2
RefreshToken string `json:"refresh_token" required:"true" help:"login type is refresh_token,this is required"`
SafePassword string `json:"safe_password" required:"true" help:"super safe password"` // 超级保险箱密码
// 签名方法1
Algorithms string `` /* 353-byte string literal not displayed */
// 签名方法2
CaptchaSign string `json:"captcha_sign" required:"true" help:"sign type is captcha_sign,this is required"`
Timestamp string `json:"timestamp" required:"true" help:"sign type is captcha_sign,this is required"`
// 验证码
CaptchaToken string `json:"captcha_token"`
// 信任密钥
CreditKey string `json:"credit_key" help:"credit key,used for login"`
// 必要且影响登录,由签名决定
DeviceID string `json:"device_id" required:"false" default:""`
ClientID string `json:"client_id" required:"true" default:"ZUBzD9J_XPXfn7f7"`
ClientSecret string `json:"client_secret" required:"true" default:"yESVmHecEe6F0aou69vl-g"`
ClientVersion string `json:"client_version" required:"true" default:"1.40.0.7208"`
PackageName string `json:"package_name" required:"true" default:"com.xunlei.browser"`
// 不影响登录,影响下载速度
UserAgent string `json:"user_agent" required:"false" default:""`
DownloadUserAgent string `json:"download_user_agent" required:"false" default:""`
// 优先使用视频链接代替下载链接
UseVideoUrl bool `json:"use_video_url"`
// 离线下载是否使用 流畅播(Fluent Play)接口
UseFluentPlay bool `json:"use_fluent_play" default:"false" help:"use fluent play for offline download,only magnet links supported"`
// 移除方式
RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"`
}
ExpertAddition 高级设置
func (*ExpertAddition) GetIdentity ¶
func (i *ExpertAddition) GetIdentity() string
GetIdentity 登录特征,用于判断是否重新登录
type FileList ¶
type FileList struct {
Kind string `json:"kind"`
NextPageToken string `json:"next_page_token"`
Files []Files `json:"files"`
Version string `json:"version"`
VersionOutdated bool `json:"version_outdated"`
FolderType int8
}
* 文件 *
type Files ¶
type Files struct {
Kind string `json:"kind"`
ID string `json:"id"`
ParentID string `json:"parent_id"`
Name string `json:"name"`
//UserID string `json:"user_id"`
Size string `json:"size"`
//Revision string `json:"revision"`
//FileExtension string `json:"file_extension"`
//MimeType string `json:"mime_type"`
//Starred bool `json:"starred"`
WebContentLink string `json:"web_content_link"`
CreatedTime CustomTime `json:"created_time"`
ModifiedTime CustomTime `json:"modified_time"`
IconLink string `json:"icon_link"`
ThumbnailLink string `json:"thumbnail_link"`
Md5Checksum string `json:"md5_checksum"`
Hash string `json:"hash"`
// Links map[string]Link `json:"links"`
// Phase string `json:"phase"`
// Audit struct {
// Status string `json:"status"`
// Message string `json:"message"`
// Title string `json:"title"`
// } `json:"audit"`
Medias []struct {
//Category string `json:"category"`
//IconLink string `json:"icon_link"`
//IsDefault bool `json:"is_default"`
//IsOrigin bool `json:"is_origin"`
//IsVisible bool `json:"is_visible"`
Link Link `json:"link"`
} `json:"medias"`
Trashed bool `json:"trashed"`
DeleteTime string `json:"delete_time"`
OriginalURL string `json:"original_url"`
//Params struct{} `json:"params"`
//OriginalFileIndex int `json:"original_file_index"`
Space string `json:"space"`
//Apps []interface{} `json:"apps"`
//Writable bool `json:"writable"`
FolderType string `json:"folder_type"`
//Collection interface{} `json:"collection"`
SortName string `json:"sort_name"`
UserModifiedTime CustomTime `json:"user_modified_time"`
}
func (*Files) CreateTime ¶
type LoginReviewResp ¶
type LoginReviewResp struct {
Creditkey string `json:"creditkey"`
Error string `json:"error"`
ErrorCode string `json:"errorCode"`
ErrorDesc string `json:"errorDesc"`
ErrorDescURL string `json:"errorDescUrl"`
ErrorIsRetry int `json:"errorIsRetry"`
ErrorDescription string `json:"error_description"`
IsCompressed string `json:"isCompressed"`
PlatformVersion string `json:"platformVersion"`
ProtocolVersion string `json:"protocolVersion"`
Reviewurl string `json:"reviewurl"`
SequenceNo string `json:"sequenceNo"`
UserID string `json:"userID"`
VerifyType string `json:"verifyType"`
}
LoginReviewResp 登录验证响应
type OfflineDownloadResp ¶
type OfflineDownloadResp struct {
File *string `json:"file"`
Task OfflineTask `json:"task"`
UploadType string `json:"upload_type"`
URL struct {
Kind string `json:"kind"`
} `json:"url"`
}
OfflineDownloadResp 离线下载响应
type OfflineListResp ¶
type OfflineListResp struct {
ExpiresIn int64 `json:"expires_in"`
NextPageToken string `json:"next_page_token"`
Tasks []OfflineTask `json:"tasks"`
}
OfflineListResp 离线下载列表响应
type OfflineTask ¶
type OfflineTask 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 Params `json:"params"`
Phase string `json:"phase"` // PHASE_TYPE_RUNNING, PHASE_TYPE_ERROR, PHASE_TYPE_COMPLETE, PHASE_TYPE_PENDING
Progress int64 `json:"progress"`
Space string `json:"space"`
StatusSize int64 `json:"status_size"`
Statuses []string `json:"statuses"`
ThirdTaskID string `json:"third_task_id"`
Type string `json:"type"`
UpdatedTime string `json:"updated_time"`
UserID string `json:"user_id"`
}
OfflineTask 离线下载任务响应
type ReviewData ¶
type ReviewData struct {
Creditkey string `json:"creditkey"`
Reviewurl string `json:"reviewurl"`
Deviceid string `json:"deviceid"`
Devicesign string `json:"devicesign"`
}
ReviewData 验证数据
type SignInRequest ¶
type ThunderBrowser ¶
type ThunderBrowser struct {
*XunLeiBrowserCommon
model.Storage
Addition
// contains filtered or unexported fields
}
func (*ThunderBrowser) Config ¶
func (x *ThunderBrowser) Config() driver.Config
func (*ThunderBrowser) GetAddition ¶
func (x *ThunderBrowser) GetAddition() driver.Additional
type ThunderBrowserExpert ¶
type ThunderBrowserExpert struct {
*XunLeiBrowserCommon
model.Storage
ExpertAddition
// contains filtered or unexported fields
}
func (*ThunderBrowserExpert) Config ¶
func (x *ThunderBrowserExpert) Config() driver.Config
func (*ThunderBrowserExpert) GetAddition ¶
func (x *ThunderBrowserExpert) GetAddition() driver.Additional
func (*ThunderBrowserExpert) Init ¶
func (x *ThunderBrowserExpert) Init(ctx context.Context) (err error)
func (*ThunderBrowserExpert) SetTokenResp ¶
func (x *ThunderBrowserExpert) SetTokenResp(token *TokenResp)
type TokenResp ¶
type TokenResp struct {
TokenType string `json:"token_type"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int64 `json:"expires_in"`
Sub string `json:"sub"`
UserID string `json:"user_id"`
Token string `json:"token"` // "超级保险箱" 访问Token
}
* 登录 *
func (*TokenResp) GetSpaceToken ¶
GetSpaceToken 获取"超级保险箱" 访问Token
type UploadTaskResponse ¶
type UploadTaskResponse struct {
UploadType string `json:"upload_type"`
//UPLOAD_TYPE_RESUMABLE
Resumable struct {
Kind string `json:"kind"`
Params struct {
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Bucket string `json:"bucket"`
Endpoint string `json:"endpoint"`
Expiration time.Time `json:"expiration"`
Key string `json:"key"`
SecurityToken string `json:"security_token"`
} `json:"params"`
Provider string `json:"provider"`
} `json:"resumable"`
File Files `json:"file"`
}
* 上传 *
type XunLeiBrowserCommon ¶
type XunLeiBrowserCommon struct {
*Common
*TokenResp // 登录信息
*CoreLoginResp // core登录信息
// contains filtered or unexported fields
}
func (*XunLeiBrowserCommon) CoreLogin ¶
func (xc *XunLeiBrowserCommon) CoreLogin(username string, password string) (sessionID string, err error)
func (*XunLeiBrowserCommon) DeleteOfflineTasks ¶
func (xc *XunLeiBrowserCommon) DeleteOfflineTasks(ctx context.Context, taskIDs []string) error
func (*XunLeiBrowserCommon) GetSafeAccessToken ¶
func (xc *XunLeiBrowserCommon) GetSafeAccessToken(safePassword string) (string, error)
GetSafeAccessToken 获取 超级保险柜 AccessToken
func (*XunLeiBrowserCommon) IsLogin ¶
func (xc *XunLeiBrowserCommon) IsLogin() bool
func (*XunLeiBrowserCommon) Login ¶
func (xc *XunLeiBrowserCommon) Login(username, password string) (*TokenResp, error)
Login 登录
func (*XunLeiBrowserCommon) OfflineDownload ¶
func (xc *XunLeiBrowserCommon) OfflineDownload(ctx context.Context, fileUrl string, parentDir model.Obj, fileName string) (*OfflineTask, error)
OfflineDownload 离线下载文件
func (*XunLeiBrowserCommon) OfflineList ¶
func (xc *XunLeiBrowserCommon) OfflineList(ctx context.Context, nextPageToken string) ([]OfflineTask, error)
OfflineList 获取离线下载任务列表
func (*XunLeiBrowserCommon) Put ¶
func (xc *XunLeiBrowserCommon) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error
func (*XunLeiBrowserCommon) RefreshToken ¶
func (xc *XunLeiBrowserCommon) RefreshToken(refreshToken string) (*TokenResp, error)
RefreshToken 刷新Token
func (*XunLeiBrowserCommon) Request ¶
func (xc *XunLeiBrowserCommon) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)
Request 携带Authorization和CaptchaToken的请求
func (*XunLeiBrowserCommon) SetCoreTokenResp ¶
func (xc *XunLeiBrowserCommon) SetCoreTokenResp(tr *CoreLoginResp)
SetCoreTokenResp 设置CoreToken
func (*XunLeiBrowserCommon) SetRefreshTokenFunc ¶
func (xc *XunLeiBrowserCommon) SetRefreshTokenFunc(fn func() error)
SetRefreshTokenFunc 设置刷新Token的方法
func (*XunLeiBrowserCommon) SetSpaceTokenResp ¶
func (xc *XunLeiBrowserCommon) SetSpaceTokenResp(spaceToken string)
SetSpaceTokenResp 设置Token
func (*XunLeiBrowserCommon) SetTokenResp ¶
func (xc *XunLeiBrowserCommon) SetTokenResp(tr *TokenResp)
SetTokenResp 设置Token
Click to show internal directories.
Click to hide internal directories.