client

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiGetShareInfoByCode = "/open/share/getShareInfoByCode.action"

	ApiGetFileInfo              = "/open/file/getFileInfo.action"
	ApiGetFileDownloadURL       = "/open/file/getFileDownloadUrl.action"
	ApiGetFolderInfo            = "/open/file/getFolderInfo.action"
	ApiGetNewVLCVideoPlayURL    = "/open/file/getNewVlcVideoPlayUrl.action"
	ApiGetUpResourceShare       = "/open/share/getUpResourceShare.action"
	ApiGetUserInfo              = "/open/user/getUserInfo.action"
	ApiGetUserPrivileges        = "/open/user/getUserPrivileges.action"
	ApiListResourceShareDir     = "/open/share/listResourceShareDir.action"
	ApiListShareDir             = "/open/share/listShareDir.action"
	ApiListFiles                = "/open/file/listFiles.action"
	ApiGetFamilyList            = "/open/family/manage/getFamilyList.action"
	ApiFamilyListFiles          = "/open/family/file/listFiles.action"
	ApiFamilyGetFileDownloadURL = "/open/family/file/getFileDownloadUrl.action"

	ApiSubscribeGetUser = "/open/subscribe/getUser.action"
)
View Source
const (
	TVAppKey             = "600100885"
	TVAppSignatureSecret = "fe5734c74c2f96a38157f420b32dc995"
	TvVersion            = "6.5.5"
	AndroidTV            = "FAMILY_TV"
	TvChannelId          = "home02"

	ApiUrl = "https://api.cloud.189.cn"

	UserAgent = "EcloudTV/6.5.5 (PJX110; unknown; home02) Android/35"
	Accept    = "application/json;charset=UTF-8"

	DefaultTimeout = time.Second * 30
)

Variables

This section is empty.

Functions

func AppKeySignatureHeader

func AppKeySignatureHeader(url, method string) map[string]string

func AppKeySignatureOfHmac

func AppKeySignatureOfHmac(sessionSecret, appKey, operate, fullUrl string, timestamp int64) string

AppKeySignatureOfHmac HMAC签名

Types

type AccessCount

type AccessCount struct {
	PreviewCount  int `json:"previewCount"`
	CopyCount     int `json:"copyCount"`
	DownloadCount int `json:"downloadCount"`
}

type AccessTokenResponse

type AccessTokenResponse struct {
	ExpiresIn   int64  `json:"expiresIn"`
	AccessToken string `json:"accessToken"`
}

func LoginQuery

func LoginQuery(uuid string) (*AccessTokenResponse, error)

type ApiURL

type ApiURL string

func (ApiURL) RequiresToken

func (a ApiURL) RequiresToken() bool

RequiresToken 是否需要token

type AppSessionResp

type AppSessionResp struct {
	UserSessionResp

	IsSaveName string `json:"isSaveName"`

	// 会话刷新Token
	AccessToken string `json:"accessToken"`
	//Token刷新
	RefreshToken string `json:"refreshToken"`
}

AppSessionResp 登录返回

type AuthToken

type AuthToken interface {
	IsExpired() bool
	ExpireTime() string
	ExpireDuration() time.Duration
	AccessToken() string
}

func NewAuthToken

func NewAuthToken(accessToken string, expires int64) AuthToken

type Client

