baiduphoto

package
v3.35.2-8Mi Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_URL         = "https://photo.baidu.com/youai"
	USER_API_URL    = API_URL + "/user/v1"
	ALBUM_API_URL   = API_URL + "/album/v1"
	FILE_API_URL_V1 = API_URL + "/file/v1"
	FILE_API_URL_V2 = API_URL + "/file/v2"
)

Variables

This section is empty.

Functions

func BoolToIntStr

func BoolToIntStr(b bool) string

func MustString

func MustString(str string, err error) string

Types

type Addition

type Addition struct {
	RefreshToken string `json:"refresh_token" required:"true"`
	ShowType     string `json:"show_type" type:"select" options:"root,root_only_album,root_only_file" default:"root"`
	AlbumID      string `json:"album_id"`
	//AlbumPassword string `json:"album_password"`
	DeleteOrigin bool   `json:"delete_origin"`
	ClientID     string `json:"client_id" required:"true" default:"iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v"`
	ClientSecret string `json:"client_secret" required:"true" default:"jXiFMOPVPCWlO2M5CwWQzffpNPaGTRBG"`
	UploadThread string `json:"upload_thread" default:"3" help:"1<=thread<=32"`
}

type Album

type Album struct {
	AlbumID      string `json:"album_id"`
	Tid          int64  `json:"tid"`
	Title        string `json:"title"`
	JoinTime     int64  `json:"join_time"`
	CreationTime int64  `json:"create_time"`
	Mtime        int64  `json:"mtime"`
	// contains filtered or unexported fields
}

相册部分

func (*Album) CreateTime

func (a *Album) CreateTime() time.Time

func (*Album) GetHash

func (a *Album) GetHash() utils.HashInfo

func (*Album) GetID

func (a *Album) GetID() string

func (*Album) GetName

func (a *Album) GetName() string

func (*Album) GetPath

func (a *Album) GetPath() string

func (*Album) GetSize

func (a *Album) GetSize() int64

func (*Album) IsDir

func (a *Album) IsDir() bool

func (*Album) ModTime

func (a *Album) ModTime() time.Time

type AlbumFile

type AlbumFile struct {
	File
	AlbumID string `json:"album_id"`
	Tid     int64  `json:"tid"`
	Uk      int64  `json:"uk"`
}

相册部分

type AlbumFileListResp

type AlbumFileListResp struct {
	Page
	List       []AlbumFile `json:"list"`
	Reset      int64       `json:"reset"`
	TotalCount int64       `json:"total_count"`
}

相册部分

type AlbumListResp

type AlbumListResp struct {
	Page
	List       []Album `json:"list"`
	Reset      int64   `json:"reset"`
	TotalCount int64   `json:"total_count"`
}

相册部分

type BaiduPhoto

type BaiduPhoto struct {
	model.Storage
	Addition

	AccessToken string
	Uk          int64
	// contains filtered or unexported fields
}

func (*BaiduPhoto) AddAlbumFile

func (d *BaiduPhoto) AddAlbumFile(ctx context.Context, album *Album, file *File) (*AlbumFile, error)

增加相册文件

func (*BaiduPhoto) Config

func (d *BaiduPhoto) Config() driver.Config

func (*BaiduPhoto) Copy

func (d *BaiduPhoto) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error)

func (*BaiduPhoto) CopyAlbumFile

func (d *BaiduPhoto) CopyAlbumFile(ctx context.Context, file *AlbumFile) (*File, error)

保存相册文件为根文件

func (*BaiduPhoto) CreateAlbum

func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, error)

创建相册

func (*BaiduPhoto) DeleteAlbum

func (d *BaiduPhoto) DeleteAlbum(ctx context.Context, album *Album) error

删除相册

func (*BaiduPhoto) DeleteAlbumFile

func (d *BaiduPhoto) DeleteAlbumFile(ctx context.Context, file *AlbumFile) error

删除相册文件

func (*BaiduPhoto) DeleteFile

func (d *BaiduPhoto) DeleteFile(ctx context.Context, file *File) error

删除根文件

func (*BaiduPhoto) Drop

func (d *BaiduPhoto) Drop(ctx context.Context) error

func (*BaiduPhoto) Get

func (d *BaiduPhoto) Get(furl string, callback base.ReqCallback, resp interface{}) (*resty.Response, error)

func (*BaiduPhoto) GetAddition

func (d *BaiduPhoto) GetAddition() driver.Additional

func (*BaiduPhoto) GetAlbumDetail

func (d *BaiduPhoto) GetAlbumDetail(ctx context.Context, albumID string) (*Album, error)

获取相册详细信息

func (*BaiduPhoto) GetAllAlbum

func (d *BaiduPhoto) GetAllAlbum(ctx context.Context) (albums []Album, err error)

获取所有相册

func (*BaiduPhoto) GetAllAlbumFile

func (d *BaiduPhoto) GetAllAlbumFile(ctx context.Context, album *Album, passwd string) (files []AlbumFile, err error)

获取相册中所有文件

