@@ -22,29 +22,31 @@ import (
22
22
log "github.com/sirupsen/logrus"
23
23
)
24
24
25
- type Quark struct {
25
+ type QuarkOrUC struct {
26
26
model.Storage
27
27
Addition
28
+ config driver.Config
29
+ conf Conf
28
30
}
29
31
30
- func (d * Quark ) Config () driver.Config {
31
- return config
32
+ func (d * QuarkOrUC ) Config () driver.Config {
33
+ return d . config
32
34
}
33
35
34
- func (d * Quark ) GetAddition () driver.Additional {
36
+ func (d * QuarkOrUC ) GetAddition () driver.Additional {
35
37
return & d .Addition
36
38
}
37
39
38
- func (d * Quark ) Init (ctx context.Context ) error {
40
+ func (d * QuarkOrUC ) Init (ctx context.Context ) error {
39
41
_ , err := d .request ("/config" , http .MethodGet , nil , nil )
40
42
return err
41
43
}
42
44
43
- func (d * Quark ) Drop (ctx context.Context ) error {
45
+ func (d * QuarkOrUC ) Drop (ctx context.Context ) error {
44
46
return nil
45
47
}
46
48
47
- func (d * Quark ) List (ctx context.Context , dir model.Obj , args model.ListArgs ) ([]model.Obj , error ) {
49
+ func (d * QuarkOrUC ) List (ctx context.Context , dir model.Obj , args model.ListArgs ) ([]model.Obj , error ) {
48
50
files , err := d .GetFiles (dir .GetID ())
49
51
if err != nil {
50
52
return nil , err
@@ -54,12 +56,12 @@ func (d *Quark) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
54
56
})
55
57
}
56
58
57
- func (d * Quark ) Link (ctx context.Context , file model.Obj , args model.LinkArgs ) (* model.Link , error ) {
59
+ func (d * QuarkOrUC ) Link (ctx context.Context , file model.Obj , args model.LinkArgs ) (* model.Link , error ) {
58
60
data := base.Json {
59
61
"fids" : []string {file .GetID ()},
60
62
}
61
63
var resp DownResp
62
- ua := "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
64
+ ua := d . conf . ua
63
65
_ , err := d .request ("/file/download" , http .MethodPost , func (req * resty.Request ) {
64
66
req .SetHeader ("User-Agent" , ua ).
65
67
SetBody (data )
@@ -103,7 +105,7 @@ func (d *Quark) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
103
105
req .Header .Set ("Range" , _range )
104
106
req .Header .Set ("User-Agent" , ua )
105
107
req .Header .Set ("Cookie" , d .Cookie )
106
- req .Header .Set ("Referer" , "https://pan.quark.cn" )
108
+ req .Header .Set ("Referer" , d . conf . referer )
107
109
resp , err := base .HttpClient .Do (req )
108
110
if err != nil {
109
111
return err
@@ -125,7 +127,7 @@ func (d *Quark) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
125
127
return & link , nil
126
128
}
127
129
128
- func (d * Quark ) MakeDir (ctx context.Context , parentDir model.Obj , dirName string ) error {
130
+ func (d * QuarkOrUC ) MakeDir (ctx context.Context , parentDir model.Obj , dirName string ) error {
129
131
data := base.Json {
130
132
"dir_init_lock" : false ,
131
133
"dir_path" : "" ,
@@ -141,7 +143,7 @@ func (d *Quark) MakeDir(ctx context.Context, parentDir model.Obj, dirName string
141
143
return err
142
144
}
143
145
144
- func (d * Quark ) Move (ctx context.Context , srcObj , dstDir model.Obj ) error {
146
+ func (d * QuarkOrUC ) Move (ctx context.Context , srcObj , dstDir model.Obj ) error {
145
147
data := base.Json {
146
148
"action_type" : 1 ,
147
149
"exclude_fids" : []string {},
@@ -154,7 +156,7 @@ func (d *Quark) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
154
156
return err
155
157
}
156
158
157
- func (d * Quark ) Rename (ctx context.Context , srcObj model.Obj , newName string ) error {
159
+ func (d * QuarkOrUC ) Rename (ctx context.Context , srcObj model.Obj , newName string ) error {
158
160
data := base.Json {
159
161
"fid" : srcObj .GetID (),
160
162
"file_name" : newName ,
@@ -165,11 +167,11 @@ func (d *Quark) Rename(ctx context.Context, srcObj model.Obj, newName string) er
165
167
return err
166
168
}
167
169
168
- func (d * Quark ) Copy (ctx context.Context , srcObj , dstDir model.Obj ) error {
170
+ func (d * QuarkOrUC ) Copy (ctx context.Context , srcObj , dstDir model.Obj ) error {
169
171
return errs .NotSupport
170
172
}
171
173
172
- func (d * Quark ) Remove (ctx context.Context , obj model.Obj ) error {
174
+ func (d * QuarkOrUC ) Remove (ctx context.Context , obj model.Obj ) error {
173
175
data := base.Json {
174
176
"action_type" : 1 ,
175
177
"exclude_fids" : []string {},
@@ -181,7 +183,7 @@ func (d *Quark) Remove(ctx context.Context, obj model.Obj) error {
181
183
return err
182
184
}
183
185
184
- func (d * Quark ) Put (ctx context.Context , dstDir model.Obj , stream model.FileStreamer , up driver.UpdateProgress ) error {
186
+ func (d * QuarkOrUC ) Put (ctx context.Context , dstDir model.Obj , stream model.FileStreamer , up driver.UpdateProgress ) error {
185
187
tempFile , err := utils .CreateTempFile (stream .GetReadCloser ())
186
188
if err != nil {
187
189
return err
@@ -266,4 +268,4 @@ func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStre
266
268
return d .upFinish (pre )
267
269
}
268
270
269
- var _ driver.Driver = (* Quark )(nil )
271
+ var _ driver.Driver = (* QuarkOrUC )(nil )
0 commit comments