dsh-browserpaw 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,395 @@
1
+ {
2
+ "id": "bilibili-video-detail",
3
+ "name": "Bilibili video detail reader",
4
+ "description": "Read a Bilibili video's title, uploader, description, stats, part list, and subtitle metadata via Bilibili's web-interface API inside Chrome.",
5
+ "source": {
6
+ "type": "builtin",
7
+ "urls": [
8
+ "https://www.bilibili.com/video/BV1xx411c7mD",
9
+ "https://api.bilibili.com/x/web-interface/view?bvid=BV1xx411c7mD"
10
+ ]
11
+ },
12
+ "domains": [
13
+ "www.bilibili.com",
14
+ "m.bilibili.com",
15
+ "bilibili.com",
16
+ "api.bilibili.com"
17
+ ],
18
+ "keywords": [
19
+ "bilibili",
20
+ "b站",
21
+ "哔哩哔哩",
22
+ "video",
23
+ "bvid",
24
+ "detail",
25
+ "subtitle",
26
+ "视频",
27
+ "详情",
28
+ "字幕",
29
+ "B站视频详情",
30
+ "哔哩哔哩视频",
31
+ "BV号"
32
+ ],
33
+ "startUrl": "https://www.bilibili.com/video/{{bvid}}",
34
+ "inputSchema": {
35
+ "type": "object",
36
+ "properties": {
37
+ "bvid": {
38
+ "type": "string",
39
+ "pattern": "^BV[0-9A-Za-z]{6,20}$"
40
+ }
41
+ },
42
+ "required": [
43
+ "bvid"
44
+ ],
45
+ "additionalProperties": false
46
+ },
47
+ "outputSchema": {
48
+ "type": "object",
49
+ "properties": {
50
+ "success": {
51
+ "const": true
52
+ },
53
+ "status": {
54
+ "const": "ok"
55
+ },
56
+ "video": {
57
+ "type": "object",
58
+ "properties": {
59
+ "bvid": {
60
+ "type": "string",
61
+ "pattern": "^BV[0-9A-Za-z]+$"
62
+ },
63
+ "aid": {
64
+ "type": "integer",
65
+ "minimum": 0
66
+ },
67
+ "title": {
68
+ "type": "string",
69
+ "minLength": 1
70
+ },
71
+ "url": {
72
+ "type": "string",
73
+ "pattern": "^https://www\\.bilibili\\.com/video/BV[0-9A-Za-z]+$"
74
+ },
75
+ "author": {
76
+ "type": "string"
77
+ },
78
+ "authorMid": {
79
+ "type": "integer",
80
+ "minimum": 0
81
+ },
82
+ "category": {
83
+ "type": "string"
84
+ },
85
+ "description": {
86
+ "type": "string"
87
+ },
88
+ "durationSeconds": {
89
+ "type": "integer",
90
+ "minimum": 0
91
+ },
92
+ "publishedAt": {
93
+ "type": "integer",
94
+ "minimum": 0
95
+ },
96
+ "stats": {
97
+ "type": "object",
98
+ "properties": {
99
+ "views": {
100
+ "type": "integer",
101
+ "minimum": 0
102
+ },
103
+ "likes": {
104
+ "type": "integer",
105
+ "minimum": 0
106
+ },
107
+ "coins": {
108
+ "type": "integer",
109
+ "minimum": 0
110
+ },
111
+ "favorites": {
112
+ "type": "integer",
113
+ "minimum": 0
114
+ },
115
+ "shares": {
116
+ "type": "integer",
117
+ "minimum": 0
118
+ },
119
+ "danmaku": {
120
+ "type": "integer",
121
+ "minimum": 0
122
+ },
123
+ "replies": {
124
+ "type": "integer",
125
+ "minimum": 0
126
+ }
127
+ },
128
+ "required": [
129
+ "views",
130
+ "likes",
131
+ "coins",
132
+ "favorites",
133
+ "shares",
134
+ "danmaku",
135
+ "replies"
136
+ ],
137
+ "additionalProperties": false
138
+ },
139
+ "parts": {
140
+ "type": "array",
141
+ "maxItems": 30,
142
+ "items": {
143
+ "type": "object",
144
+ "properties": {
145
+ "page": {
146
+ "type": "integer",
147
+ "minimum": 1
148
+ },
149
+ "cid": {
150
+ "type": "integer",
151
+ "minimum": 0
152
+ },
153
+ "title": {
154
+ "type": "string"
155
+ },
156
+ "durationSeconds": {
157
+ "type": "integer",
158
+ "minimum": 0
159
+ }
160
+ },
161
+ "required": [
162
+ "page",
163
+ "cid",
164
+ "title",
165
+ "durationSeconds"
166
+ ],
167
+ "additionalProperties": false
168
+ }
169
+ },
170
+ "subtitles": {
171
+ "type": "array",
172
+ "maxItems": 10,
173
+ "items": {
174
+ "type": "object",
175
+ "properties": {
176
+ "lang": {
177
+ "type": "string"
178
+ },
179
+ "langDoc": {
180
+ "type": "string"
181
+ },
182
+ "url": {
183
+ "type": "string"
184
+ }
185
+ },
186
+ "required": [
187
+ "lang",
188
+ "langDoc",
189
+ "url"
190
+ ],
191
+ "additionalProperties": false
192
+ }
193
+ }
194
+ },
195
+ "required": [
196
+ "bvid",
197
+ "aid",
198
+ "title",
199
+ "url",
200
+ "author",
201
+ "authorMid",
202
+ "category",
203
+ "description",
204
+ "durationSeconds",
205
+ "publishedAt",
206
+ "stats",
207
+ "parts",
208
+ "subtitles"
209
+ ],
210
+ "additionalProperties": false
211
+ },
212
+ "sources": {
213
+ "type": "object",
214
+ "properties": {
215
+ "api": {
216
+ "oneOf": [
217
+ {
218
+ "type": "string",
219
+ "pattern": "^https://api\\.bilibili\\.com/x/web-interface/view\\?"
220
+ },
221
+ {
222
+ "type": "null"
223
+ }
224
+ ]
225
+ },
226
+ "page": {
227
+ "type": "string",
228
+ "pattern": "^https://www\\.bilibili\\.com/video/BV[0-9A-Za-z]+$"
229
+ }
230
+ },
231
+ "required": [
232
+ "api",
233
+ "page"
234
+ ],
235
+ "additionalProperties": false
236
+ }
237
+ },
238
+ "required": [
239
+ "success",
240
+ "status",
241
+ "video",
242
+ "sources"
243
+ ],
244
+ "additionalProperties": false
245
+ },
246
+ "steps": [
247
+ {
248
+ "tool": "chrome_javascript",
249
+ "args": {
250
+ "code": "const rawBvid = String(input.bvid || '').trim();\nconst bvidMatch = rawBvid.match(/BV[0-9A-Za-z]{6,20}/);\nconst bvid = bvidMatch ? bvidMatch[0] : rawBvid;\nif (!/^BV[0-9A-Za-z]{6,20}$/.test(bvid)) {\n return { success: false, status: 'invalid_input', bvid: rawBvid, message: 'Invalid Bilibili BV id', source: 'https://www.bilibili.com/' };\n}\nconst pageUrl = 'https://www.bilibili.com/video/' + bvid;\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:www\\.|m\\.)?bilibili\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', bvid, message: 'Bilibili page origin is not ready', source: pageUrl };\n}\nconst endpoint = new URL('/x/web-interface/view', 'https://api.bilibili.com');\nendpoint.searchParams.set('bvid', bvid);\nconst readInitialStateFallback = () => {\n const state = (typeof globalThis !== 'undefined' && globalThis.__INITIAL_STATE__) || null;\n if (state && state.videoData && typeof state.videoData.bvid === 'string' && state.videoData.bvid.toLowerCase() === bvid.toLowerCase() && String(state.videoData.title || '').trim()) {\n return state.videoData;\n }\n return null;\n};\nlet data = null;\nlet apiSource = endpoint.href;\nlet response;\ntry {\n response = await fetch(endpoint.href, { credentials: 'include', headers: { Accept: 'application/json' } });\n apiSource = response.url || endpoint.href;\n} catch (error) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'fetch_error', bvid, message: String(error && error.message || error), source: apiSource };\n }\n}\nif (!data) {\n if (response.status === 404) {\n return { success: false, status: 'not_found', bvid, httpStatus: 404, source: apiSource };\n }\n if (response.status === 403) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'requires_auth', bvid, requiresLogin: true, httpStatus: 403, source: apiSource };\n }\n } else if (response.status === 412 || response.status === 429) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'rate_limited', bvid, httpStatus: response.status, message: 'Bilibili risk control or rate limit triggered', source: apiSource };\n }\n } else if (!response.ok) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'http_error', bvid, httpStatus: response.status, source: apiSource };\n }\n }\n}\nif (!data) {\n let payload;\n try {\n payload = await response.json();\n } catch {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'invalid_json', bvid, source: apiSource };\n }\n }\n if (!data) {\n if (!payload || typeof payload !== 'object') {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'invalid_json', bvid, source: apiSource };\n }\n } else if (payload.code === -404 || payload.code === 62002 || payload.code === 62004) {\n return { success: false, status: 'not_found', bvid, code: payload.code, message: String(payload.message || ''), source: apiSource };\n } else if (payload.code === -101 || payload.code === -403) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'requires_auth', bvid, requiresLogin: true, code: payload.code, message: String(payload.message || 'Bilibili requires authentication'), source: apiSource };\n }\n } else if (payload.code === -352 || payload.code === -412) {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'rate_limited', bvid, code: payload.code, message: String(payload.message || 'Bilibili risk control triggered'), source: apiSource };\n }\n } else if (payload.code !== 0 || !payload.data || typeof payload.data !== 'object') {\n const fallback = readInitialStateFallback();\n if (fallback) {\n data = fallback;\n apiSource = null;\n } else {\n return { success: false, status: 'schema_changed', bvid, code: payload.code, message: String(payload.message || ''), source: apiSource };\n }\n } else {\n data = payload.data;\n }\n }\n}\nconst resolvedBvid = String(data.bvid || bvid).trim();\nconst title = String(data.title || '').trim();\nif (!/^BV[0-9A-Za-z]+$/.test(resolvedBvid) || !title) {\n return { success: false, status: 'schema_changed', bvid, source: apiSource || pageUrl };\n}\nconst stat = data.stat || {};\nconst parts = Array.isArray(data.pages) ? data.pages.slice(0, 30).map((part, idx) => ({\n page: Math.max(1, Math.floor(Number(part && part.page) || idx + 1)),\n cid: Math.max(0, Math.floor(Number(part && part.cid) || 0)),\n title: String((part && part.part) || '').trim(),\n durationSeconds: Math.max(0, Math.floor(Number(part && part.duration) || 0))\n})) : [];\nconst rawSubs = data.subtitle && Array.isArray(data.subtitle.list) ? data.subtitle.list : [];\nconst subtitles = rawSubs.slice(0, 10).map(sub => {\n const rawUrl = String((sub && sub.subtitle_url) || '').trim();\n const normalizedUrl = rawUrl.startsWith('//') ? 'https:' + rawUrl : rawUrl;\n return {\n lang: String((sub && sub.lan) || '').trim(),\n langDoc: String((sub && sub.lan_doc) || '').trim(),\n url: normalizedUrl\n };\n}).filter(sub => sub.lang || sub.url);\nreturn {\n success: true,\n status: 'ok',\n video: {\n bvid: resolvedBvid,\n aid: Math.max(0, Math.floor(Number(data.aid) || 0)),\n title,\n url: 'https://www.bilibili.com/video/' + resolvedBvid,\n author: String((data.owner && data.owner.name) || '').trim(),\n authorMid: Math.max(0, Math.floor(Number(data.owner && data.owner.mid) || 0)),\n category: String(data.tname || '').trim(),\n description: String(data.desc || '').trim().slice(0, 3000),\n durationSeconds: Math.max(0, Math.floor(Number(data.duration) || 0)),\n publishedAt: Math.max(0, Math.floor(Number(data.pubdate) || 0)),\n stats: {\n views: Math.max(0, Math.floor(Number(stat.view) || 0)),\n likes: Math.max(0, Math.floor(Number(stat.like) || 0)),\n coins: Math.max(0, Math.floor(Number(stat.coin) || 0)),\n favorites: Math.max(0, Math.floor(Number(stat.favorite) || 0)),\n shares: Math.max(0, Math.floor(Number(stat.share) || 0)),\n danmaku: Math.max(0, Math.floor(Number(stat.danmaku) || 0)),\n replies: Math.max(0, Math.floor(Number(stat.reply) || 0))\n },\n parts,\n subtitles\n },\n sources: {\n api: apiSource,\n page: 'https://www.bilibili.com/video/' + resolvedBvid\n }\n};",
251
+ "timeoutMs": 30000
252
+ },
253
+ "resultPath": "/result"
254
+ }
255
+ ],
256
+ "verification": {
257
+ "tool": "chrome_network_request",
258
+ "args": {
259
+ "url": "https://api.bilibili.com/x/web-interface/view?bvid={{bvid}}",
260
+ "method": "GET",
261
+ "timeout": 30000
262
+ },
263
+ "resultPath": "/response/body"
264
+ },
265
+ "tests": [
266
+ {
267
+ "inputs": {
268
+ "bvid": "BV1xx411c7mD"
269
+ },
270
+ "expect": {
271
+ "type": "object",
272
+ "properties": {
273
+ "success": {
274
+ "const": true
275
+ },
276
+ "video": {
277
+ "type": "object",
278
+ "properties": {
279
+ "bvid": {
280
+ "const": "BV1xx411c7mD"
281
+ },
282
+ "title": {
283
+ "type": "string",
284
+ "minLength": 1
285
+ }
286
+ },
287
+ "required": [
288
+ "bvid",
289
+ "title"
290
+ ]
291
+ },
292
+ "sources": {
293
+ "type": "object",
294
+ "required": [
295
+ "api",
296
+ "page"
297
+ ]
298
+ }
299
+ },
300
+ "required": [
301
+ "success",
302
+ "video",
303
+ "sources"
304
+ ]
305
+ },
306
+ "observe": {
307
+ "type": "object",
308
+ "properties": {
309
+ "code": {
310
+ "const": 0
311
+ },
312
+ "data": {
313
+ "type": "object",
314
+ "properties": {
315
+ "bvid": {
316
+ "const": "BV1xx411c7mD"
317
+ }
318
+ },
319
+ "required": [
320
+ "bvid"
321
+ ]
322
+ }
323
+ },
324
+ "required": [
325
+ "code",
326
+ "data"
327
+ ]
328
+ }
329
+ },
330
+ {
331
+ "inputs": {
332
+ "bvid": "BV1GJ411x7h7"
333
+ },
334
+ "expect": {
335
+ "type": "object",
336
+ "properties": {
337
+ "success": {
338
+ "const": true
339
+ },
340
+ "video": {
341
+ "type": "object",
342
+ "properties": {
343
+ "bvid": {
344
+ "const": "BV1GJ411x7h7"
345
+ },
346
+ "title": {
347
+ "type": "string",
348
+ "minLength": 1
349
+ }
350
+ },
351
+ "required": [
352
+ "bvid",
353
+ "title"
354
+ ]
355
+ },
356
+ "sources": {
357
+ "type": "object",
358
+ "required": [
359
+ "api",
360
+ "page"
361
+ ]
362
+ }
363
+ },
364
+ "required": [
365
+ "success",
366
+ "video",
367
+ "sources"
368
+ ]
369
+ },
370
+ "observe": {
371
+ "type": "object",
372
+ "properties": {
373
+ "code": {
374
+ "const": 0
375
+ },
376
+ "data": {
377
+ "type": "object",
378
+ "properties": {
379
+ "bvid": {
380
+ "const": "BV1GJ411x7h7"
381
+ }
382
+ },
383
+ "required": [
384
+ "bvid"
385
+ ]
386
+ }
387
+ },
388
+ "required": [
389
+ "code",
390
+ "data"
391
+ ]
392
+ }
393
+ }
394
+ ]
395
+ }