fix(jellyfin): skip playback percentage when runtime is zero (#7034)

This commit is contained in:
Cat
2026-10-16 22:12:08 +08:00
committed by GitHub
parent 3a88d6d57b
commit f75c32e4ea
2 changed files with 17 additions and 1 deletions

View File

@@ -904,7 +904,7 @@ class Jellyfin:
playback_position_ticks = message.get('PlaybackPositionTicks')
runtime_ticks = message.get('RunTimeTicks')
if playback_position_ticks is not None and runtime_ticks is not None:
if playback_position_ticks is not None and runtime_ticks:
eventItem.percentage = playback_position_ticks / runtime_ticks * 100
# 获取消息图片

View File

@@ -155,3 +155,19 @@ def test_emby_series_identity_requests_provider_ids(monkeypatch) -> None:
"http://emby.local/emby/Users/user-1/Items/series-item-1",
{"api_key": "test-key", "Fields": "ProviderIds"},
)
def test_jellyfin_webhook_ignores_zero_runtime_percentage() -> None:
"""时长为 0 的条目(如 strm)不应因计算播放进度而中断 webhook 解析。"""
client = Jellyfin.__new__(Jellyfin)
event = client.get_webhook_message(json.dumps({
"NotificationType": "PlaybackStart",
"ItemType": "Movie",
"Name": "测试电影",
"Year": 2026,
"PlaybackPositionTicks": 0,
"RunTimeTicks": 0,
}))
assert event is not None
assert event.percentage is None