66 "encoding/base64"
77 "errors"
88 "fmt"
9+ "html"
910 "io"
1011 "net/http"
1112 "strconv"
@@ -50,20 +51,29 @@ func (d *QuarkOrUC) request(pathname string, method string, callback base.ReqCal
5051 d .Cookie = cookie .SetStr (d .Cookie , "__puus" , __puus .Value )
5152 op .MustSaveDriverStorage (d )
5253 }
54+ if d .UseTransCodingAddress && d .config .Name == "Quark" {
55+ __pus := cookie .GetCookie (res .Cookies (), "__pus" )
56+ if __pus != nil {
57+ d .Cookie = cookie .SetStr (d .Cookie , "__pus" , __pus .Value )
58+ op .MustSaveDriverStorage (d )
59+ }
60+ }
5361 if e .Status >= 400 || e .Code != 0 {
5462 return nil , errors .New (e .Message )
5563 }
5664 return res .Body (), nil
5765}
5866
59- func (d * QuarkOrUC ) GetFiles (parent string ) ([]File , error ) {
60- files := make ([]File , 0 )
67+ func (d * QuarkOrUC ) GetFiles (parent string ) ([]model. Obj , error ) {
68+ files := make ([]model. Obj , 0 )
6169 page := 1
6270 size := 100
6371 query := map [string ]string {
64- "pdir_fid" : parent ,
65- "_size" : strconv .Itoa (size ),
66- "_fetch_total" : "1" ,
72+ "pdir_fid" : parent ,
73+ "_size" : strconv .Itoa (size ),
74+ "_fetch_total" : "1" ,
75+ "fetch_all_file" : "1" ,
76+ "fetch_risk_file_name" : "1" ,
6777 }
6878 if d .OrderBy != "none" {
6979 query ["_sort" ] = "file_type:asc," + d .OrderBy + ":" + d .OrderDirection
@@ -77,7 +87,16 @@ func (d *QuarkOrUC) GetFiles(parent string) ([]File, error) {
7787 if err != nil {
7888 return nil , err
7989 }
80- files = append (files , resp .Data .List ... )
90+ for _ , file := range resp .Data .List {
91+ file .FileName = html .UnescapeString (file .FileName )
92+ if d .OnlyListVideoFile {
93+ if file .IsDir () || file .Category == 1 {
94+ files = append (files , & file )
95+ }
96+ } else {
97+ files = append (files , & file )
98+ }
99+ }
81100 if page * size >= resp .Metadata .Total {
82101 break
83102 }
@@ -86,6 +105,62 @@ func (d *QuarkOrUC) GetFiles(parent string) ([]File, error) {
86105 return files , nil
87106}
88107
108+ func (d * QuarkOrUC ) getDownloadLink (file model.Obj ) (* model.Link , error ) {
109+ data := base.Json {
110+ "fids" : []string {file .GetID ()},
111+ }
112+ var resp DownResp
113+ ua := d .conf .ua
114+ _ , err := d .request ("/file/download" , http .MethodPost , func (req * resty.Request ) {
115+ req .SetHeader ("User-Agent" , ua ).
116+ SetBody (data )
117+ }, & resp )
118+ if err != nil {
119+ return nil , err
120+ }
121+
122+ return & model.Link {
123+ URL : resp .Data [0 ].DownloadUrl ,
124+ Header : http.Header {
125+ "Cookie" : []string {d .Cookie },
126+ "Referer" : []string {d .conf .referer },
127+ "User-Agent" : []string {ua },
128+ },
129+ Concurrency : 3 ,
130+ PartSize : 10 * utils .MB ,
131+ }, nil
132+ }
133+
134+ func (d * QuarkOrUC ) getTranscodingLink (file model.Obj ) (* model.Link , error ) {
135+ data := base.Json {
136+ "fid" : file .GetID (),
137+ "resolutions" : "low,normal,high,super,2k,4k" ,
138+ "supports" : "fmp4_av,m3u8,dolby_vision" ,
139+ }
140+ var resp TranscodingResp
141+ ua := d .conf .ua
142+
143+ _ , err := d .request ("/file/v2/play/project" , http .MethodPost , func (req * resty.Request ) {
144+ req .SetHeader ("User-Agent" , ua ).
145+ SetBody (data )
146+ }, & resp )
147+ if err != nil {
148+ return nil , err
149+ }
150+
151+ for _ , info := range resp .Data .VideoList {
152+ if info .VideoInfo .URL != "" {
153+ return & model.Link {
154+ URL : info .VideoInfo .URL ,
155+ Concurrency : 3 ,
156+ PartSize : 10 * utils .MB ,
157+ }, nil
158+ }
159+ }
160+
161+ return nil , errors .New ("no link found" )
162+ }
163+
89164func (d * QuarkOrUC ) upPre (file model.FileStreamer , parentId string ) (UpPreResp , error ) {
90165 now := time .Now ()
91166 data := base.Json {
0 commit comments