dsh-bili-watch 0.2.26 → 0.2.27

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tools/look.mjs +14 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-bili-watch",
3
- "version": "0.2.26",
3
+ "version": "0.2.27",
4
4
  "private": false,
5
5
  "description": "把 B 站视频读成文本给 DSH agent 用:元数据、评论、弹幕、字幕、本地转写、抽帧 OCR;支持 b23.tv 短链与 av 号,抽帧缓存目录可换。只读命令零依赖。",
6
6
  "type": "module",
package/tools/look.mjs CHANGED
@@ -93,7 +93,17 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
93
93
  const jitter = (base, spread) => base + Math.floor(Math.random() * spread)
94
94
 
95
95
  async function jget(url, headers = H, timeoutMs = 30000) {
96
- const r = await fetch(url, { headers, signal: AbortSignal.timeout(timeoutMs) })
96
+ // T36-P1-2:只对网络层抖动重试一次(B 站偶发 ECONNRESET);业务 code(-352/-404)不重试
97
+ let r
98
+ for (let attempt = 0; ; attempt++) {
99
+ try {
100
+ r = await fetch(url, { headers, signal: AbortSignal.timeout(timeoutMs) })
101
+ if (!(r.status >= 500) || attempt >= 1) break
102
+ } catch (e) {
103
+ if (attempt >= 1) throw e
104
+ }
105
+ await sleep(300 + Math.floor(Math.random() * 400))
106
+ }
97
107
  const t = await r.text()
98
108
  if (!r.ok) return { code: -r.status, message: `HTTP ${r.status}` }
99
109
  try {
@@ -1781,7 +1791,7 @@ async function cmdText(bv, credPath, opts = {}) {
1781
1791
  // 口播类正常 4–6 字/秒;低于 2 字/秒多半是背景音乐、外语歌或纯画面,
1782
1792
  // 这时候转写出来的「字」只是把杂音听成了字,继续往下走 OCR 更靠谱。
1783
1793
  const rate = v.dur > 0 ? a.chars / v.dur : 0
1784
- if (rate >= 2) {
1794
+ if (rate >= 2 && !(a.verify && a.verify.suspect)) {
1785
1795
  // T40:ASR 也会把杂音/背景音听成字,主入口同样要过诱饵信号(原先只有字幕分支有)
1786
1796
  const asrBait = baitSignals(a.text, v, credibility(v, a.text))
1787
1797
  if (asrBait.suspect) {
@@ -1800,6 +1810,8 @@ async function cmdText(bv, credPath, opts = {}) {
1800
1810
  printText(a.text, opts, bv)
1801
1811
  done()
1802
1812
  return
1813
+ } else if (a.verify && a.verify.suspect) {
1814
+ say(`[track] 转写: ⚠ 疑似幻觉(${(a.verify.reasons || []).join(';')}),降级到抽帧/OCR`)
1803
1815
  }
1804
1816
  say(`[track] 转写: 质量低(${a.chars} 字,${rate.toFixed(1)} 字/秒),继续往下试`)
1805
1817
  } else {