mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 22:39:41 +08:00
feat: parse url with js plugins support (#96)
* feat: WIP. add parser functionality and text message handling * fix: use json to marshal js result * feat: add metadata handling and version validation for jsParser * refactor: rename parser package to parsers and restructure parser handling * refactor: core code struct and impl parse task handle * feat: impl parsed download * fix: seek cache file when processing tph picture * feat: implement parsed task handling and progress tracking * feat: enhance task processing with concurrency control and progress tracking * feat: add resource ID generation and improve resource processing handling * feat: improve message formatting in parsed text and progress completion * feat: add example js plugin * feat: implement Twitter parser * fix: twitter parse video json decode error * feat: impl stream mode for parse task
This commit is contained in:
56
core/tasks/telegraph/task.go
Normal file
56
core/tasks/telegraph/task.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package telegraph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/tasktype"
|
||||
"github.com/krau/SaveAny-Bot/pkg/telegraph"
|
||||
"github.com/krau/SaveAny-Bot/storage"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID string
|
||||
Ctx context.Context
|
||||
PhPath string
|
||||
Pics []string
|
||||
Stor storage.Storage
|
||||
StorPath string
|
||||
client *telegraph.Client
|
||||
progress ProgressTracker
|
||||
|
||||
cannotStream bool
|
||||
totalpics int
|
||||
downloaded atomic.Int64
|
||||
}
|
||||
|
||||
func (t *Task) Type() tasktype.TaskType {
|
||||
return tasktype.TaskTypeTphpics
|
||||
}
|
||||
|
||||
func NewTask(
|
||||
id string,
|
||||
ctx context.Context,
|
||||
phPath string,
|
||||
pics []string,
|
||||
stor storage.Storage,
|
||||
storPath string,
|
||||
client *telegraph.Client,
|
||||
progress ProgressTracker,
|
||||
) *Task {
|
||||
_, cannotStream := stor.(storage.StorageCannotStream)
|
||||
telegraph := &Task{
|
||||
ID: id,
|
||||
Ctx: ctx,
|
||||
PhPath: phPath,
|
||||
Pics: pics,
|
||||
Stor: stor,
|
||||
StorPath: storPath,
|
||||
client: client,
|
||||
progress: progress,
|
||||
cannotStream: cannotStream,
|
||||
totalpics: len(pics),
|
||||
downloaded: atomic.Int64{},
|
||||
}
|
||||
return telegraph
|
||||
}
|
||||
Reference in New Issue
Block a user