dsh-watch-together 0.2.7 → 0.2.9
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.
- package/CHANGELOG.md +68 -0
- package/dsh.plugin.json +1 -1
- package/examples/floating-chat/run-glass.cmd +37 -9
- package/examples/floating-chat/window.py +19 -2
- package/extension/content.js +41 -8
- package/package.json +1 -1
- package/examples/floating-chat/run-glass-60fps.cmd +0 -7
- package/examples/floating-chat/run-glass-acrylic.cmd +0 -8
- package/examples/floating-chat/run-glass-nochroma.cmd +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,74 @@
|
|
|
3
3
|
All notable changes to **dsh-watch-together** are documented here.
|
|
4
4
|
This package starts its own version line at `0.0.7` — it is not a continuation of `dsh-video-storyboard`.
|
|
5
5
|
|
|
6
|
+
## [0.2.9] - 2026-11-03
|
|
7
|
+
|
|
8
|
+
> 一条根因修得很漂亮的 bug:拖动窗口时的动态模糊。
|
|
9
|
+
|
|
10
|
+
### Fixed — 拖动窗口没有动态模糊(合 PR #49,作者 @ggfgfgf-on,对应 #48)
|
|
11
|
+
|
|
12
|
+
现象是「`GLASS_FORCE=1` 下能看到那种黏黏的拖尾,正常启动看不到」,我一开始以为是
|
|
13
|
+
`_motion_blur` 的衰减公式问题 —— 猜错了。
|
|
14
|
+
|
|
15
|
+
真正的原因在这行:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
if self._sig is not None and box == self._sig_bbox and sig.shape == self._sig.shape:
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
拖动窗口时抓取区域 `box = (gl, gt, gr, gb)` 每帧都在变,`box == self._sig_bbox` 永远不成立,
|
|
22
|
+
`moved` 一直是 `False`。于是:
|
|
23
|
+
|
|
24
|
+
- `_motion_blur` 一路乘 0.55 衰减到 0,混合那步一次都不执行;
|
|
25
|
+
- 反而每帧都在做 `apply_chroma(panel, 1.7)`(那是「没在动」时的色散补偿)。
|
|
26
|
+
|
|
27
|
+
`FORCE` 之所以看起来有效,只是因为它跳过静态跳帧、帧数更多,更容易凑出连续可混合的帧 ——
|
|
28
|
+
它并没有修掉这个判断。
|
|
29
|
+
|
|
30
|
+
现在 `_sig_bbox` 已存在且 `box` 变了,就把这一帧标成 `moved = True`:抓取区域变了,
|
|
31
|
+
旧区域的像素本来也不能直接做差,但这确实是运动。静止窗口仍走原来的像素差判断,
|
|
32
|
+
不会变成常驻拖影。和 #42 不冲突 —— `_invalidate_glass()` 会把 `_sig_bbox` 清成 `None`,
|
|
33
|
+
形状变化后的第一帧不会误判成 `box_changed`。
|
|
34
|
+
|
|
35
|
+
### 说明 — 静止画面下没有动态模糊是设计
|
|
36
|
+
|
|
37
|
+
同一轮确认:`if moved` 这层是故意留的,运动模糊不是常驻滤镜。静止时混上一帧只会把文字和边缘
|
|
38
|
+
永久糊一层,还会让 `_motion_blur` 维持在高位,停下后回不到清晰;CPU 每帧做一次 `Image.blend` 也不便宜。
|
|
39
|
+
|
|
40
|
+
想要「低速拖尾」可以做配置项(类似 `motionBlurFloor`,默认 0),但不改默认行为。
|
|
41
|
+
|
|
42
|
+
## [0.2.8] - 2026-11-03
|
|
43
|
+
|
|
44
|
+
> 三个社区 PR(都是 @ggfgfgf-on)+ 一批失效入口的清理。
|
|
45
|
+
|
|
46
|
+
### Fixed — 多 P / 选集页面读错 `<video>`(合 PR #45,对应 #44)
|
|
47
|
+
|
|
48
|
+
旧实现按 `duration` 挑播放器,遇到 B 站多语言版本这种页面,会挑中一个隐藏的 13 分钟长视频,
|
|
49
|
+
上报的 `pos` 直接跳到 13:42,插件判定「换片了」,陪看中断。
|
|
50
|
+
|
|
51
|
+
新逻辑:先排除不可见 / 零尺寸 / `opacity: 0` 的候选,再按在视口里占据的面积排序;
|
|
52
|
+
播放中只加一档权重(不能压过更大的主播放器);认画中画和全屏;整页都不可见才退回全部。
|
|
53
|
+
|
|
54
|
+
### Fixed — 气泡形状变化后不重合成(合 PR #42)
|
|
55
|
+
|
|
56
|
+
静态跳帧只看 `_sig_bbox`,只清 `_sig` 不够。气泡/内框形状变了之后,如果桌面本身静止,
|
|
57
|
+
worker 会一直 `return None`,新遮罩和新色散要等用户动一下鼠标才出现。
|
|
58
|
+
`FORCE` 模式下看不出来,只在真机静置时暴露。
|
|
59
|
+
|
|
60
|
+
### Fixed — `_tick` 每 4ms 重读一次配置(合 PR #47,fixes #46)
|
|
61
|
+
|
|
62
|
+
`not capturable()` 每拍读一次 `watch-window.json` —— `__init__` 早就把结果缓存在
|
|
63
|
+
`self._cappable` 了,这里纯属白花。0.2.7 引入的疏漏,谢谢抓出来。
|
|
64
|
+
|
|
65
|
+
### Fixed — 删掉失效的 `run-glass*.cmd`,并去掉里面的本机绝对路径(#43)
|
|
66
|
+
|
|
67
|
+
玻璃渲染重写之后 `DSH_WATCH_GLASS_TTL/FPS/CHROMA/BLUR/SAT` 和 `DSH_GLASS_ACRYLIC`
|
|
68
|
+
已经没有任何代码读取,但那几个脚本还在设置它们:双击 `run-glass-acrylic.cmd` 以为开了
|
|
69
|
+
亚克力,实际还是普通软件模糊。静默失效比报错更糟。
|
|
70
|
+
|
|
71
|
+
现在只留一个 `run-glass.cmd`,开头列清哪些变量废弃、哪些真正有效;解释器也不再写死
|
|
72
|
+
本机路径(先找 PATH 上的 `pythonw`,再退 `py -3`)—— 这个仓库是公开的。
|
|
73
|
+
|
|
6
74
|
## [0.2.7] - 2026-11-03
|
|
7
75
|
|
|
8
76
|
> 五个社区 PR 一起收(都是 @ggfgfgf-on 提的),外加录屏模式的两个真 bug。
|
package/dsh.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-watch-together",
|
|
3
3
|
"description": "Watch a video together with a text-only agent: follow the user's real playback position and hand over one segment at a time, just before the segment ends.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.9",
|
|
5
5
|
"entry": {
|
|
6
6
|
"name": "dsh-watch-together",
|
|
7
7
|
"inject": [
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
@echo off
|
|
2
|
-
rem
|
|
3
|
-
rem
|
|
4
|
-
rem
|
|
5
|
-
rem
|
|
6
|
-
rem
|
|
7
|
-
rem
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
rem ---------------------------------------------------------------------------
|
|
3
|
+
rem 手工启动悬浮窗(开发/调试用)。正常使用时插件自己会拉起窗口,不需要这个。
|
|
4
|
+
rem
|
|
5
|
+
rem 【重要】旧版的这组变量在玻璃渲染重写之后**已经全部不读了**,设了也不会有
|
|
6
|
+
rem 任何效果 —— 见 issue #43。以前双击 run-glass-acrylic.cmd 以为开了亚克力,
|
|
7
|
+
rem 实际还是普通软件模糊:
|
|
8
|
+
rem
|
|
9
|
+
rem DSH_WATCH_GLASS_TTL / FPS / CHROMA / BLUR / SAT (不读)
|
|
10
|
+
rem DSH_GLASS_ACRYLIC (不读,没有 acrylic 路径了)
|
|
11
|
+
rem
|
|
12
|
+
rem 现在真正有效的开关:
|
|
13
|
+
rem
|
|
14
|
+
rem DSH_GLASS_NATIVE=1 走 GPU 路径(D3D11)
|
|
15
|
+
rem GLASS_FORCE=1 每帧强制重合成(调试用,很费 CPU)
|
|
16
|
+
rem DSH_GLASS_PREVIEW=1 预览模式:不抓屏,只贴最后一帧
|
|
17
|
+
rem DSH_GLASS_SNAPSHOT=1 文档截图模式:跑 2.5 秒后冻结画面
|
|
18
|
+
rem DSH_GLASS_WDA=0 允许截图/录屏拍到窗口(等价于配置里的 capturable)
|
|
19
|
+
rem
|
|
20
|
+
rem 尺寸、名字、capturable 这类持久设置写 ~/.dsh/watch-window.json。
|
|
21
|
+
rem ---------------------------------------------------------------------------
|
|
22
|
+
|
|
10
23
|
cd /d "%~dp0"
|
|
11
|
-
|
|
24
|
+
|
|
25
|
+
rem 不写死解释器路径:先在 PATH 上找,找不到再试 py 启动器。
|
|
26
|
+
where pythonw >nul 2>&1
|
|
27
|
+
if %errorlevel%==0 (
|
|
28
|
+
start "" pythonw window.py
|
|
29
|
+
goto :eof
|
|
30
|
+
)
|
|
31
|
+
where py >nul 2>&1
|
|
32
|
+
if %errorlevel%==0 (
|
|
33
|
+
start "" py -3 window.py
|
|
34
|
+
goto :eof
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
echo 找不到 pythonw / py。
|
|
38
|
+
echo 需要一个带 tkinter 的 Python(python.org 官方包勾 tcl/tk,或 Microsoft Store 版),
|
|
39
|
+
echo 或者直接用插件拉起窗口(它自己会挑解释器)。
|
|
12
40
|
pause
|
|
@@ -949,6 +949,13 @@ class LiveGlass:
|
|
|
949
949
|
ctypes.windll.user32.GetWindowRect(hwnd, ctypes.byref(rc))
|
|
950
950
|
return (rc.left, rc.top, rc.right, rc.bottom)
|
|
951
951
|
|
|
952
|
+
def _invalidate_glass(self):
|
|
953
|
+
"""让下一帧必须重新合成(静态跳帧只看 _sig_bbox,单清 _sig 不够)。"""
|
|
954
|
+
with self._geo_lock:
|
|
955
|
+
self._sig = None
|
|
956
|
+
self._sig_bbox = None
|
|
957
|
+
self._prev_out = None
|
|
958
|
+
|
|
952
959
|
def _capture(self, sct):
|
|
953
960
|
l, t, r, b = self._bbox()
|
|
954
961
|
if r <= l or b <= t:
|
|
@@ -987,7 +994,13 @@ class LiveGlass:
|
|
|
987
994
|
box = (gl, gt, gr, gb)
|
|
988
995
|
now = time.perf_counter()
|
|
989
996
|
moved = False
|
|
990
|
-
|
|
997
|
+
# 窗口被拖动 / 跨屏移动时抓取区域每帧都在变,旧区域的像素不能直接做差;
|
|
998
|
+
# 但这仍然是运动。不标 moved 的话,拖动全程都走“无运动”分支:
|
|
999
|
+
# _motion_blur 一路衰减、混合永远不执行,只有 FORCE 强制多帧时才明显。
|
|
1000
|
+
box_changed = self._sig_bbox is not None and box != self._sig_bbox
|
|
1001
|
+
if box_changed:
|
|
1002
|
+
moved = True
|
|
1003
|
+
elif self._sig is not None and sig.shape == self._sig.shape:
|
|
991
1004
|
d = np.abs(sig - self._sig)
|
|
992
1005
|
moved = bool(float(d.mean()) > 0.01 or float(d.max()) > 0.5)
|
|
993
1006
|
if moved:
|
|
@@ -1453,6 +1466,10 @@ class LiveGlass:
|
|
|
1453
1466
|
if shapes != SHAPES:
|
|
1454
1467
|
with self._geo_lock:
|
|
1455
1468
|
apply_shapes(shapes)
|
|
1469
|
+
# 气泡/内框形状变了,合成的遮罩也变了;必须让上一帧的静态跳帧
|
|
1470
|
+
# 失效,否则桌面静止时 worker 会一直 return None,新遮罩/色散
|
|
1471
|
+
# 要等用户动一下鼠标或背景动一下才出现(调试 FORCE 模式下看不出)。
|
|
1472
|
+
self._invalidate_glass()
|
|
1456
1473
|
# 每条消息只按正文占一块;时间戳贴在气泡上方,不进框。
|
|
1457
1474
|
for info in infos:
|
|
1458
1475
|
bx0, by0, bx1, by1, _r = info["shape"]
|
|
@@ -1742,7 +1759,7 @@ class LiveGlass:
|
|
|
1742
1759
|
# 底部圆角/暗边会闪一下,看起来像渲染错位。
|
|
1743
1760
|
self.root.after(INTERVAL_MS, self._tick)
|
|
1744
1761
|
return
|
|
1745
|
-
if not self._excluded and not
|
|
1762
|
+
if not self._excluded and not self._cappable:
|
|
1746
1763
|
self._set_exclude(True)
|
|
1747
1764
|
self._pause.clear()
|
|
1748
1765
|
|
package/extension/content.js
CHANGED
|
@@ -13,18 +13,51 @@
|
|
|
13
13
|
/* global chrome */
|
|
14
14
|
|
|
15
15
|
(() => {
|
|
16
|
-
// 有些站点在一个页面里放多个 video
|
|
17
|
-
// 挑"
|
|
16
|
+
// 有些站点在一个页面里放多个 video(广告、预览、小窗、多 P、多语言选集)。
|
|
17
|
+
// 挑"用户正在看的那个":先排除不可见 / 零尺寸的,再按可见面积选最大的;
|
|
18
|
+
// 播放中只加一点权重,不能让它压过一个更大的主播放器。
|
|
19
|
+
// 旧实现按 duration 选,多 P 页面会挑到隐藏的 13 分钟长视频,位置直接跳到另一集。
|
|
20
|
+
function visibleBox(v) {
|
|
21
|
+
if (!v.isConnected) return null;
|
|
22
|
+
const r = v.getBoundingClientRect();
|
|
23
|
+
if (!(r.width > 2 && r.height > 2)) return null;
|
|
24
|
+
let style;
|
|
25
|
+
try { style = getComputedStyle(v); } catch { return null; }
|
|
26
|
+
if (style.display === 'none' || style.visibility === 'hidden'
|
|
27
|
+
|| Number(style.opacity) === 0) return null;
|
|
28
|
+
const left = Math.max(0, r.left);
|
|
29
|
+
const top = Math.max(0, r.top);
|
|
30
|
+
const right = Math.min(window.innerWidth, r.right);
|
|
31
|
+
const bottom = Math.min(window.innerHeight, r.bottom);
|
|
32
|
+
if (right - left <= 2 || bottom - top <= 2) return null;
|
|
33
|
+
return { area: (right - left) * (bottom - top) };
|
|
34
|
+
}
|
|
35
|
+
|
|
18
36
|
function pickVideo() {
|
|
19
37
|
const all = [...document.querySelectorAll('video')];
|
|
20
38
|
if (all.length === 0) return null;
|
|
21
39
|
if (all.length === 1) return all[0];
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
|
|
41
|
+
const viewport = Math.max(1, window.innerWidth * window.innerHeight);
|
|
42
|
+
const info = all.map((v) => ({ v, box: visibleBox(v) }));
|
|
43
|
+
// 先只在可见的里挑;整页都不可见(比如刚切走)时才退回全部。
|
|
44
|
+
const visible = info.filter((x) => x.box);
|
|
45
|
+
const pool = visible.length > 0 ? visible : info;
|
|
46
|
+
// 用户主动暂停时视频是 paused 但没 ended;只有 ended 才该让位给别的。
|
|
47
|
+
const live = pool.filter((x) => !x.v.ended);
|
|
48
|
+
const candidates = live.length > 0 ? live : pool;
|
|
49
|
+
|
|
50
|
+
const score = ({ v, box }) => {
|
|
51
|
+
let s = box ? (box.area / viewport) * 1e7 : 0;
|
|
52
|
+
if (!v.paused && !v.ended) s += 1e5;
|
|
53
|
+
if (v.readyState >= 2) s += 1e3;
|
|
54
|
+
if (v.currentTime > 0) s += 1e3;
|
|
55
|
+
if (v === document.pictureInPictureElement) s += 1e9;
|
|
56
|
+
const fs = document.fullscreenElement;
|
|
57
|
+
if (fs && fs !== document.documentElement && fs.contains(v)) s += 5e8;
|
|
58
|
+
return s;
|
|
59
|
+
};
|
|
60
|
+
return candidates.reduce((best, cur) => (score(cur) > score(best) ? cur : best)).v;
|
|
28
61
|
}
|
|
29
62
|
|
|
30
63
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-watch-together",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Watch a video together with a text-only agent: follow the user's real playback position, hand over one segment at a time just before it ends, and keep a single text stream of scripted lines, interjections and the user's replies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
rem 磨砂模式:背景由 Windows 的 GPU 合成(DWM Acrylic),一次屏都不截。
|
|
3
|
-
rem 气泡和标题栏会变成实心卡片(Tk 不支持半透明叠加)。
|
|
4
|
-
rem 想调色调:DSH_GLASS_ACRYLIC_TINT,ABGR 十六进制,默认 0xB4121014
|
|
5
|
-
set DSH_GLASS_ACRYLIC=1
|
|
6
|
-
cd /d "%~dp0"
|
|
7
|
-
"C:/Users/10437/AppData/Local/Microsoft/WindowsApps/python.exe" window.py
|
|
8
|
-
pause
|