mirror of https://github.com/Xhofe/alist
wip: use items in offline_download
parent
0acb2d6073
commit
0380d7fff9
|
@ -5,6 +5,8 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
_ "github.com/alist-org/alist/v3/drivers"
|
||||
_ "github.com/alist-org/alist/v3/internal/offline_download"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
_ "github.com/alist-org/alist/v3/drivers"
|
||||
"github.com/alist-org/alist/v3/internal/bootstrap"
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/offline_download/tool"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
"github.com/alist-org/alist/v3/pkg/utils/random"
|
||||
|
@ -168,6 +169,7 @@ func InitialSettings() []model.SettingItem {
|
|||
{Key: conf.QbittorrentUrl, Value: "http://admin:adminadmin@localhost:8080/", Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE},
|
||||
{Key: conf.QbittorrentSeedtime, Value: "0", Type: conf.TypeNumber, Group: model.SINGLE, Flag: model.PRIVATE},
|
||||
}
|
||||
initialSettingItems = append(initialSettingItems, tool.Tools.Items()...)
|
||||
if flags.Dev {
|
||||
initialSettingItems = append(initialSettingItems, []model.SettingItem{
|
||||
{Key: "test_deprecated", Value: "test_value", Type: conf.TypeString, Flag: model.DEPRECATED},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package offline_download
|
||||
|
||||
import (
|
||||
_ "github.com/alist-org/alist/v3/internal/offline_download/aria2"
|
||||
)
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/offline_download"
|
||||
"github.com/alist-org/alist/v3/internal/offline_download/tool"
|
||||
"github.com/alist-org/alist/v3/internal/setting"
|
||||
"github.com/alist-org/alist/v3/pkg/aria2/rpc"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -50,7 +50,7 @@ func (a *Aria2) IsReady() bool {
|
|||
return a.client != nil
|
||||
}
|
||||
|
||||
func (a *Aria2) AddURI(args *offline_download.AddUriArgs) (string, error) {
|
||||
func (a *Aria2) AddURI(args *tool.AddUriArgs) (string, error) {
|
||||
options := map[string]interface{}{
|
||||
"dir": args.TempDir,
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func (a *Aria2) Remove(tid string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (a *Aria2) Status(tid string) (*offline_download.Status, error) {
|
||||
func (a *Aria2) Status(tid string) (*tool.Status, error) {
|
||||
info, err := a.client.TellStatus(tid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -79,7 +79,7 @@ func (a *Aria2) Status(tid string) (*offline_download.Status, error) {
|
|||
if err != nil {
|
||||
downloaded = 0
|
||||
}
|
||||
s := &offline_download.Status{
|
||||
s := &tool.Status{
|
||||
Completed: info.Status == "complete",
|
||||
Err: err,
|
||||
}
|
||||
|
@ -109,8 +109,12 @@ func (a *Aria2) Status(tid string) (*offline_download.Status, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (a *Aria2) GetFile(tid string) *offline_download.File {
|
||||
func (a *Aria2) GetFile(tid string) *tool.File {
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ offline_download.Tool = (*Aria2)(nil)
|
||||
var _ tool.Tool = (*Aria2)(nil)
|
||||
|
||||
func init() {
|
||||
tool.Tools.Add("aria2", &Aria2{})
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package offline_download
|
||||
package tool
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,13 +1,13 @@
|
|||
package offline_download_test
|
||||
package tool_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/offline_download"
|
||||
"github.com/alist-org/alist/v3/internal/offline_download/tool"
|
||||
)
|
||||
|
||||
func TestGetFiles(t *testing.T) {
|
||||
files, err := offline_download.GetFiles("..")
|
||||
files, err := tool.GetFiles("..")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package offline_download
|
||||
package tool
|
||||
|
||||
import (
|
||||
"io"
|
|
@ -1,4 +1,4 @@
|
|||
package offline_download
|
||||
package tool
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,8 +1,9 @@
|
|||
package offline_download
|
||||
package tool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/task"
|
||||
)
|
||||
|
||||
|
@ -31,3 +32,11 @@ func (t ToolsManager) Names() []string {
|
|||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func (t ToolsManager) Items() []model.SettingItem {
|
||||
var items []model.SettingItem
|
||||
for _, tool := range t {
|
||||
items = append(items, tool.Items()...)
|
||||
}
|
||||
return items
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package offline_download
|
||||
package tool
|
||||
|
||||
import (
|
||||
"os"
|
Loading…
Reference in New Issue