mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-03 14:40:52 +08:00
feat: add direct links download functionality
- 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.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
package tasktype
|
||||
|
||||
//go:generate go-enum --values --names --flag --nocase
|
||||
// ENUM(tgfiles,tphpics,parseditem)
|
||||
// ENUM(tgfiles,tphpics,parseditem,directlinks)
|
||||
type TaskType string
|
||||
|
||||
@@ -18,6 +18,8 @@ const (
|
||||
TaskTypeTphpics TaskType = "tphpics"
|
||||
// TaskTypeParseditem is a TaskType of type parseditem.
|
||||
TaskTypeParseditem TaskType = "parseditem"
|
||||
// TaskTypeDirectlinks is a TaskType of type directlinks.
|
||||
TaskTypeDirectlinks TaskType = "directlinks"
|
||||
)
|
||||
|
||||
var ErrInvalidTaskType = fmt.Errorf("not a valid TaskType, try [%s]", strings.Join(_TaskTypeNames, ", "))
|
||||
@@ -26,6 +28,7 @@ var _TaskTypeNames = []string{
|
||||
string(TaskTypeTgfiles),
|
||||
string(TaskTypeTphpics),
|
||||
string(TaskTypeParseditem),
|
||||
string(TaskTypeDirectlinks),
|
||||
}
|
||||
|
||||
// TaskTypeNames returns a list of possible string values of TaskType.
|
||||
@@ -41,6 +44,7 @@ func TaskTypeValues() []TaskType {
|
||||
TaskTypeTgfiles,
|
||||
TaskTypeTphpics,
|
||||
TaskTypeParseditem,
|
||||
TaskTypeDirectlinks,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +61,10 @@ func (x TaskType) IsValid() bool {
|
||||
}
|
||||
|
||||
var _TaskTypeValue = map[string]TaskType{
|
||||
"tgfiles": TaskTypeTgfiles,
|
||||
"tphpics": TaskTypeTphpics,
|
||||
"parseditem": TaskTypeParseditem,
|
||||
"tgfiles": TaskTypeTgfiles,
|
||||
"tphpics": TaskTypeTphpics,
|
||||
"parseditem": TaskTypeParseditem,
|
||||
"directlinks": TaskTypeDirectlinks,
|
||||
}
|
||||
|
||||
// ParseTaskType attempts to convert a string to a TaskType.
|
||||
|
||||
@@ -55,7 +55,7 @@ func (r *Resource) ID() string {
|
||||
h.Write([]byte(r.Filename))
|
||||
h.Write([]byte(r.MimeType))
|
||||
h.Write([]byte(r.Extension))
|
||||
h.Write([]byte(fmt.Sprintf("%d", r.Size)))
|
||||
fmt.Fprintf(h, "%d", r.Size)
|
||||
|
||||
for k, v := range r.Hash {
|
||||
h.Write([]byte(k))
|
||||
|
||||
@@ -43,6 +43,8 @@ type Add struct {
|
||||
TphDirPath string // unescaped telegraph.Page.Path
|
||||
// parseditem
|
||||
ParsedItem *parser.Item
|
||||
// directlinks
|
||||
DirectLinks []string
|
||||
}
|
||||
|
||||
type SetDefaultStorage struct {
|
||||
|
||||
Reference in New Issue
Block a user