- Implemented a new task type for handling direct links downloads. - Added command handler for downloading multiple links via /dl command. - Introduced progress tracking for direct link downloads. - Enhanced filename parsing to support various encoding scenarios. - Updated enums to include direct links as a task type. - Refactored existing task structures to accommodate new functionality. - Improved error handling and logging throughout the download process.
57 lines
968 B
Go
57 lines
968 B
Go
package batchtfile
|
|
|
|
type TaskElementInfo interface {
|
|
FileName() string
|
|
FileSize() int64
|
|
StoragePath() string
|
|
StorageName() string
|
|
}
|
|
|
|
func (e *TaskElement) FileName() string {
|
|
return e.File.Name()
|
|
}
|
|
|
|
func (e *TaskElement) FileSize() int64 {
|
|
return e.File.Size()
|
|
}
|
|
|
|
func (e *TaskElement) StoragePath() string {
|
|
return e.Path
|
|
}
|
|
|
|
func (e *TaskElement) StorageName() string {
|
|
return e.Storage.Name()
|
|
}
|
|
|
|
type TaskInfo interface {
|
|
TaskID() string
|
|
TotalSize() int64
|
|
Downloaded() int64
|
|
Count() int
|
|
Processing() []TaskElementInfo
|
|
}
|
|
|
|
func (t *Task) TaskID() string {
|
|
return t.ID
|
|
}
|
|
|
|
func (t *Task) TotalSize() int64 {
|
|
return t.totalSize
|
|
}
|
|
|
|
func (t *Task) Downloaded() int64 {
|
|
return t.downloaded.Load()
|
|
}
|
|
|
|
func (t *Task) Count() int {
|
|
return len(t.elems)
|
|
}
|
|
|
|
func (t *Task) Processing() []TaskElementInfo {
|
|
processing := make([]TaskElementInfo, 0, len(t.elems))
|
|
for _, elem := range t.processing {
|
|
processing = append(processing, elem)
|
|
}
|
|
return processing
|
|
}
|