-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrecorder.d.ts
258 lines (232 loc) · 7.02 KB
/
recorder.d.ts
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
/**
* 录播姬的事件
*/
declare var recorderEvents: {
/**
* 按下测试按钮。
*/
onTest?: (alert: (message?: any) => void) => void;
/**
* 过滤弹幕消息。
* 写入 XML 文件之前会调用,如果返回 false 就不会写入。
*/
onDanmaku?: (json: string) => boolean;
/**
* 获取直播流地址,每次尝试开始录播调用一次。
* 如果返回了 null 会使用录播姬默认逻辑获取直播流地址。
* 如果返回了 string 则无条件使用脚本给的地址。
*/
onFetchStreamUrl?: (data: { roomid: number, qn: number[] }) => string | null;
/**
* 修改直播流地址,每次连接直播服务器(包括 HTTP 302 跳转后)都会调用一次。
* 可以返回 null 意为不做修改
* 或返回 string 修改后的直播流地址
* 或返回 {url:string, ip?:string} 在修改直播流地址的同时指定连接的 IP 地址
*/
onTransformStreamUrl?: (originalUrl: string) => string | { url: string, ip?: string } | null;
/**
* 修改发给弹幕服务器的握手包 JSON。
* 需要注意握手包会影响到弹幕服务器返回的消息格式,导致直播服务器返回录播姬不支持的数据。
* @param roomInfo 当前直播间信息
* @param json 原握手包 JSON
* @returns 返回 null 意为不做修改,或返回修改后的 JSON 文本
*/
onDanmakuHandshake?: (roomInfo: RoomInfo, json: string) => string | null;
}
interface RoomInfo {
/**
* 原房间号
* @example 123456
*/
readonly roomId: number;
/**
* 直播间短号,没有的为 0
* @example 0
*/
readonly shortId: 0 | number;
/**
* 主播名字
*/
readonly name: string;
/**
* 直播间标题
*/
readonly title: string;
/**
* 直播间父分区
*/
readonly areaParent: string;
/**
* 直播间子分区
*/
readonly areaChild: string;
/**
* 录播姬内部对象 ID,与 API 中的 objectId 相同,重启后会变化
*/
readonly objectId: string;
/**
* B站直播 API 返回的原始数据。与文件名模板的 `json` 变量相同。
* @see https://rec.danmuji.org/user/file-name-template/#json
*/
readonly apiData: any;
}
declare var console: Console;
interface Console {
assert(condition?: boolean, ...data: any[]): void;
clear(): void;
count(label?: string): void;
countReset(label?: string): void;
debug(...data: any[]): void;
error(...data: any[]): void;
info(...data: any[]): void;
log(...data: any[]): void;
time(label?: string): void;
timeEnd(label?: string): void;
timeLog(label?: string, ...data: any[]): void;
trace(...data: any[]): void;
warn(...data: any[]): void;
}
interface Storage {
readonly length: number;
clear(): void;
getItem(key: string): string | null;
key(index: number): string | null;
removeItem(key: string): void;
setItem(key: string, value: string): void;
}
declare var sharedStorage: Storage;
interface URL {
hash: string;
host: string;
hostname: string;
href: string;
readonly origin: string;
username: string;
password: string;
pathname: string;
port: string;
protocol: string;
search: string;
readonly searchParams: URLSearchParams;
toString(): string;
toJSON(): string;
}
declare var URL: {
prototype: URL;
new(url: string, base?: string): URL;
};
interface URLSearchParams {
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
getAll(name: string): string[];
has(name: string): boolean;
set(name: string, value: string): void;
/** @deprecated not implemented */
sort(): void;
toString(): string;
forEach(callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any): void;
}
declare var URLSearchParams: {
prototype: URLSearchParams;
new(init?: Record<string, string> | string): URLSearchParams;
};
declare var dns: DNS;
declare interface DNS {
/**
* 根据域名查询 IP
* @param domain 域名
* @returns IP 地址,包括 IPv4 和 IPv6(如果有)
*/
lookup(domain: string): string[];
}
/**
* 发送网络请求
* @param url 请求 URL
* @param init 请求参数
*/
declare function fetchSync(url: string, init?: FetchSyncInit): FetchSyncResponse;
interface FetchSyncInit {
method?: 'GET' | 'POST' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE';
body?: string | undefined;
headers?: Record<string, string> | [name: string, value: string][];
redirect?: 'follow' | 'manual' | 'error';
referrer?: string | undefined;
}
interface FetchSyncResponse {
status: number;
statusText: string;
ok: boolean;
body: string;
headers: { [name: string]: string }
}
/**
* 提供给脚本环境的 .NET 类型
*/
declare const dotnet: {
/**
* System.Net.Dns
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.dns
*/
Dns: any;
/**
* System.Uri
* @link https://docs.microsoft.com/en-us/dotnet/api/system.uri
*/
Uri: any;
/**
* System.UriBuilder
* @link https://docs.microsoft.com/en-us/dotnet/api/system.uribuilder
*/
UriBuilder: any;
/**
* System.Web.HttpUtility
* @link https://docs.microsoft.com/en-us/dotnet/api/system.web.httputility
*/
HttpUtility: any;
/**
* System.Collections.Specialized.NameValueCollection
* @link https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.namevaluecollection
*/
NameValueCollection: any;
/**
* System.Net.Http.HttpClient
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient
*/
HttpClient: any;
/**
* System.Net.Http.HttpClientHandler
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler
*/
HttpClientHandler: any;
/**
* System.Net.Http.HttpCompletionOption
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpcompletionoption
*/
HttpCompletionOption: any;
/**
* System.Net.Http.HttpRequestMessage
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage
*/
HttpRequestMessage: any;
/**
* System.Net.Http.HttpMethod
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpmethod
*/
HttpMethod: any;
/**
* System.Net.Http.ByteArrayContent
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.bytearraycontent
*/
ByteArrayContent: any;
/**
* System.Net.Http.StringContent
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.stringcontent
*/
StringContent: any;
/**
* System.Net.Http.FormUrlEncodedContent
* @link https://docs.microsoft.com/en-us/dotnet/api/system.net.http.formurlencodedcontent
*/
FormUrlEncodedContent: any;
}