@@ -3,17 +3,18 @@ package doubao
33import (
44 "context"
55 "errors"
6+ "net/http"
7+ "strconv"
8+ "strings"
9+ "time"
10+
611 "github.com/alist-org/alist/v3/drivers/base"
712 "github.com/alist-org/alist/v3/internal/driver"
813 "github.com/alist-org/alist/v3/internal/errs"
914 "github.com/alist-org/alist/v3/internal/model"
1015 "github.com/alist-org/alist/v3/pkg/utils"
1116 "github.com/go-resty/resty/v2"
1217 "github.com/google/uuid"
13- "net/http"
14- "strconv"
15- "strings"
16- "time"
1718)
1819
1920type Doubao struct {
@@ -97,33 +98,50 @@ func (d *Doubao) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
9798 var downloadUrl string
9899
99100 if u , ok := file .(* Object ); ok {
100- switch u . NodeType {
101- case VideoType , AudioType :
102- var r GetVideoFileUrlResp
103- _ , err := d .request ("/samantha/media/get_play_info " , http .MethodPost , func (req * resty.Request ) {
101+ switch d . DownloadApi {
102+ case "get_download_info" :
103+ var r GetDownloadInfoResp
104+ _ , err := d .request ("/samantha/aispace/get_download_info " , http .MethodPost , func (req * resty.Request ) {
104105 req .SetBody (base.Json {
105- "key" : u .Key ,
106- "node_id" : file .GetID (),
106+ "requests" : []base.Json {{"node_id" : file .GetID ()}},
107107 })
108108 }, & r )
109109 if err != nil {
110110 return nil , err
111111 }
112112
113- downloadUrl = r .Data .OriginalMediaInfo .MainURL
114- default :
115- var r GetFileUrlResp
116- _ , err := d .request ("/alice/message/get_file_url" , http .MethodPost , func (req * resty.Request ) {
117- req .SetBody (base.Json {
118- "uris" : []string {u .Key },
119- "type" : FileNodeType [u .NodeType ],
120- })
121- }, & r )
122- if err != nil {
123- return nil , err
113+ downloadUrl = r .Data .DownloadInfos [0 ].MainURL
114+ case "get_file_url" :
115+ switch u .NodeType {
116+ case VideoType , AudioType :
117+ var r GetVideoFileUrlResp
118+ _ , err := d .request ("/samantha/media/get_play_info" , http .MethodPost , func (req * resty.Request ) {
119+ req .SetBody (base.Json {
120+ "key" : u .Key ,
121+ "node_id" : file .GetID (),
122+ })
123+ }, & r )
124+ if err != nil {
125+ return nil , err
126+ }
127+
128+ downloadUrl = r .Data .OriginalMediaInfo .MainURL
129+ default :
130+ var r GetFileUrlResp
131+ _ , err := d .request ("/alice/message/get_file_url" , http .MethodPost , func (req * resty.Request ) {
132+ req .SetBody (base.Json {
133+ "uris" : []string {u .Key },
134+ "type" : FileNodeType [u .NodeType ],
135+ })
136+ }, & r )
137+ if err != nil {
138+ return nil , err
139+ }
140+
141+ downloadUrl = r .Data .FileUrls [0 ].MainURL
124142 }
125-
126- downloadUrl = r . Data . FileUrls [ 0 ]. MainURL
143+ default :
144+ return nil , errs . NotImplement
127145 }
128146
129147 // 生成标准的Content-Disposition
0 commit comments