diff --git a/drivers/terabox/driver.go b/drivers/terabox/driver.go index 67eeed75..f163c898 100644 --- a/drivers/terabox/driver.go +++ b/drivers/terabox/driver.go @@ -6,15 +6,16 @@ import ( "crypto/md5" "encoding/hex" "fmt" - "github.com/alist-org/alist/v3/drivers/base" - "github.com/alist-org/alist/v3/pkg/utils" - log "github.com/sirupsen/logrus" "io" "math" stdpath "path" "strconv" "strings" + "github.com/alist-org/alist/v3/drivers/base" + "github.com/alist-org/alist/v3/pkg/utils" + log "github.com/sirupsen/logrus" + "github.com/alist-org/alist/v3/internal/driver" "github.com/alist-org/alist/v3/internal/model" ) @@ -119,9 +120,6 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt if err != nil { return err } - defer func() { - _ = tempFile.Close() - }() var Default int64 = 4 * 1024 * 1024 defaultByteData := make([]byte, Default) count := int(math.Ceil(float64(stream.GetSize()) / float64(Default))) @@ -168,6 +166,9 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt return err } log.Debugf("%+v", precreateResp) + if precreateResp.Errno != 0 { + return fmt.Errorf("[terabox] failed to precreate file, errno: %s", precreateResp.Errno) + } if precreateResp.ReturnType == 2 { return nil } diff --git a/drivers/terabox/meta.go b/drivers/terabox/meta.go index 797244b2..fd2a59e0 100644 --- a/drivers/terabox/meta.go +++ b/drivers/terabox/meta.go @@ -8,6 +8,7 @@ import ( type Addition struct { driver.RootPath Cookie string `json:"cookie" required:"true"` + JsToken string `json:"js_token" type:"string" required:"true"` DownloadAPI string `json:"download_api" type:"select" options:"official,crack" default:"official"` OrderBy string `json:"order_by" type:"select" options:"name,time,size" default:"name"` OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"` diff --git a/drivers/terabox/util.go b/drivers/terabox/util.go index 9b1f5fd5..825a2ee7 100644 --- a/drivers/terabox/util.go +++ b/drivers/terabox/util.go @@ -24,10 +24,13 @@ func (d *Terabox) request(furl string, method string, callback base.ReqCallback, "User-Agent": base.UserAgent, "X-Requested-With": "XMLHttpRequest", }) - req.SetQueryParam("app_id", "250528") - req.SetQueryParam("web", "1") - req.SetQueryParam("channel", "dubox") - req.SetQueryParam("clienttype", "0") + req.SetQueryParams(map[string]string{ + "app_id": "250528", + "web": "1", + "channel": "dubox", + "clienttype": "0", + "jsToken": d.JsToken, + }) if callback != nil { callback(req) }