feat: auto extract archives (#1212)

This commit is contained in:
Matteo Pietro Dazzi authored and GitHub committed 2025-12-29 17:27:49 +08:00
1 parent 5515a1c48c
commit 0d5c4e8e7f
35 files changed
+950 -40

No files matched your search

+20 -3
View File
@@ -2,13 +2,14 @@ package base
import (
"fmt"
"github.com/GopeedLab/gopeed/pkg/util"
"github.com/mattn/go-ieproxy"
"golang.org/x/exp/slices"
"net/http"
"net/url"
"sync"
"time"
"github.com/GopeedLab/gopeed/pkg/util"
"github.com/mattn/go-ieproxy"
"golang.org/x/exp/slices"
)
// Request download request
@@ -183,6 +184,7 @@ type DownloaderStoreConfig struct {
Extra map[string]any `json:"extra"`
Proxy *DownloaderProxyConfig `json:"proxy"`
Webhook *WebhookConfig `json:"webhook"` // Webhook is the webhook configuration
Archive *ArchiveConfig `json:"archive"` // Archive is the archive extraction configuration
}
func (cfg *DownloaderStoreConfig) Init() *DownloaderStoreConfig {
@@ -198,6 +200,12 @@ func (cfg *DownloaderStoreConfig) Init() *DownloaderStoreConfig {
if cfg.Webhook == nil {
cfg.Webhook = &WebhookConfig{}
}
if cfg.Archive == nil {
cfg.Archive = &ArchiveConfig{
AutoExtract: false,
DeleteAfterExtract: false,
}
}
return cfg
}
@@ -223,6 +231,9 @@ func (cfg *DownloaderStoreConfig) Merge(beforeCfg *DownloaderStoreConfig) *Downl
if cfg.Webhook == nil {
cfg.Webhook = beforeCfg.Webhook
}
if cfg.Archive == nil {
cfg.Archive = beforeCfg.Archive
}
return cfg
}
@@ -232,6 +243,12 @@ type WebhookConfig struct {
URLs []string `json:"urls"` // URLs is the list of webhook URLs
}
// ArchiveConfig is the archive extraction configuration
type ArchiveConfig struct {
AutoExtract bool `json:"autoExtract"` // AutoExtract enables automatic extraction of archives after download
DeleteAfterExtract bool `json:"deleteAfterExtract"` // DeleteAfterExtract deletes the archive after successful extraction
}
type DownloaderProxyConfig struct {
Enable bool `json:"enable"`
// System is the flag that use system proxy