type Client interface {
	WithDebug(flags ...bool) Client
	WithToken(token AuthToken) Client
	WithForceWithToken(flags ...bool) Client
	WithClient(client *resty.Client) Client

	GetShareInfo(ctx context.Context, shareCode string, opts ...GetShareInfoOption) (*GetShareInfoResponse, error)
	GetFileDownload(ctx context.Context, fileId String, opts ...GetFileDownloadOption) (*GetFileDownloadResponse, error)
	GetFileInfo(ctx context.Context, fileId String, opts ...GetFileFileOption) (*GetFileInfoResponse, error)
	GetFolderInfo(ctx context.Context, folder String, opts ...GetFolderFileOption) (*GetFolderInfoResponse, error)
	GetNewVLCVideoPlayURL(ctx context.Context, fileId String, opts ...WithGetNewVLCVideoPlayURLRequestOption) (*GetNewVLCVideoPlayURLResponse, error)
	GetUpResourceShare(ctx context.Context, upUserId string, pageNum int64, pageSize int64, opts ...GetUpResourceShareRequestOption) (*GetUpResourceShareResponse, error)
	GetUserInfo(ctx context.Context) (*GetUserInfoResponse, error)
	GetUserPrivileges(ctx context.Context) (*GetUserPrivilegesResponse, error)
	ListResourceShareDir(ctx context.Context, upUserId string, shareId int64, fileId String, opts ...WithListResourceShareDirRequestOption) (*ListFilesResponse, error)
	ListShareDir(ctx context.Context, shareId int64, fileId String, opts ...WithListShareFileRequestOption) (*ListFilesResponse, error)
	ListFiles(ctx context.Context, folderId String, opts ...WithListFilesRequestOption) (*ListFilesResponse, error)
	GetFamilyList(ctx context.Context) (*GetFamilyListResponse, error)
	FamilyListFiles(ctx context.Context, familyId String, folderId String, opts ...WithFamilyListFilesRequestOption) (*ListFilesResponse, error)
	FamilyGetFileDownload(ctx context.Context, familyId String, fileId String, opts ...FamilyGetFileDownloadOption) (*FamilyGetFileDownloadResponse, error)
	SubscribeGetUser(ctx context.Context, userId string) (*SubscribeGetUserResponse, error)
}

func New

func New() Client

type E189AccessTokenResp

type E189AccessTokenResp struct {
	E189AccessToken string `json:"accessToken"`
	ExpiresIn       int64  `json:"expiresIn"`
}

type FamilyGetFileDownloadOption added in v1.0.3

type FamilyGetFileDownloadOption func(*FamilyGetFileDownloadRequest)

type FamilyGetFileDownloadRequest added in v1.0.3

type FamilyGetFileDownloadRequest struct {
	FileId   String `url:"fileId"`
	FamilyId String `url:"familyId"`
}

type FamilyGetFileDownloadResponse added in v1.0.3

type FamilyGetFileDownloadResponse struct {
	FileDownloadUrl string `json:"fileDownloadUrl"`
}

type FamilyInfo added in v1.0.3

type FamilyInfo struct {
	Count      int    `json:"count"`
	CreateTime string `json:"createTime"`
	FamilyId   String `json:"familyId"`
	RemarkName string `json:"remarkName"`
	Type       int    `json:"type"`
	UseFlag    int    `json:"useFlag"`
	UserRole   int    `json:"userRole"`
	ExpireTime string `json:"expireTime,omitempty"`
}

type FamilyListFilesRequest added in v1.0.3

type FamilyListFilesRequest struct {
	PageNum    int    `url:"pageNum"`
	PageSize   int    `url:"pageSize"`
	MediaType  int    `url:"mediaType"`
	FamilyId   String `url:"familyId"`
	FolderId   String `url:"folderId"`
	IconOption int    `url:"iconOption"`
	OrderBy    string `url:"orderBy"`
	Descending bool   `url:"descending"`
}

type FileInfo

type FileInfo struct {
	CreateDate  string `json:"createDate"`
	FileCata    int    `json:"fileCata"`
	Id          String `json:"id"`
	LastOpTime  string `json:"lastOpTime"`
	Md5         string `json:"md5"`
	MediaType   int    `json:"mediaType"`
	Name        string `json:"name"`
	Rev         string `json:"rev"`
	Size        int64  `json:"size"`
	StarLabel   int    `json:"starLabel"`
	Orientation int    `json:"orientation,omitempty"`
}

type FolderInfo

type FolderInfo struct {
	CreateDate   string `json:"createDate"`
	FileCata     int    `json:"fileCata"`
	FileCount    int    `json:"fileCount"`
	FileListSize int    `json:"fileListSize"`
	Id           String `json:"id"`
	LastOpTime   string `json:"lastOpTime"`
	Name         string `json:"name"`
	ParentId     String `json:"parentId"`
	Rev          string `json:"rev"`
	StarLabel    int    `json:"starLabel"`
}

