thunder

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	API_URL        = "https://api-pan.xunlei.com/drive/v1"
	FILE_API_URL   = API_URL + "/files"
	XLUSER_API_URL = "https://xluser-ssl.xunlei.com/v1"
)
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"
)

Variables

This section is empty.

Functions

func GetAction

func GetAction(method string, url string) string

Types

type Addition

type Addition struct {
	driver.RootID
	Username     string `json:"username" required:"true"`
	Password     string `json:"password" required:"true"`
	CaptchaToken string `json:"captcha_token"`
}

func (*Addition) GetIdentity

func (i *Addition) GetIdentity() string

登录特征,用于判断是否重新登录

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 CaptchaTokenResponse struct {
	CaptchaToken string `json:"captcha_token"`
	ExpiresIn    int64  `json:"expires_in"`
	Url          string `json:"url"`
}

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
	// contains filtered or unexported fields
}

func (*Common) GetCaptchaSign

func (c *Common) GetCaptchaSign() (timestamp, sign string)

获取验证码签名

func (*Common) GetCaptchaToken

func (c *Common) GetCaptchaToken() string

func (*Common) RefreshCaptchaTokenAtLogin

func (c *Common) RefreshCaptchaTokenAtLogin(action, userID string) error

刷新验证码token(登录后)

func (*Common) RefreshCaptchaTokenInLogin

func (c *Common) RefreshCaptchaTokenInLogin(action, username string) error

刷新验证码token(登录时)

func (*Common) Request

func (c *Common) Request(url, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)

只有基础信息的请求

func (*Common) SetCaptchaToken

func (c *Common) SetCaptchaToken(captchaToken string)

type ErrResp

type ErrResp struct {
	ErrorCode        int64  `json:"error_code"`
	ErrorMsg         string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

func (*ErrResp) Error

func (e *ErrResp) Error() string

func (*ErrResp) IsError

func (e *ErrResp) IsError() bool

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"`

	// 签名方法1
	Algorithms string `` /* 354-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"`

	// 必要且影响登录,由签名决定
	DeviceID      string `json:"device_id"  required:"true" default:"9aa5c268e7bcfc197a9ad88e2fb330e5"`
	ClientID      string `json:"client_id"  required:"true" default:"Xp6vsxz_7IYVw2BB"`
	ClientSecret  string `json:"client_secret"  required:"true" default:"Xp6vsy4tN9toTVdMSpomVdXpRmES"`
	ClientVersion string `json:"client_version"  required:"true" default:"7.51.0.8196"`
	PackageName   string `json:"package_name"  required:"true" default:"com.xunlei.downloadprovider"`

	//不影响登录,影响下载速度
	UserAgent         string `` /* 298-byte string literal not displayed */
	DownloadUserAgent string `json:"download_user_agent"  required:"true" default:"Dalvik/2.1.0 (Linux; U; Android 12; M2004J7AC Build/SP1A.210812.016)"`

	//优先使用视频链接代替下载链接
	UseVideoUrl bool `json:"use_video_url"`
}

高级设置

func (*ExpertAddition) GetIdentity

func (i *ExpertAddition) GetIdentity() string

登录特征,用于判断是否重新登录

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"`
}

* 文件 *

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    time.Time `json:"created_time"`
	ModifiedTime   time.Time `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"`
		MediaID        string `json:"media_id"`
		MediaName      string `json:"media_name"`
		NeedMoreQuota  bool   `json:"need_more_quota"`
		Priority       int    `json:"priority"`
		RedirectLink   string `json:"redirect_link"`
		ResolutionName string `json:"resolution_name"`
		Video          struct {
			AudioCodec string `json:"audio_codec"`
			BitRate    int    `json:"bit_rate"`
			Duration   int    `json:"duration"`
			FrameRate  int    `json:"frame_rate"`
			Height     int    `json:"height"`
			VideoCodec string `json:"video_codec"`
			VideoType  string `json:"video_type"`
			Width      int    `json:"width"`
		} `json:"video"`
		VipTypes []string `json:"vip_types"`
	} `json:"medias"`
	Trashed     bool   `json:"trashed"`
	DeleteTime  string `json:"delete_time"`
	OriginalURL string `json:"original_url"`
}

