Skip to content

Commit 087052b

Browse files
committed
fix: 通知消息去掉路径前缀和季度,添加'最新一集更新啦'
1 parent 17374df commit 087052b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

  • backend/src/module/notification

backend/src/module/notification/base.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,23 @@ def _format_message(self, notify: Notification) -> str:
4545
Formatted message string.
4646
"""
4747
import os
48-
# If official_title contains a path separator, extract just the folder name
48+
import re
49+
# If official_title contains a full path like "D:\server\QB\Bangumi\", strip it
4950
title = notify.official_title
5051
if os.sep in title or (os.altsep and os.altsep in title):
51-
title = os.path.basename(os.path.normpath(title))
52+
# Try to find the bangumi folder name (the folder before "Season X")
53+
# Strip drive letter and base paths
54+
normalized = os.path.normpath(title)
55+
parts = normalized.split(os.sep)
56+
# Find the part that looks like a bangumi title (not "Season X")
57+
bangumi_parts = []
58+
for part in parts:
59+
if re.match(r'^Season\s*\d+$', part, re.IGNORECASE):
60+
break
61+
bangumi_parts.append(part)
62+
title = os.sep.join(bangumi_parts) if bangumi_parts else parts[-1]
5263
return (
64+
f"最新一集更新啦\n"
5365
f"番剧名称:{title}\n"
54-
f"季度: 第{notify.season}\n"
5566
f"更新集数: 第{notify.episode}集"
5667
)

0 commit comments

Comments
 (0)