type GetFamilyListResponse added in v1.0.3

type GetFamilyListResponse struct {
	FamilyInfoResp []FamilyInfo `json:"familyInfoResp"`
}

type GetFileDownloadOption

type GetFileDownloadOption func(*GetFileDownloadRequest)

type GetFileDownloadRequest

type GetFileDownloadRequest struct {
	FileId String `url:"fileId"`
	Short  bool   `url:"short,omitempty"` // 是否获取短地址, true:获取短地址格式下载URL 为空或false:获取原始下载URL

	ShareId int64 `url:"shareId,omitempty"`
	Dt      int8  `url:"dt"`
	// contains filtered or unexported fields
}

type GetFileDownloadResponse

type GetFileDownloadResponse struct {
	ResCode         int    `json:"res_code"`
	ResMessage      string `json:"res_message"`
	FileDownloadUrl string `json:"fileDownloadUrl"`
}

type GetFileFileOption

type GetFileFileOption func(*GetFileInfoRequest)

type GetFileInfoRequest

type GetFileInfoRequest struct {
	FileId  String `url:"fileId"`
	Short   bool   `url:"short,omitempty"` // 是否获取短地址, true:获取短地址格式下载URL 为空或false:获取原始下载URL
	ShareId int64  `url:"shareId,omitempty"`
	Dt      int8   `url:"dt"`
}

type GetFileInfoResponse

type GetFileInfoResponse struct {
	ResCode         int    `json:"res_code"`
	ResMessage      string `json:"res_message"`
	CreateDate      string `json:"createDate"`
	FileDownloadUrl string `json:"fileDownloadUrl"`
	FilePath        string `json:"filePath"`
	Id              String `json:"id"`
	LastOpTime      int64  `json:"lastOpTime"`
	LastOpTimeStr   string `json:"lastOpTimeStr"`
	Md5             string `json:"md5"`
	Name            string `json:"name"`
	ParentId        String `json:"parentId"`
	Rev             int64  `json:"rev"`
	Size            int    `json:"size"`
}

type GetFolderFileOption

type GetFolderFileOption func(*GetFolderInfoRequest)

type GetFolderInfoRequest

type GetFolderInfoRequest struct {
	Folder  String `url:"folderId"`
	ShareId int64  `url:"shareId,omitempty"`
	Dt      int8   `url:"dt"`
}

type GetFolderInfoResponse

type GetFolderInfoResponse struct {
	ResCode       int    `json:"res_code"`
	ResMessage    string `json:"res_message"`
	CreateDate    string `json:"createDate"`    // 文件夹创建日期(YYYY-MM-DD hh:mm:ss)
	CreateTime    int64  `json:"createTime"`    // 文件夹创建时间(13位时间戳)
	FileId        String `json:"fileId"`        // 文件夹ID
	FileName      string `json:"fileName"`      // 文件夹名称
	FilePath      string `json:"filePath"`      // 文件夹路径
	LastOpTime    int64  `json:"lastOpTime"`    // 上次修改时间(13位时间戳)
	LastOpTimeStr string `json:"lastOpTimeStr"` // 上次修改时间(YYYY-MM-DD hh:mm:ss)
	ParentId      String `json:"parentId"`      // 父文件夹ID
	Rev           int64  `json:"rev"`           // 文件夹版本号
}

type GetNewVLCVideoPlayURLRequest

type GetNewVLCVideoPlayURLRequest struct {
	ShareId string `url:"shareId"`
	FileId  String `url:"fileId"`
	Type    int8   `url:"type"`
	Dt      int8   `url:"dt"`
}

type GetNewVLCVideoPlayURLResponse

type GetNewVLCVideoPlayURLResponse struct {
	ResCode    int    `json:"res_code"`
	ResMessage string `json:"res_message"`
	Normal     struct {
		Code      int    `json:"code"`
		Message   string `json:"message"`
		URL       string `json:"url"`
		VideoKbps int    `json:"videoKbps"`
	} `json:"normal"`
}

type GetShareInfoOption

