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:
Krau
2025-08-21 23:48:17 +08:00
committed by GitHub
parent 79386bdd7d
commit 302db2fe75
47 changed files with 1348 additions and 47 deletions

View File

@@ -0,0 +1,56 @@
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
}