func (*BaiduPhoto) GetAllFile

func (d *BaiduPhoto) GetAllFile(ctx context.Context) (files []File, err error)

获取所有文件

func (*BaiduPhoto) GetRoot

func (d *BaiduPhoto) GetRoot(ctx context.Context) (model.Obj, error)

func (*BaiduPhoto) Init

func (d *BaiduPhoto) Init(ctx context.Context) error

func (*BaiduPhoto) JoinAlbum

func (d *BaiduPhoto) JoinAlbum(ctx context.Context, code string) (*Album, error)

加入相册

func (d *BaiduPhoto) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)

func (*BaiduPhoto) List

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

func (*BaiduPhoto) MakeDir

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

func (*BaiduPhoto) Move

func (d *BaiduPhoto) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error)

func (*BaiduPhoto) Post

func (d *BaiduPhoto) Post(furl string, callback base.ReqCallback, resp interface{}) (*resty.Response, error)

func (*BaiduPhoto) Put

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

func (*BaiduPhoto) Remove

func (d *BaiduPhoto) Remove(ctx context.Context, obj model.Obj) error

func (*BaiduPhoto) Rename

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

func (*BaiduPhoto) Request

func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) (*resty.Response, error)

func (*BaiduPhoto) SetAlbumName

func (d *BaiduPhoto) SetAlbumName(ctx context.Context, album *Album, name string) (*Album, error)

相册改名

type CopyFile

type CopyFile struct {
	FromFsid  int64  `json:"from_fsid"` // 源ID
	Ctime     int64  `json:"ctime"`
	Fsid      int64  `json:"fsid"` // 目标ID
	Path      string `json:"path"`
	ShootTime int    `json:"shoot_time"`
}

type CopyFileResp

type CopyFileResp struct {
	List []CopyFile `json:"list"`
}

type CreateFileResp

type CreateFileResp struct {
	Data UploadFile `json:"data"`
}

上传部分

type Erron

type Erron struct {
	Errno     int `json:"errno"`
	RequestID int `json:"request_id"`
}

type File

type File struct {
	Fsid     int64    `json:"fsid"` // 文件ID
	Path     string   `json:"path"` // 文件路径
	Size     int64    `json:"size"`
	Ctime    int64    `json:"ctime"` // 创建时间 s
	Mtime    int64    `json:"mtime"` // 修改时间 s
	Thumburl []string `json:"thumburl"`
	Md5      string   `json:"md5"`
}

func (*File) CreateTime

func (c *File) CreateTime() time.Time

func (*File) GetHash

func (c *File) GetHash() utils.HashInfo

func (*File) GetID

func (c *File) GetID() string

func (*File) GetName

func (c *File) GetName() string

func (*File) GetPath

func (c *File) GetPath() string

func (*File) GetSize

func (c *File) GetSize() int64

func (*File) IsDir

func (c *File) IsDir() bool

func (*File) ModTime

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

func (*File) Thumb

func (c *File) Thumb() string

type FileListResp

type FileListResp struct {
	Page
	List []File `json:"list"`
}

type InviteResp

type InviteResp struct {
	Pdata struct {
		// 邀请码
		InviteCode string `json:"invite_code"`
		// 有效时间
		ExpireTime int    `json:"expire_time"`
		ShareID    string `json:"share_id"`
	} `json:"pdata"`
}

共享相册部分

type JoinOrCreateAlbumResp

type JoinOrCreateAlbumResp struct {
	AlbumID       string `json:"album_id"`
	AlreadyExists int    `json:"already_exists"`
}

加入相册部分

type Page

type Page struct {
	HasMore int    `json:"has_more"`
	Cursor  string `json:"cursor"`
}

func (Page) HasNextPage

func (p Page) HasNextPage() bool

type PrecreateResp

type PrecreateResp struct {
	ReturnType int `json:"return_type"` //存在返回2 不存在返回1 已经保存3
	//存在返回
	CreateFileResp

	//不存在返回
	Path      string `json:"path"`
	UploadID  string `json:"uploadid"`
	BlockList []int  `json:"block_list"`
}

上传部分

type Root

type Root = model.Object

type TokenErrResp

type TokenErrResp struct {
	ErrorDescription string `json:"error_description"`
	ErrorMsg         string `json:"error"`
}

func (*TokenErrResp) Error

func (e *TokenErrResp) Error() string

type UInfo

type UInfo struct {
	// uk
	YouaID string `json:"youa_id"`
}

用户信息

type UploadFile

type UploadFile struct {
	FsID           int64  `json:"fs_id"`
	Size           int64  `json:"size"`
	Md5            string `json:"md5"`
	ServerFilename string `json:"server_filename"`
	Path           string `json:"path"`
	Ctime          int64  `json:"ctime"`
	Mtime          int64  `json:"mtime"`
	Isdir          int    `json:"isdir"`
	Category       int    `json:"category"`
	ServerMd5      string `json:"server_md5"`
	ShootTime      int    `json:"shoot_time"`
}

上传部分

Jump to

Keyboard shortcuts

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