type GetShareInfoOption func(*GetShareInfoRequest)

type GetShareInfoRequest

type GetShareInfoRequest struct {
	ShareCode  string `url:"shareCode"`
	AccessCode string `url:"accessCode"`
	UUID       string `url:"uuid"`
}

type GetShareInfoResponse

type GetShareInfoResponse struct {
	ResCode    int    `json:"res_code"`
	ResMessage string `json:"res_message"`
	AccessCode string `json:"accessCode"`
	Creator    struct {
		IconURL      string `json:"iconURL"`
		NickName     string `json:"nickName"`
		Oper         bool   `json:"oper"`
		OwnerAccount string `json:"ownerAccount"`
		SuperVip     int    `json:"superVip"`
		Vip          int    `json:"vip"`
	} `json:"creator"`
	ExpireTime     int    `json:"expireTime"`
	ExpireType     int    `json:"expireType"`
	FileCreateDate string `json:"fileCreateDate"`
	FileId         String `json:"fileId"`
	FileLastOpTime string `json:"fileLastOpTime"`
	FileName       string `json:"fileName"`
	FileSize       int    `json:"fileSize"`
	FileType       string `json:"fileType"`
	IsFolder       bool   `json:"isFolder"`
	MediaType      int    `json:"mediaType"`
	NeedAccessCode int    `json:"needAccessCode"`
	ReviewStatus   int    `json:"reviewStatus"`
	ShareDate      int64  `json:"shareDate"`
	ShareId        int64  `json:"shareId"`
	ShareMode      int    `json:"shareMode"`
	ShareType      int    `json:"shareType"`
}

type GetUpResourceShareRequest

type GetUpResourceShareRequest struct {
	IconOption string `url:"iconOption"`
	PageNum    int64  `url:"pageNum"`
	PageSize   int64  `url:"pageSize"`
	UpUserId   string `url:"upUserId"`
	FileName   string `url:"fileName"`
	OrderBy    string `url:"orderBy"`
	Descending bool   `url:"descending"`
}

type GetUpResourceShareRequestOption

type GetUpResourceShareRequestOption func(*GetUpResourceShareRequest)

type GetUpResourceShareResponse

type GetUpResourceShareResponse struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Data    *ShareFileList `json:"data"`
}

type GetUserInfoResponse

type GetUserInfoResponse struct {
	ResCode         int     `json:"res_code"`
	ResMessage      string  `json:"res_message"`
	Available       int64   `json:"available"`
	Capacity        int64   `json:"capacity"`
	ExtPicAvailable int     `json:"extPicAvailable"`
	ExtPicCapacity  int     `json:"extPicCapacity"`
	ExtPicUsed      int     `json:"extPicUsed"`
	HasFamily       int     `json:"hasFamily"`
	LoginName       string  `json:"loginName"`
	Mail189UsedSize int     `json:"mail189UsedSize"`
	MaxFilesize     float64 `json:"maxFilesize"`
	OrderAmount     int     `json:"orderAmount"`
	ProvinceCode    string  `json:"provinceCode"`
	UEncrypt        string  `json:"uEncrypt"`
	UMd5            string  `json:"uMd5"`
}

type GetUserPrivilegesResponse

type GetUserPrivilegesResponse struct {
	ResCode            int     `json:"res_code"`
	ResMessage         string  `json:"res_message"`
	BeginTime          string  `json:"beginTime"`
	ChannelId          string  `json:"channelId"`
	EndTime            string  `json:"endTime"`
	IsNetSDKOpen       string  `json:"isNetSDKOpen"`
	PackOverLimitSize  int64   `json:"packOverLimitSize"`
	PicEditRemainTimes int     `json:"picEditRemainTimes"`
	PicEditTotalTimes  int     `json:"picEditTotalTimes"`
	PreDecomp          int64   `json:"preDecomp"`
	ShareFileNum       int     `json:"shareFileNum"`
	TransChannel       int     `json:"transChannel"`
	TransConcurrent    int     `json:"transConcurrent"`
	TransDayFlow       int64   `json:"transDayFlow"`
	TransDownSpeed     int     `json:"transDownSpeed"` // 可以排查有没有被限速
	TransFileSize      float64 `json:"transFileSize"`
	TransQos           int     `json:"transQos"`
	TransSpeed         int     `json:"transSpeed"`
	TransVideo         int     `json:"transVideo"`
	TryNum             int     `json:"tryNum"`
	UsedDayFlow        int     `json:"usedDayFlow"`
	UserLevel          int     `json:"userLevel"`
	VipExpiredTime     string  `json:"vipExpiredTime"`
}

