31 lines
883 B
Go
31 lines
883 B
Go
package download
|
|
|
|
import "context"
|
|
|
|
type DownloadProgress struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
Progress float64 `json:"progress"`
|
|
Speed int64 `json:"speed"`
|
|
ETA int `json:"eta"`
|
|
Size int64 `json:"size"`
|
|
}
|
|
|
|
type CompletedDownload struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
OutputPath string `json:"output_path"`
|
|
Size int64 `json:"size"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type DownloadClient interface {
|
|
Add(ctx context.Context, url string, category string) (string, error)
|
|
GetProgress(ctx context.Context, id string) (*DownloadProgress, error)
|
|
GetCompleted(ctx context.Context) ([]CompletedDownload, error)
|
|
Remove(ctx context.Context, id string) error
|
|
Pause(ctx context.Context, id string) error
|
|
Resume(ctx context.Context, id string) error
|
|
}
|