-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive.api.go
More file actions
312 lines (271 loc) · 8.17 KB
/
Copy patharchive.api.go
File metadata and controls
312 lines (271 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// Code generated by protoc-gen-go_api(github.com/dev-openapi/protoc-gen-go_api version=v1.0.5). DO NOT EDIT.
// source: bilibili-webapp/archive.proto
package bilibili_webapp
import (
context "context"
fmt "fmt"
io "io"
json "encoding/json"
bytes "bytes"
http "net/http"
strings "strings"
url "net/url"
multipart "mime/multipart"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = context.Background
var _ = http.NewRequest
var _ = io.Copy
var _ = bytes.Compare
var _ = json.Marshal
var _ = strings.Compare
var _ = fmt.Errorf
var _ = url.Parse
var _ = multipart.ErrMessageTooLarge
// Client API for Archive service
type ArchiveService interface {
// GetArchive 查询单一视频稿件详情 https://openhome.bilibili.com/doc/4/d9554788-dcef-f139-6217-b487d41c3826
GetArchive(ctx context.Context, in *GetArchiveReq, opts ...Option) (*GetArchiveRes, error)
// BatchGetArchive 查询用户视频稿件列表 https://openhome.bilibili.com/doc/4/a24030b7-6b8f-b36c-32d8-a4aae67fcc35
BatchGetArchive(ctx context.Context, in *BatchGetArchiveReq, opts ...Option) (*BatchGetArchiveRes, error)
// EditArchive 视频稿件编辑 https://openhome.bilibili.com/doc/4/ddfbe54d-b4ab-340e-c698-933b9a3c619c
EditArchive(ctx context.Context, in *EditArchiveReq, opts ...Option) (*EditArchiveRes, error)
// DeleteArchive 视频稿件删除 https://openhome.bilibili.com/doc/4/23d78390-4119-1e5f-2bbe-b45bd5cecdb0
DeleteArchive(ctx context.Context, in *DeleteArchiveReq, opts ...Option) (*DeleteArchiveRes, error)
// GetArchiveTypeList 获取分区
GetArchiveTypeList(ctx context.Context, in *GetArchiveTypeListReq, opts ...Option) (*GetArchiveTypeListRes, error)
// AddArchive 视频稿件提交
AddArchive(ctx context.Context, in *AddArchiveReq, opts ...Option) (*AddArchiveRes, error)
}
type archiveService struct {
// opts
opts *Options
}
func NewArchiveService(opts ...Option) ArchiveService {
opt := newOptions(opts...)
if len(opt.addr) <= 0 {
opt.addr = "https://member.bilibili.com"
}
return &archiveService {
opts: opt,
}
}
func (c *archiveService) GetArchive(ctx context.Context, in *GetArchiveReq, opts ...Option) (*GetArchiveRes, error) {
var res GetArchiveRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/view", opt.addr)
// body
req, err := http.NewRequest("GET", rawURL, nil)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
if in.GetResourceId() != "" {
params.Add("resource_id", fmt.Sprintf("%v", in.GetResourceId()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *archiveService) BatchGetArchive(ctx context.Context, in *BatchGetArchiveReq, opts ...Option) (*BatchGetArchiveRes, error) {
var res BatchGetArchiveRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/viewlist", opt.addr)
// body
req, err := http.NewRequest("GET", rawURL, nil)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
if in.GetPn() != 0 {
params.Add("pn", fmt.Sprintf("%v", in.GetPn()))
}
if in.GetPs() != 0 {
params.Add("ps", fmt.Sprintf("%v", in.GetPs()))
}
if in.GetStatus() != "" {
params.Add("status", fmt.Sprintf("%v", in.GetStatus()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *archiveService) EditArchive(ctx context.Context, in *EditArchiveReq, opts ...Option) (*EditArchiveRes, error) {
var res EditArchiveRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/edit", opt.addr)
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *archiveService) DeleteArchive(ctx context.Context, in *DeleteArchiveReq, opts ...Option) (*DeleteArchiveRes, error) {
var res DeleteArchiveRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/delete", opt.addr)
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *archiveService) GetArchiveTypeList(ctx context.Context, in *GetArchiveTypeListReq, opts ...Option) (*GetArchiveTypeListRes, error) {
var res GetArchiveTypeListRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/type/list", opt.addr)
// body
req, err := http.NewRequest("GET", rawURL, nil)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *archiveService) AddArchive(ctx context.Context, in *AddArchiveReq, opts ...Option) (*AddArchiveRes, error) {
var res AddArchiveRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/arcopen/fn/archive/add-by-utoken", opt.addr)
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
params := req.URL.Query()
if in.GetAccessToken() != "" {
params.Add("access_token", fmt.Sprintf("%v", in.GetAccessToken()))
}
if in.GetClientId() != "" {
params.Add("client_id", fmt.Sprintf("%v", in.GetClientId()))
}
if in.GetUploadToken() != "" {
params.Add("upload_token", fmt.Sprintf("%v", in.GetUploadToken()))
}
req.URL.RawQuery = params.Encode()
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}