type ListFilesRequest added in v1.0.3

type ListFilesRequest struct {
	PageNum    int    `url:"pageNum"`
	PageSize   int    `url:"pageSize"`
	MediaType  int    `url:"mediaType"`
	FolderId   String `url:"folderId"`
	IconOption int    `url:"iconOption"`
	OrderBy    string `url:"orderBy"`
	Descending bool   `url:"descending"`
}

type ListFilesResponse

type ListFilesResponse struct {
	ResCode    int    `json:"res_code"`
	ResMessage string `json:"res_message"`
	FileListAO struct {
		Count        int64        `json:"count"`
		FileList     []FileInfo   `json:"fileList"`
		FileListSize int64        `json:"fileListSize"`
		FolderList   []FolderInfo `json:"folderList"`
	} `json:"fileListAO"`
	LastRev int64 `json:"lastRev"`
}

type ListResourceShareFileRequest

type ListResourceShareFileRequest struct {
	ShareId    string `url:"shareId"`
	FileId     String `url:"fileId"`
	UpUserId   string `url:"upUserId"`
	IsFolder   bool   `url:"isFolder"`
	IconOption int    `url:"iconOption"`
	OrderBy    string `url:"orderBy"`
	Descending bool   `url:"descending"`
	PageNum    int    `url:"pageNum"`
	PageSize   int    `url:"pageSize"`
}

type ListShareFileRequest

type ListShareFileRequest struct {
	PageNum        int    `url:"pageNum"`
	PageSize       int    `url:"pageSize"`
	FileId         String `url:"fileId"`
	ShareDirFileId String `url:"shareDirFileId"`
	IsFolder       bool   `url:"isFolder"`
	ShareId        int64  `url:"shareId"`
	ShareMode      int    `url:"shareMode"`
	IconOption     int    `url:"iconOption"`
	OrderBy        string `url:"orderBy"`
	Descending     bool   `url:"descending"`
	AccessCode     string `url:"accessCode"`
}

type ListShareFileResponse

type ListShareFileResponse struct {
	ResCode    int    `json:"res_code"`
	ResMessage string `json:"res_message"`
	ExpireTime int    `json:"expireTime"`
	ExpireType int    `json:"expireType"`
	FileListAO struct {
		Count        int64        `json:"count"`
		FileList     []FileInfo   `json:"fileList"`
		FileListSize int64        `json:"fileListSize"`
		FolderList   []FolderInfo `json:"folderList"`
	} `json:"fileListAO"`
	LastRev int64 `json:"lastRev"`
}

type RespErr

type RespErr struct {
	ResCode    any    `json:"res_code"` // int or string
	ResMessage string `json:"res_message"`

	Error_ string `json:"error"`

	XMLName xml.Name `xml:"error"`
	Code    string   `json:"code" xml:"code"`
	Message string   `json:"message" xml:"message"`
	Msg     string   `json:"msg"`

	ErrorCode string `json:"errorCode"`
	ErrorMsg  string `json:"errorMsg"`
}

RespErr 居然有四种返回方式

func (*RespErr) Error

func (e *RespErr) Error() string

func (*RespErr) HasError

func (e *RespErr) HasError() bool

type ShareFileInfo

