Documentation
¶
Overview ¶
Package elevengo is an API client of 115 Cloud Storage Service, it bases on 115 web APIs which captured from their web pages.
Index ¶
- func IsCaptchaRequired(err error) bool
- func IsIteratorEnd(err error) bool
- type Agent
- func (a *Agent) CaptchaKeyImage(session *CaptchaSession, index int) (data []byte, err error)
- func (a *Agent) CaptchaStart(session *CaptchaSession) (err error)
- func (a *Agent) CaptchaSubmit(session *CaptchaSession, code string) (err error)
- func (a *Agent) CredentialExport(cr *Credential)
- func (a *Agent) CredentialImport(cr *Credential) (err error)
- func (a *Agent) DirGetId(path string) (dirId string, err error)
- func (a *Agent) DirMake(parentId string, name string) (dirId string, err error)
- func (a *Agent) DirSetOrder(dirId string, order DirOrder, asc bool) (err error)
- func (a *Agent) DownloadCreateTicket(pickcode string, ticket *DownloadTicket) (err error)
- func (a *Agent) FileCopy(dirId string, fileIds ...string) (err error)
- func (a *Agent) FileDelete(fileIds ...string) (err error)
- func (a *Agent) FileFindDuplications(fileId string) (dupIds []string, err error)
- func (a *Agent) FileGet(fileId string, file *File) (err error)
- func (a *Agent) FileIterate(dirId string) (it Iterator[File], err error)
- func (a *Agent) FileLabeled(labelId string) (it Iterator[File], err error)
- func (a *Agent) FileMove(dirId string, fileIds ...string) (err error)
- func (a *Agent) FileRename(fileId, newName string) (err error)
- func (a *Agent) FileSearch(dirId, keyword string) (it Iterator[File], err error)
- func (a *Agent) FileSetLabels(fileId string, labelIds ...string) (err error)
- func (a *Agent) FileStar(fileId string, star bool) (err error)
- func (a *Agent) FileStared() (it Iterator[File], err error)
- func (a *Agent) FileStat(fileId string, info *FileInfo) (err error)
- func (a *Agent) Get(url string) (body io.ReadCloser, err error)
- func (a *Agent) GetRange(url string, rng Range) (body io.ReadCloser, err error)
- func (a *Agent) ImageGetUrl(pickcode string) (imageUrl string, err error)
- func (a *Agent) Import(dirId string, ticket *ImportTicket) (err error)
- func (a *Agent) ImportCalculateSignValue(pickcode string, signRange string) (value string, err error)
- func (a *Agent) ImportCreateTicket(fileId string, ticket *ImportTicket) (pickcode string, err error)
- func (a *Agent) LabelCreate(name string, color LabelColor) (labelId string, err error)
- func (a *Agent) LabelDelete(labelId string) (err error)
- func (a *Agent) LabelFind(name string, label *Label) (err error)
- func (a *Agent) LabelIterate() (it Iterator[Label], err error)
- func (a *Agent) LabelUpdate(label *Label) (err error)
- func (a *Agent) LoginCheck() bool
- func (a *Agent) OfflineAdd(url string, dirId string) (result OfflineAddResult)
- func (a *Agent) OfflineBatchAdd(urls []string, dirId string) (results []OfflineAddResult, err error)
- func (a *Agent) OfflineClear(flag OfflineClearFlag) (err error)
- func (a *Agent) OfflineDelete(deleteFiles bool, hashes ...string) (err error)
- func (a *Agent) OfflineIterate() (it Iterator[OfflineTask], err error)
- func (a *Agent) QrcodeLogin(session *QrcodeSession) (err error)
- func (a *Agent) QrcodeStart(session *QrcodeSession) (err error)
- func (a *Agent) QrcodeStatus(session *QrcodeSession) (status QrcodeStatus, err error)
- func (a *Agent) StorageFormatStat(info *StorageFormatInfo) (err error)
- func (a *Agent) StorageStat(info *StorageInfo) (err error)
- func (a *Agent) UploadCreateOssTicket(dirId, name string, r io.ReadSeeker, ticket *UploadOssTicket) (err error)
- func (a *Agent) UploadCreateTicket(dirId, name string, r io.ReadSeeker, ticket *UploadTicket) (err error)
- func (a *Agent) UploadParseResult(r io.Reader, file *File) (err error)
- func (a *Agent) UploadSimply(dirId, name string, size int64, r io.Reader) (fileId string, err error)
- func (a *Agent) UserGet(info *UserInfo) (err error)
- func (a *Agent) Version() string
- func (a *Agent) VideoGet(pickcode string, video *Video) (err error)
- type CaptchaSession
- type Credential
- type DirInfo
- type DirOrder
- type DownloadTicket
- type ErrImportNeedCheck
- type File
- type FileInfo
- type ImportTicket
- type Iterator
- type Label
- type LabelColor
- type OfflineAddResult
- type OfflineClearFlag
- type OfflineTask
- type QrcodeSession
- type QrcodeStatus
- type Range
- type StorageFormatInfo
- type StorageInfo
- type UploadOssTicket
- type UploadTicket
- type UserInfo
- type Video
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCaptchaRequired ¶ added in v0.4.1
IsCaptchaRequired indicates whether err requires user to solve a captcha.
func IsIteratorEnd ¶ added in v0.2.2
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent holds signed-in user's credentials, and provides methods to access upstream server's features, such as file management, offline download, etc.
func (*Agent) CaptchaKeyImage ¶
func (a *Agent) CaptchaKeyImage(session *CaptchaSession, index int) (data []byte, err error)
CaptchaKeyImage gets one CAPTCHA key image data.
You can call this method multiple times, it will return the same character in different font on every calling.
It is useful when you try to train your CAPTCHA solver.
func (*Agent) CaptchaStart ¶
func (a *Agent) CaptchaStart(session *CaptchaSession) (err error)
CaptchaStart starts a CAPTCHA session.
Example ¶
agent := Default()
var err error
// Start captcha session.
session := &CaptchaSession{}
if err = agent.CaptchaStart(session); err != nil {
log.Fatalf("Start captcha session error: %s", err)
}
// 1. Show `session.CodeImage` and `session.KeysImage` to user.
// 2. Ask user to give the captcha code.
if err = agent.CaptchaSubmit(session, "code"); err != nil {
log.Fatalf("Submit captcha code error: %s", err)
}
func (*Agent) CaptchaSubmit ¶
func (a *Agent) CaptchaSubmit(session *CaptchaSession, code string) (err error)
CaptchaSubmit submits the CAPTCHA code to session.
func (*Agent) CredentialExport ¶ added in v0.1.3
func (a *Agent) CredentialExport(cr *Credential)
CredentialExport exports credentials for future-use.
func (*Agent) CredentialImport ¶ added in v0.1.3
func (a *Agent) CredentialImport(cr *Credential) (err error)
CredentialImport imports credentials into agent.
Example ¶
agent := Default()
// Import credential to agent
if err := agent.CredentialImport(&Credential{
UID: "UID-From-Cookie",
CID: "CID-From-Cookie",
SEID: "SEID-From-Cookie",
}); err != nil {
log.Fatalf("Import credentail error: %s", err)
}
func (*Agent) DirSetOrder ¶ added in v0.2.1
DirSetOrder sets how files under the directory be ordered.
func (*Agent) DownloadCreateTicket ¶ added in v0.1.4
func (a *Agent) DownloadCreateTicket(pickcode string, ticket *DownloadTicket) (err error)
DownloadCreateTicket creates ticket which contains all required information to download a file. Caller can use third-party tools/libraries to download file, such as wget/curl/aria2.
Example ¶
agent := Default()
// Create download ticket
var err error
ticket := DownloadTicket{}
if err = agent.DownloadCreateTicket("pickcode", &ticket); err != nil {
log.Fatalf("Get download ticket error: %s", err)
}
// Process download ticket through curl
cmd := exec.Command("/usr/bin/curl", ticket.Url)
for name, value := range ticket.Headers {
cmd.Args = append(cmd.Args, "-H", fmt.Sprintf("%s: %s", name, value))
}
cmd.Args = append(cmd.Args, "-o", ticket.FileName)
if err = cmd.Run(); err != nil {
log.Fatal(err)
} else {
log.Printf("File downloaded to %s", ticket.FileName)
}
func (*Agent) FileDelete ¶
FileDelete deletes files.
func (*Agent) FileFindDuplications ¶ added in v0.2.1
FileFindDuplications finds all duplicate files which have the same SHA1 hash with the given file, and return their ID.
func (*Agent) FileIterate ¶ added in v0.2.2
FileIterate returns an iterator.
Example ¶
agent := Default()
it, err := agent.FileIterate("0")
for ; err == nil; err = it.Next() {
file := &File{}
_ = it.Get(file)
log.Printf("File: %d => %#v", it.Index(), file)
}
if !IsIteratorEnd(err) {
log.Fatalf("Iterate file failed: %s", err.Error())
}
func (*Agent) FileLabeled ¶ added in v0.2.1
FileLabeled lists all files which has specific label.
func (*Agent) FileRename ¶
FileRename renames file to new name.
func (*Agent) FileSearch ¶
FileSearch recursively searches files under dirId, whose name contains keyword.
func (*Agent) FileSetLabels ¶ added in v0.2.1
FileSetLabels sets labels for a file, you can also remove all labels from it by not passing any labelId.
func (*Agent) FileStar ¶ added in v0.2.1
FileStar adds/removes star from a file, whose ID is fileId.
func (*Agent) FileStared ¶ added in v0.2.1
FileStared lists all stared files.
func (*Agent) Get ¶ added in v0.2.1
func (a *Agent) Get(url string) (body io.ReadCloser, err error)
Get gets content from url using agent underlying HTTP client.
func (*Agent) GetRange ¶ added in v0.3.1
GetRange gets partial content from |url|, which is located by |rng|.
func (*Agent) ImageGetUrl ¶ added in v0.2.1
ImageGetUrl gets an accessible URL of an image file by its pickcode.
func (*Agent) Import ¶ added in v0.2.1
func (a *Agent) Import(dirId string, ticket *ImportTicket) (err error)
Import imports(aka. fast-upload) a file to your 115 cloud storage. Please check example code for the detailed usage.
Example ¶
var err error
// Initialize two agents for sender and receiver
sender, receiver := Default(), Default()
sender.CredentialImport(&Credential{
UID: "", CID: "", SEID: "",
})
receiver.CredentialImport(&Credential{
UID: "", CID: "", SEID: "",
})
// File to send on sender's storage
fileId := "12345678"
// Create import ticket by sender
ticket, pickcode := &ImportTicket{}, ""
if pickcode, err = sender.ImportCreateTicket(fileId, ticket); err != nil {
log.Fatalf("Get file info failed: %s", err)
}
// Directory to save file on receiver's storage
dirId := "0"
// Call Import first time
if err = receiver.Import(dirId, ticket); err != nil {
if ie, ok := err.(*ErrImportNeedCheck); ok {
// Calculate sign value by sender
signValue, err := sender.ImportCalculateSignValue(pickcode, ie.SignRange)
if err != nil {
log.Fatalf("Calculate sign value failed: %s", err)
}
// Update ticket and import again
ticket.SignKey, ticket.SignValue = ie.SignKey, signValue
if err = receiver.Import(dirId, ticket); err == nil {
log.Print("Import succeeded!")
} else {
log.Fatalf("Import failed: %s", err)
}
} else {
log.Fatalf("Import failed: %s", err)
}
} else {
log.Print("Import succeeded!")
}
func (*Agent) ImportCalculateSignValue ¶ added in v0.4.2
func (a *Agent) ImportCalculateSignValue(pickcode string, signRange string) (value string, err error)
ImportCalculateSignValue calculates sign value of a file on cloud storage. Please check example code for the detailed usage.
func (*Agent) ImportCreateTicket ¶ added in v0.3.1
func (a *Agent) ImportCreateTicket(fileId string, ticket *ImportTicket) (pickcode string, err error)
ImportCreateTicket is a helper function to create an ImportTicket of a file, that you can share to others to import this file to their cloud storage. You should also send pickcode together with ticket.
func (*Agent) LabelCreate ¶ added in v0.2.1
func (a *Agent) LabelCreate(name string, color LabelColor) (labelId string, err error)
LabelCreate creates a label with name and color, returns its ID.
func (*Agent) LabelDelete ¶ added in v0.2.1
LabelDelete deletes a label whose ID is labelId.
func (*Agent) LabelIterate ¶ added in v0.2.1
func (*Agent) LabelUpdate ¶ added in v0.2.1
LabelUpdate updates label's name or color.
func (*Agent) LoginCheck ¶ added in v0.2.1
func (*Agent) OfflineAdd ¶
func (a *Agent) OfflineAdd(url string, dirId string) (result OfflineAddResult)
OfflineAdd adds an offline task with url, and saves the downloaded files at directory whose ID is dirId. You can pass empty string as dirId, to save the downloaded files at default directory.
func (*Agent) OfflineBatchAdd ¶ added in v0.4.1
func (a *Agent) OfflineBatchAdd(urls []string, dirId string) (results []OfflineAddResult, err error)
OfflineBatchAdd adds many offline tasks in one request.
func (*Agent) OfflineClear ¶
func (a *Agent) OfflineClear(flag OfflineClearFlag) (err error)
OfflineClear clears tasks which is in specific status.
func (*Agent) OfflineDelete ¶
OfflineDelete deletes tasks.
func (*Agent) OfflineIterate ¶ added in v0.2.1
func (a *Agent) OfflineIterate() (it Iterator[OfflineTask], err error)
OfflineIterate returns an iterator for travelling offline tasks, it will return an error if there are no tasks.
Example ¶
agent := Default()
for it, err := agent.OfflineIterate(); err == nil; err = it.Next() {
task := &OfflineTask{}
err = it.Get(task)
if err != nil {
log.Printf("Offline task: %#v", task)
}
}
func (*Agent) QrcodeLogin ¶
func (a *Agent) QrcodeLogin(session *QrcodeSession) (err error)
QrcodeLogin logins user through QRCode. You SHOULD call this method ONLY when `QrcodeStatus.IsAllowed()` is true.
func (*Agent) QrcodeStart ¶
func (a *Agent) QrcodeStart(session *QrcodeSession) (err error)
QrcodeStart starts a QRCode login session.
Example ¶
agent := Default()
session := &QrcodeSession{}
err := agent.QrcodeStart(session)
if err != nil {
log.Fatalf("Start QRcode session error: %s", err)
}
// Convert `session.Content` to QRCode, show it to user, and prompt user
// to scan it using mobile app.
for {
var status QrcodeStatus
// Get QR-Code status
status, err = agent.QrcodeStatus(session)
if err != nil {
log.Fatalf("Get QRCode status error: %s", err)
} else {
// Check QRCode status
if status.IsWaiting() {
log.Println("Please scan the QRCode in mobile app.")
} else if status.IsScanned() {
log.Println("QRCode has been scanned, please allow this login in mobile app.")
} else if status.IsAllowed() {
err = agent.QrcodeLogin(session)
if err == nil {
log.Println("QRCode login successes!")
} else {
log.Printf("Submit QRcode login error: %s", err)
}
break
} else if status.IsCanceled() {
fmt.Println("User canceled this login!")
break
}
}
}
func (*Agent) QrcodeStatus ¶
func (a *Agent) QrcodeStatus(session *QrcodeSession) (status QrcodeStatus, err error)
QrcodeStatus returns the status of QRCode login session.
The upstream API uses a long-pull request for 30 seconds, so this API will also block at most 30 seconds, be careful to use it in main goroutine.
There will be 4 kinds of status:
- Waiting
- Scanned
- Allowed
- Canceled
The QRCode will expire in 5 minutes, when it expired, an error will be return, caller can use IsQrcodeExpire() to check that.
func (*Agent) StorageFormatStat ¶ added in v0.2.2
func (a *Agent) StorageFormatStat(info *StorageFormatInfo) (err error)
StorageFormatStat gets storage size information format.
func (*Agent) StorageStat ¶
func (a *Agent) StorageStat(info *StorageInfo) (err error)
StorageStat gets storage size information.
func (*Agent) UploadCreateOssTicket ¶ added in v0.3.2
func (a *Agent) UploadCreateOssTicket( dirId, name string, r io.ReadSeeker, ticket *UploadOssTicket, ) (err error)
UploadCreateOssTicket creates ticket to upload file through aliyun-oss-sdk. Use this method if you want to upload a file larger than 5G bytes.
To create ticket, r will be fully read to calculate SHA-1 and MD5 hash value. If you want to re-use r, try to seek it to beginning.
Example:
import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/deadblue/elevengo"
)
func main() {
filePath := "/file/to/upload"
var err error
file, err := os.Open(filePath)
if err != nil {
log.Fatalf("Open file failed: %s", err)
}
defer file.Close()
// Create 115 agent
agent := elevengo.Default()
if err = agent.CredentialImport(&elevengo.Credential{
UID: "", CID: "", SEID: "",
}); err != nil {
log.Fatalf("Login failed: %s", err)
}
// Prepare OSS upload ticket
ticket := &UploadOssTicket{}
if err = agent.UploadCreateOssTicket(
"dirId",
filepath.Base(file.Name()),
file,
ticket,
); err != nil {
log.Fatalf("Create OSS ticket failed: %s", err)
}
if ticket.Exist {
log.Printf("File has been fast-uploaded!")
return
}
// Create OSS client
oc, err := oss.New(
ticket.Client.Endpoint,
ticket.Client.AccessKeyId,
ticket.Client.AccessKeySecret,
oss.SecurityToken(ticket.Client.SecurityToken)
)
if err != nil {
log.Fatalf("Create OSS client failed: %s", err)
}
bucket, err := oc.Bucket(ticket.Bucket)
if err != nil {
log.Fatalf("Get OSS bucket failed: %s", err)
}
// Upload file in multipart.
err = bucket.UploadFile(
ticket.Object,
filePath,
100 * 1024 * 1024, // 100 Megabytes per part
oss.Callback(ticket.Callback),
oss.CallbackVar(ticket.CallbackVar),
)
// Until now (2023-01-29), there is a bug in aliyun-oss-go-sdk:
// When set Callback option, the response from CompleteMultipartUpload API
// is returned by callback host, which is not the standard XML. But SDK
// always tries to parse it as CompleteMultipartUploadResult, and returns
// `io.EOF` error, just ignore it!
if err != nil && err != io.EOF {
log.Fatalf("Upload file failed: %s", err)
} else {
log.Print("Upload done!")
}
}
func (*Agent) UploadCreateTicket ¶ added in v0.1.4
func (a *Agent) UploadCreateTicket( dirId, name string, r io.ReadSeeker, ticket *UploadTicket, ) (err error)
UploadCreateTicket creates a ticket which contains all required parameters to upload file/data to cloud, the ticket should be used in 1 hour.
To create ticket, r will be fully read to calculate SHA-1 and MD5 hash value. If you want to re-use r, try to seek it to beginning.
To upload a file larger than 5G bytes, use `UploadCreateOssTicket`.
Example ¶
agent := Default()
filename := "/path/to/file"
file, err := os.Open(filename)
if err != nil {
log.Fatalf("Open file failed: %s", err.Error())
}
ticket := &UploadTicket{}
if err = agent.UploadCreateTicket("dirId", path.Base(filename), file, ticket); err != nil {
log.Fatalf("Create upload ticket failed: %s", err.Error())
}
if ticket.Exist {
log.Printf("File already exists!")
return
}
// Make temp file to receive upload result
tmpFile, err := os.CreateTemp("", "curl-upload-*")
if err != nil {
log.Fatalf("Create temp file failed: %s", err)
}
defer func() {
_ = tmpFile.Close()
_ = os.Remove(tmpFile.Name())
}()
// Use "curl" to upload file
cmd := exec.Command("curl", ticket.Url,
"-o", tmpFile.Name(), "-#",
"-T", filename)
for name, value := range ticket.Header {
cmd.Args = append(cmd.Args, "-H", fmt.Sprintf("%s: %s", name, value))
}
if err = cmd.Run(); err != nil {
log.Fatalf("Upload failed: %s", err)
}
// Parse upload result
uploadFile := &File{}
if err = agent.UploadParseResult(tmpFile, uploadFile); err != nil {
log.Fatalf("Parse upload result failed: %s", err)
} else {
log.Printf("Uploaded file: %#v", file)
}
func (*Agent) UploadParseResult ¶ added in v0.1.4
UploadParseResult parses the raw upload response, and fills it to file.
func (*Agent) UploadSimply ¶ added in v0.2.1
func (a *Agent) UploadSimply(dirId, name string, size int64, r io.Reader) (fileId string, err error)
UploadSimply directly uploads small file/data (smaller than 200MB) to cloud.
func (*Agent) VideoGet ¶ added in v0.2.2
VideoGet gets information of a video file by its pickcode.
Example ¶
agent := Default()
// Get video information
info := Video{}
err := agent.VideoGet("pickcode", &info)
if err != nil {
log.Fatalf("Get video info failed: %s", err)
}
// Get HLS content
hlsData, err := agent.Get(info.PlayUrl)
if err != nil {
log.Fatalf("Get HLS content failed: %s", err.Error())
}
defer func() {
_ = hlsData.Close()
}()
// Play HLS through mpv
cmd := exec.Command("mpv", "-")
cmd.Stdin = hlsData
if err = cmd.Run(); err != nil {
log.Fatalf("Execute mpv error: %s", err)
}
type CaptchaSession ¶
type CaptchaSession struct {
// CAPTCHA image data.
CodeImage []byte
// CAPTCHA keys image data.
KeysImage []byte
// contains filtered or unexported fields
}
CaptchaSession holds CAPTCHA images and session information during a CAPTCHA process.
There are 4 Chinese characters on "CodeImage" and 10 Chinese characters on "KeysImage" (5 columns by 2 rows). User should find the 4 characters on "CodeImage" from "KeysImage", the indexes of these characters is the CAPTCHA code.
The index bases on 0, starts from left top corner, increases from left to right, then from top to bottom.
For example:
Assume the code image is
+---------------+ | J | F | C | H | +---------------+
and the keys image is
+-------------------+ | A | B | C | D | E | +-------------------+ | F | G | H | I | J | +-------------------+
Then the CAPTCHA code is "9527", you can call Agent.CaptchaSubmit() to submit it.
type Credential ¶ added in v0.1.3
Credential contains required information which upstream server uses to authenticate a signed-in user. In detail, three cookies are required: "UID", "CID", "SEID", caller can find them from browser cookie storage.
type DownloadTicket ¶
type DownloadTicket struct {
// Download URL.
Url string
// Request headers which SHOULD be sent with download URL.
Headers map[string]string
// File name.
FileName string
// File size in bytes.
FileSize int64
}
DownloadTicket contains all required information to download a file.
type ErrImportNeedCheck ¶ added in v0.4.2
type ErrImportNeedCheck struct {
// The sign key your should set to ImportTicket
SignKey string
// The sign range in format of "<start>-<end>" in bytes.
// You can directly use it in ImportCreateTicket.
SignRange string
}
func (*ErrImportNeedCheck) Error ¶ added in v0.4.2
func (e *ErrImportNeedCheck) Error() string
type File ¶
type File struct {
// Marks is the file a directory.
IsDirectory bool
// Unique identifier of the file on the cloud storage.
FileId string
// FileId of the parent directory.
ParentId string
// Base name of the file.
Name string
// Size in bytes of the file.
Size int64
// Identifier used for downloading or playing the file.
PickCode string
// SHA1 hash of file content, in HEX format.
Sha1 string
// Is file stared
Star bool
// File labels
Labels []*Label
// Last modified time
ModifiedTime time.Time
}
File describe a file or directory on cloud storage.
type FileInfo ¶
type FileInfo struct {
// Base name of the file.
Name string
// Identifier used for downloading or playing the file.
PickCode string
// SHA1 hash of file content, in HEX format.
Sha1 string
// Marks is file a directory.
IsDirectory bool
// Files count under this directory.
FileCount int
// Subdirectories count under this directory.
DirCount int
// Create time of the file.
CreateTime time.Time
// Last update time of the file.
UpdateTime time.Time
// Last access time of the file.
AccessTime time.Time
// Parent directory list.
Parents []*DirInfo
}
FileInfo is returned by FileStat(), contains basic information of a file.
type ImportTicket ¶ added in v0.2.1
type ImportTicket struct {
// File base name
FileName string
// File size in bytes
FileSize int64
// File SHA-1 hash, in upper-case HEX format
FileSha1 string
// Sign key from 115 server.
SignKey string
// SHA-1 hash value of a segment of the file, in upper-case HEX format
SignValue string
}
ImportTicket container reqiured fields to import(aka. quickly upload) a file to your 115 cloud storage.
type Iterator ¶ added in v0.2.1
type Iterator[T any] interface { // Next move cursor to next. Next() error // Index returns the index of current item, starts from 0. Index() int // Get gets current item. Get(*T) error // Count return the count of items. Count() int }
Iterator iterate items.
type Label ¶ added in v0.2.1
type Label struct {
Id string
Name string
Color LabelColor
}
type LabelColor ¶ added in v0.2.1
type LabelColor int
const ( LabelNoColor LabelColor = iota LabelRed LabelOrange LabelYellow LabelGreen LabelBlue LabelPurple LabelGray )
type OfflineAddResult ¶ added in v0.4.1
func (*OfflineAddResult) IsExist ¶ added in v0.4.1
func (r *OfflineAddResult) IsExist() bool
type OfflineClearFlag ¶
type OfflineClearFlag int
const ( OfflineClearDone OfflineClearFlag = iota OfflineClearAll OfflineClearFailed OfflineClearRunning OfflineClearDoneAndDelete OfflineClearAllAndDelete )
type OfflineTask ¶
type OfflineTask struct {
InfoHash string
Name string
Size int64
Status int
Percent float64
Url string
FileId string
}
OfflineTask describe an offline downloading task.
func (*OfflineTask) IsDone ¶ added in v0.2.1
func (t *OfflineTask) IsDone() bool
func (*OfflineTask) IsFailed ¶ added in v0.2.1
func (t *OfflineTask) IsFailed() bool
func (*OfflineTask) IsRunning ¶ added in v0.2.1
func (t *OfflineTask) IsRunning() bool
type QrcodeSession ¶
type QrcodeSession struct {
// The raw data of QRCode, caller should use third-party tools/libraries
// to convert it into QRCode matrix or image.
Content string
// contains filtered or unexported fields
}
QrcodeSession holds the information during a QRCode login process.
type QrcodeStatus ¶
type QrcodeStatus int
QrcodeStatus is returned by `Agent.QrcodeStatus()`. You can call `QrcodeStatus.IsXXX()` method to check the status, or directly check its value.
func (QrcodeStatus) IsAllowed ¶
func (s QrcodeStatus) IsAllowed() bool
func (QrcodeStatus) IsCanceled ¶
func (s QrcodeStatus) IsCanceled() bool
func (QrcodeStatus) IsScanned ¶
func (s QrcodeStatus) IsScanned() bool
func (QrcodeStatus) IsWaiting ¶
func (s QrcodeStatus) IsWaiting() bool
type Range ¶ added in v0.3.2
type Range struct {
// contains filtered or unexported fields
}
Range is used in Agent.GetRange().
func RangeFirst ¶ added in v0.3.2
RangeFirst makes a Range parameter to request the first `length` bytes.
func RangeLast ¶ added in v0.3.2
RangeLast makes a Range parameter to request the last `length` bytes.
func RangeMiddle ¶ added in v0.3.2
RangeMiddle makes a Range parameter to request content starts from `offset`, and has `length` bytes (at most).
You can pass a negative number in `length`, to request content starts from `offset` to the end.
type StorageFormatInfo ¶ added in v0.2.2
type StorageFormatInfo struct {
// Total size in bytes.
Size string
// Used size in bytes.
Used string
// Avail size in bytes.
Avail string
}
StorageFormatInfo describes storage space format usage.
type StorageInfo ¶
type StorageInfo struct {
// Total size in bytes.
Size int64
// Used size in bytes.
Used int64
// Available size in bytes.
Avail int64
// Human-readable total size.
FormatSize string
// Human-readable used size.
FormatUsed string
// Human-readable remain size.
FormatAvail string
}
StorageInfo describes storage space usage.
type UploadOssTicket ¶ added in v0.3.2
type UploadOssTicket struct {
// Expiration time
Expiration time.Time
// Is file already exists
Exist bool
// Client parameters
Client struct {
Endpoint string
AccessKeyId string
AccessKeySecret string
SecurityToken string
}
// Bucket name
Bucket string
// Object key
Object string
// Callback option
Callback string
// CallbackVar option
CallbackVar string
}
UploadOssTicket contains all required paramters to upload a file through aliyun-oss-sdk(https://github.com/aliyun/aliyun-oss-go-sdk).
type UploadTicket ¶
type UploadTicket struct {
// Expiration time
Expiration time.Time
// Is file exists
Exist bool
// Request method
Verb string
// Remote URL which will receive the file content.
Url string
// Request header
Header map[string]string
}
UploadTicket contains all required information to upload a file.
type Video ¶ added in v0.2.1
type Video struct {
// File ID
FileId string
// File Name
FileName string
// File size in bytes
FileSize int64
// Pick code for downloading
PickCode string
// SHA-1 hash
Sha1 string
// Video width
Width int
// Video height
Height int
// Video duration in seconds
Duration float64
// Play URL, usually is a m3u8 URL
PlayUrl string
}
Video contains information of a video file on cloud.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package plugin declares some interfaces that allow developer customizing elevengo agent.
|
Package plugin declares some interfaces that allow developer customizing elevengo agent. |