pcsdownload

package
v0.0.0-...-3404eb1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPrintFormat 默认的下载进度输出格式
	DefaultPrintFormat = "\r[%s] ↓ %s/%s %s/s in %s, left %s ............"
	//DownloadSuffix 文件下载后缀
	DownloadSuffix = ".BaiduPCS-Go-downloading"
	//StrDownloadInitError 初始化下载发生错误
	StrDownloadInitError = "初始化下载发生错误"
	// StrDownloadFailed 下载文件失败
	StrDownloadFailed = "下载文件失败"
	// StrDownloadGetDlinkFailed 获取下载链接失败
	StrDownloadGetDlinkFailed = "获取下载链接失败"
	// StrDownloadChecksumFailed 检测文件有效性失败
	StrDownloadChecksumFailed = "检测文件有效性失败"
	// DefaultDownloadMaxRetry 默认下载失败最大重试次数
	DefaultDownloadMaxRetry = 3
)

Variables

View Source
var (
	// ErrDownloadNotSupportChecksum 文件不支持校验
	ErrDownloadNotSupportChecksum = errors.New("该文件不支持校验")
	// ErrDownloadChecksumFailed 文件校验失败
	ErrDownloadChecksumFailed = errors.New("该文件校验失败, 文件md5值与服务器记录的不匹配")
	// ErrDownloadFileBanned 违规文件
	ErrDownloadFileBanned = errors.New("该文件可能是违规文件, 不支持校验")
	// ErrDlinkNotFound 未取得下载链接
	ErrDlinkNotFound = errors.New("未取得下载链接")
	// ErrShareInfoNotFound 未在已分享列表中找到分享信息
	ErrShareInfoNotFound = errors.New("未在已分享列表中找到分享信息")
)

Functions

func BaiduPCSURLCheckFunc

func BaiduPCSURLCheckFunc(client *requester.HTTPClient, durl string) (contentLength int64, resp *http.Response, err error)

BaiduPCSURLCheckFunc downloader 首次检查下载地址要执行的函数

func CheckFileValid

func CheckFileValid(filePath string, fileInfo *baidupcs.FileDirectory) error

CheckFileValid 检测文件有效性

func FileExist

func FileExist(path string) bool

FileExist 检查文件是否存在, 只有当文件存在, 文件大小不为0或断点续传文件不存在时, 才判断为存在

func FixHTTPLinkURL

func FixHTTPLinkURL(linkURL *url.URL)

FixHTTPLinkURL 通过配置, 确定链接使用的协议(http,https)

func GetLocateDownloadLinks(pcs *baidupcs.BaiduPCS, pcspath string) (dlinks []*url.URL, err error)

func IsSkipMd5Checksum

func IsSkipMd5Checksum(size int64, md5Str string) bool

IsSkipMd5Checksum 是否忽略某些校验

Types

type DownloadMode

type DownloadMode int

DownloadMode 下载模式

const (
	DownloadModeLocate DownloadMode = iota
	DownloadModePCS
	DownloadModeStreaming
)

type DownloadStatistic

type DownloadStatistic struct {
	pcsfunctions.Statistic
}

type DownloadTaskUnit

type DownloadTaskUnit struct {
	Cfg                *downloader.Config
	PCS                *baidupcs.BaiduPCS
	ParentTaskExecutor *taskframework.TaskExecutor

	DownloadStatistic *DownloadStatistic // 下载统计

	// 可选项
	VerbosePrinter       *pcsverbose.PCSVerbose
	PrintFormat          string
	IsPrintStatus        bool // 是否输出各个下载线程的详细信息
	IsExecutedPermission bool // 下载成功后是否加上执行权限
	IsOverwrite          bool // 是否覆盖已存在的文件
	NoCheck              bool // 不校验文件

	DownloadMode DownloadMode // 下载模式

	PcsPath  string // 要下载的网盘文件路径
	SavePath string // 保存的路径
	// contains filtered or unexported fields
}

DownloadTaskUnit 下载的任务单元

func (*DownloadTaskUnit) OnComplete

func (dtu *DownloadTaskUnit) OnComplete(lastRunResult *taskframework.TaskUnitRunResult)

func (*DownloadTaskUnit) OnFailed

func (dtu *DownloadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult)

func (*DownloadTaskUnit) OnRetry

func (dtu *DownloadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResult)

func (*DownloadTaskUnit) OnSuccess

func (dtu *DownloadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult)

func (*DownloadTaskUnit) RetryWait

func (dtu *DownloadTaskUnit) RetryWait() time.Duration

func (*DownloadTaskUnit) Run

func (dtu *DownloadTaskUnit) Run() (result *taskframework.TaskUnitRunResult)

func (*DownloadTaskUnit) SetTaskInfo

func (dtu *DownloadTaskUnit) SetTaskInfo(info *taskframework.TaskInfo)

Jump to

Keyboard shortcuts

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