type ShareFileInfo struct {
	LastOpTime   string      `json:"lastOpTime"`
	Heat         int         `json:"heat"`
	ShareDate    string      `json:"shareDate"`
	AccessCount  AccessCount `json:"accessCount"`
	Rev          string      `json:"rev"`
	AccessURL    string      `json:"accessURL"`
	ExpireType   int         `json:"expireType"`
	ShareId      int64       `json:"shareId"`
	RedTip       bool        `json:"redTip,omitempty"`
	TopTime      string      `json:"topTime"`
	ShareType    int         `json:"shareType"`
	ExpireTime   int         `json:"expireTime"`
	Folder       int         `json:"folder"`
	Size         int64       `json:"size"`
	IsTop        int         `json:"isTop"`
	Name         string      `json:"name"`
	ReviewStatus int         `json:"reviewStatus"`
	Id           String      `json:"id"`
	CreateDate   string      `json:"createDate"`
	Status       int         `json:"status"`
	Md5          string      `json:"md5"`
}

type ShareFileList

type ShareFileList struct {
	Count    int64            `json:"count"`
	FileList []*ShareFileInfo `json:"fileList"`
}

type String

type String string

func (*String) Unmarshal

func (s *String) Unmarshal(b []byte) error

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(b []byte) error

func (*String) UnmarshalXML

func (s *String) UnmarshalXML(e *xml.Decoder, ee xml.StartElement) error

type SubscribeGetUserInfo added in v1.0.2

type SubscribeGetUserInfo struct {
	Id               int64       `json:"id"`
	UserId           string      `json:"userId"`
	Name             string      `json:"name"`
	Picture          string      `json:"picture"`
	FansNum          int         `json:"fansNum"`
	FollowNum        int         `json:"followNum"`
	Status           int         `json:"status"`
	Ip               interface{} `json:"ip"`
	IsVip            int         `json:"isVip"`
	IsFirstSubscribe int         `json:"isFirstSubscribe"`
	Phone            string      `json:"phone"`
	Brief            interface{} `json:"brief"`
	OrderNum         interface{} `json:"orderNum"`
	ExtendOne        string      `json:"extendOne"`
	ExtendTwo        string      `json:"extendTwo"`
	CreateTime       time.Time   `json:"createTime"`
	UpdateTime       time.Time   `json:"updateTime"`
	PushSwitch       int         `json:"pushSwitch"`
	ExtendThree      interface{} `json:"extendThree"`
	ExtendFour       interface{} `json:"extendFour"`
	IsFollow         interface{} `json:"isFollow"`
}

type SubscribeGetUserRequest added in v1.0.2

type SubscribeGetUserRequest struct {
	UserId string `url:"userId"`
}

type SubscribeGetUserResponse added in v1.0.2

type SubscribeGetUserResponse struct {
	Code string               `json:"code"`
	Msg  string               `json:"msg"`
	Data SubscribeGetUserInfo `json:"data"`
}

type UUIDInfoResp

type UUIDInfoResp struct {
	UUID string `json:"uuid"`
}

func LoginInit

func LoginInit() (*UUIDInfoResp, error)

type UserSessionResp

type UserSessionResp struct {
	ResCode    int    `json:"res_code"`
	ResMessage string `json:"res_message"`

	LoginName string `json:"loginName"`

	KeepAlive       int `json:"keepAlive"`
	GetFileDiffSpan int `json:"getFileDiffSpan"`
	GetUserInfoSpan int `json:"getUserInfoSpan"`

	// 个人云
	SessionKey    string `json:"sessionKey"`
	SessionSecret string `json:"sessionSecret"`
	// 家庭云
	FamilySessionKey    string `json:"familySessionKey"`
	FamilySessionSecret string `json:"familySessionSecret"`
}

type WithFamilyListFilesRequestOption added in v1.0.3

type WithFamilyListFilesRequestOption func(*FamilyListFilesRequest)

type WithGetNewVLCVideoPlayURLRequestOption

type WithGetNewVLCVideoPlayURLRequestOption func(*GetNewVLCVideoPlayURLRequest)

type WithListFilesRequestOption added in v1.0.3

type WithListFilesRequestOption func(*ListFilesRequest)

type WithListResourceShareDirRequestOption

type WithListResourceShareDirRequestOption func(*ListResourceShareFileRequest)

type WithListShareFileRequestOption

type WithListShareFileRequestOption func(*ListShareFileRequest)

Jump to

Keyboard shortcuts

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