func (*Files) GetID

func (c *Files) GetID() string

func (*Files) GetName

func (c *Files) GetName() string

func (*Files) GetPath

func (c *Files) GetPath() string

func (*Files) GetSize

func (c *Files) GetSize() int64

func (*Files) IsDir

func (c *Files) IsDir() bool

func (*Files) ModTime

func (c *Files) ModTime() time.Time

func (*Files) Thumb

func (c *Files) Thumb() string
type Link struct {
	URL    string    `json:"url"`
	Token  string    `json:"token"`
	Expire time.Time `json:"expire"`
	Type   string    `json:"type"`
}

type SignInRequest

type SignInRequest struct {
	CaptchaToken string `json:"captcha_token"`

	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`

	Username string `json:"username"`
	Password string `json:"password"`
}

type Thunder

type Thunder struct {
	*XunLeiCommon
	model.Storage
	Addition
	// contains filtered or unexported fields
}

func (*Thunder) Config

func (x *Thunder) Config() driver.Config

func (*Thunder) Drop

func (x *Thunder) Drop(ctx context.Context) error

func (*Thunder) GetAddition

func (x *Thunder) GetAddition() driver.Additional

func (*Thunder) Init

func (x *Thunder) Init(ctx context.Context) (err error)

type ThunderExpert

type ThunderExpert struct {
	*XunLeiCommon
	model.Storage
	ExpertAddition
	// contains filtered or unexported fields
}

func (*ThunderExpert) Config

func (x *ThunderExpert) Config() driver.Config

func (*ThunderExpert) Drop

func (x *ThunderExpert) Drop(ctx context.Context) error

func (*ThunderExpert) GetAddition

func (x *ThunderExpert) GetAddition() driver.Additional

func (*ThunderExpert) Init

func (x *ThunderExpert) Init(ctx context.Context) (err error)

func (*ThunderExpert) SetTokenResp

func (x *ThunderExpert) 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"`
}

* 登录 *

func (*TokenResp) Token

func (t *TokenResp) Token() string

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 XunLeiCommon

type XunLeiCommon struct {
	*Common
	*TokenResp // 登录信息
	// contains filtered or unexported fields
}

func (*XunLeiCommon) Copy

func (xc *XunLeiCommon) Copy(ctx context.Context, srcObj, dstDir model.Obj) error

func (*XunLeiCommon) IsLogin

func (xc *XunLeiCommon) IsLogin() bool
func (xc *XunLeiCommon) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)

func (*XunLeiCommon) List

func (xc *XunLeiCommon) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error)

func (*XunLeiCommon) Login

func (xc *XunLeiCommon) Login(username, password string) (*TokenResp, error)

登录

func (*XunLeiCommon) MakeDir

func (xc *XunLeiCommon) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error

func (*XunLeiCommon) Move

func (xc *XunLeiCommon) Move(ctx context.Context, srcObj, dstDir model.Obj) error

func (*XunLeiCommon) Put

func (xc *XunLeiCommon) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error

func (*XunLeiCommon) RefreshToken

func (xc *XunLeiCommon) RefreshToken(refreshToken string) (*TokenResp, error)

刷新Token

func (*XunLeiCommon) Remove

func (xc *XunLeiCommon) Remove(ctx context.Context, obj model.Obj) error

func (*XunLeiCommon) Rename

func (xc *XunLeiCommon) Rename(ctx context.Context, srcObj model.Obj, newName string) error

func (*XunLeiCommon) Request

func (xc *XunLeiCommon) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)

携带Authorization和CaptchaToken的请求

func (*XunLeiCommon) SetRefreshTokenFunc

func (xc *XunLeiCommon) SetRefreshTokenFunc(fn func() error)

设置刷新Token的方法

func (*XunLeiCommon) SetTokenResp

func (xc *XunLeiCommon) SetTokenResp(tr *TokenResp)

设置Token

Jump to

Keyboard shortcuts

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