Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(copy): 服务端返给用户的状态与报错文案改成作者口吻

longmeidaof9cac5a446bc
diff --git a/src/peach/desktop_uninstall.py b/src/peach/desktop_uninstall.py
index 79e150ede..c55fa316f 100644
--- a/src/peach/desktop_uninstall.py
+++ b/src/peach/desktop_uninstall.py
@@ -60,7 +60,7 @@ def plan(config, *, delete_data: bool, program: Path | None = None) -> dict:
def snapshot(config) -> dict:
- result = {"available": False, "message": "此系统请退出 Peach 后手动移除程序与数据目录", "data_root": str(config.data_root),
+ result = {"available": False, "message": "这个系统上先退出 Peach,再手动移除程序与数据目录", "data_root": str(config.data_root),
"directories": [str(config.directory(key)) for key in settings_file.DIRECTORY_KEYS], "full_available": False}
if sys.platform != "win32":
return result
diff --git a/src/peach/field_owners.py b/src/peach/field_owners.py
index 7c179812b..e3ece370e 100644
--- a/src/peach/field_owners.py
+++ b/src/peach/field_owners.py
@@ -116,9 +116,9 @@ def owner_label(owner: str | None) -> str:
"""
kind, _, identifier = str(owner or "").partition(":")
if kind == "user":
- return "你填的"
+ return "手动填写"
if kind == "review":
- return f"你批准的 {identifier}"
+ return f"复核批准 {identifier}"
if kind == "auto":
return f"{identifier} 免复核落库"
if kind == "scan":
diff --git a/src/peach/library_processing.py b/src/peach/library_processing.py
index bf5773665..4874d4d03 100644
--- a/src/peach/library_processing.py
+++ b/src/peach/library_processing.py
@@ -352,7 +352,7 @@ def snapshot(config):
if state.get('status') == 'running':
# 拿得到锁说明写入者已经不在了。结论写回文件:只改副本的话,另一个读取者
# 正好短暂占着锁时会读到原样的「运行中」,界面就在两种状态之间来回跳。
- state.update(status='failed', error='处理被中断,请重试。',
+ state.update(status='failed', error='处理被中断,可重试未完成的部分。',
completed_at=state.get('last_progress_at') or time.time())
_save(state_path(config), state)
except Timeout:
@@ -379,9 +379,9 @@ def snapshot(config):
state.update(notes=notes, issue_count=problems, issue_preview=preview,
issues_truncated=problems > len(preview),
retryable_asset_ids=sorted(retryable))
- if state.get('error') == f'{count} 项需要处理,请查看详情并重试。':
+ if state.get('error') == f'{count} 项需要处理,可重试未完成的部分。':
state['status'] = 'failed' if problems else 'complete'
- state['error'] = f'{problems} 项需要处理,请查看详情并重试。' if problems else ''
+ state['error'] = f'{problems} 项需要处理,可重试未完成的部分。' if problems else ''
except (OSError, ValueError, TypeError):
pass
return decorate(state)
@@ -884,7 +884,7 @@ def process_library(config, db_path, candidate_root, cover_root, *, location='co
if stage == SCAN_STAGE:
update(status='failed' if state['issue_count'] else 'complete',
stage='处理结束', completed_at=time.time(),
- error=f"{state['issue_count']} 项需要处理,请查看详情并重试。"
+ error=f"{state['issue_count']} 项需要处理,可重试未完成的部分。"
if state['issue_count'] else '')
return state
# 演员和标签是另外两张表,`asset` 上没有这两列。不带上它们,采集就把每部片都
@@ -1023,11 +1023,11 @@ def process_library(config, db_path, candidate_root, cover_root, *, location='co
performer_aliases=profiles['aliases'], performer_avatars=profiles['avatars'],
performer_profile_conflicts=profiles['conflicts'],
performer_profile_failed=profiles['failed'],
- error=f"{state['issue_count']} 项需要处理,请查看详情并重试。" if state['issue_count'] else '',
+ error=f"{state['issue_count']} 项需要处理,可重试未完成的部分。" if state['issue_count'] else '',
completed_at=time.time(), current_asset_id=None, current_asset_name='',
current_action='', current_started_at=None, current_deadline_at=None)
except Exception:
- state.update(status='failed', error='处理被中断,请检查媒体目录后重试。', completed_at=time.time())
+ state.update(status='failed', error='处理被中断。核对媒体目录后重试。', completed_at=time.time())
_save(path, state)
raise
finally:
diff --git a/src/peach/onboarding.py b/src/peach/onboarding.py
index 8c457f188..41115bf1b 100644
--- a/src/peach/onboarding.py
+++ b/src/peach/onboarding.py
@@ -113,7 +113,7 @@ def media_dir_validator(*, windows: bool) -> Callable[[str], Path]:
raise ValueError("媒体目录不能为空")
path = Path(text).expanduser()
if not path.is_dir():
- raise ValueError(f"目录不存在或不是目录:{path}(这里不会替你创建)")
+ raise ValueError(f"目录不存在,或者不是目录:{path}。先建好再填。")
resolved = path.resolve()
if windows and not is_windows_path(str(resolved)):
raise ValueError(f"{resolved} 不是盘符路径;网络位置先映射成盘符再来")
diff --git a/src/peach/routes_configuration.py b/src/peach/routes_configuration.py
index 7d5d67ddb..9abc1f0fc 100644
--- a/src/peach/routes_configuration.py
+++ b/src/peach/routes_configuration.py
@@ -28,7 +28,7 @@ router = APIRouter()
_SAVE_LOCK = threading.Lock()
RELOAD_NAME = onboarding.RELOAD_NAME
#: 直接由 CLI 管理的服务使用设置文件。
-FILE_MANAGED_NOTICE = "此部署通过配置文件管理服务,请在本机编辑下方的设置文件。"
+FILE_MANAGED_NOTICE = "这个部署由配置文件管理服务;在本机编辑下方的设置文件。"
def managed_configuration() -> bool:
@@ -343,7 +343,7 @@ def save_access(request: Request, body: dict[str, Any] = Body(default_factory=di
if body["action"] == "set" and not password:
raise HTTPException(400, {"message": "请输入访问密码", "errors": {"password": "请输入访问密码"}})
if body["action"] == "disable" and body.get("confirm_disable") is not True:
- raise HTTPException(400, "请确认允许能连接到 Peach 的设备直接访问")
+ raise HTTPException(400, "关闭访问密码前先勾选确认")
try:
try:
access.validate_password(password, body.get("confirmation", ""))
diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.py
index b4268ae8a..5d8cae13b 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -352,7 +352,7 @@ def setup_page(
media_dirs = _media_dir_values(values, question.default)
row_errors = errors.get("media_dir", [])
note = "" if windows else onboarding.mounts_explanation(
- [path for path in media_dirs if path] or ["你在上面填的目录"])
+ [path for path in media_dirs if path] or ["上面填写的目录"])
fields.append(_media_dirs_html(media_dirs, list(row_errors), "" if windows else
"本机文件夹是这台电脑读取媒体的位置;Windows 中的对应路径用于匹配馆藏中已有的路径。",
locations=values.get("media_location", ()), roots=values.get("media_root", ()), windows=windows))
@@ -399,7 +399,7 @@ def setup_page(
body = (
'<section class="setup-auth-card"><header><img class="mark" src="/peach-logo.png" alt="" width="40" height="40">'
"<h1>欢迎使用 Peach</h1>"
- '<p class="lede">添加媒体库,开始整理你的馆藏。</p></header>'
+ '<p class="lede">添加媒体库,开始整理馆藏。</p></header>'
'<form method="post" action="/setup">'
+ "".join(fields)
+ '<section class="setup-options" aria-labelledby="setup-options-title">'
@@ -419,11 +419,11 @@ def setup_done_page(applied, *, windows: bool, scan_requested: bool, history_gui
config = applied.config
destination = escape(_normal_url(config) + ('taste?onboarding=1' if history_guide else '?onboarding=1'), quote=True)
destination_label = '导入浏览器历史记录' if history_guide else '进入 Peach'
- scan = ("首次扫描已排队,将在后台整理媒体库。你可以继续使用 Peach。" if scan_requested
- else "你可以稍后在配置页开始扫描媒体库。")
+ scan = ("首次扫描已排队,在后台整理媒体库,期间可以照常使用 Peach。" if scan_requested
+ else "稍后在配置页开始扫描媒体库。")
body = (
'<section class="setup-auth-card"><header><img class="mark" src="/peach-logo.png" alt="" width="40" height="40">'
- '<h1>设置完成</h1><p class="lede">正在启动你的馆藏。</p></header>'
+ '<h1>设置完成</h1><p class="lede">正在启动馆藏。</p></header>'
f'<p>{scan}</p>'
+ f'<p><a class="setup-enter" href="{destination}">{destination_label}</a></p>'
+ runtime_facts_html(config, collapsible=True)
diff --git a/src/peach/tunnel.py b/src/peach/tunnel.py
index c9048946d..c6d063895 100644
--- a/src/peach/tunnel.py
+++ b/src/peach/tunnel.py
@@ -331,8 +331,8 @@ def _require_binary(
)
if binary is None:
raise TunnelError(
- "找不到 cloudflared;请安装官方 cloudflared,"
- "或在设置文件的 tunnel.binary 指定路径,也可用 PEACH_CLOUDFLARED 指定"
+ "找不到 cloudflared:安装官方 cloudflared,"
+ "或用设置文件的 tunnel.binary 与 PEACH_CLOUDFLARED 指定路径"
)
return binary
diff --git a/src/peach/web_scraping.py b/src/peach/web_scraping.py
index 472ad94d7..de13f77f5 100644
--- a/src/peach/web_scraping.py
+++ b/src/peach/web_scraping.py
@@ -57,7 +57,7 @@ def _fetch_cover(contract, code):
installed = json.loads(sidecar.read_text(encoding="utf-8"))
if (time.time() - float(installed["checked_at"]) < 86400 and target.is_file()
and hashlib.sha256(target.read_bytes()).hexdigest() == installed["raw_sha256"]):
- return {"ok": True, "code": code, "result": f"已复用 24 小时内核验的本机封面({installed['width']} × {installed['height']}),本次未重复请求来源。", **{
+ return {"ok": True, "code": code, "result": f"复用 24 小时内核验过的本机封面({installed['width']} × {installed['height']}),没有再向来源请求。", **{
key: installed[key] for key in ("width", "height", "raw_sha256")}}
except (OSError, ValueError, KeyError, TypeError):
installed = None
@@ -91,9 +91,9 @@ def _fetch_cover(contract, code):
target, candidate, size, current_candidate,
candidate_improves, candidate_quality)
if kept_size is not None:
- suffix = "部分来源连接失败,未能完成全部来源比较。" if network_failed or any(s >= 400 and s != 404 for s in statuses) else "本次未找到更大尺寸或更合适的可用封面。"
+ suffix = "部分来源连接失败,未能完成全部来源比较。" if network_failed or any(s >= 400 and s != 404 for s in statuses) else "没有找到更大或更合适的封面。"
return {"ok": True, "code": code, "reason": "kept_existing",
- "result": f"本机封面 {kept_size[0]} × {kept_size[1]},本次取得的可用封面 {size[0]} × {size[1]};保留本机封面。{suffix}"}
+ "result": f"本机封面 {kept_size[0]} × {kept_size[1]},来源可用封面 {size[0]} × {size[1]};保留本机封面。{suffix}"}
evidence = {"code": code, "width": size[0], "height": size[1],
"source": candidate.source, "source_url": candidate.url,
"raw_sha256": hashlib.sha256(data).hexdigest(),
@@ -111,7 +111,7 @@ def _fetch_cover(contract, code):
elif any(s >= 500 for s in statuses):
reason, message = "source_error", "来源服务异常(HTTP 5xx),请稍后重试。"
elif str(exc) == "所有渠道都没有候选":
- reason, message = "no_candidate", "本次来源未返回匹配该番号的封面候选,无法判断是否还有高清版。"
+ reason, message = "no_candidate", "来源没有返回这个番号的封面候选,无法判断是否有高清版。"
else:
reason, message = {
OFFICIAL_PLACEHOLDER_ONLY: ("placeholder_only", f"{OFFICIAL_PLACEHOLDER_ONLY}。"),
diff --git a/tests/test_field_owners.py b/tests/test_field_owners.py
index d6ba80b80..1fb1c4d1b 100644
--- a/tests/test_field_owners.py
+++ b/tests/test_field_owners.py
@@ -207,8 +207,8 @@ class FieldOwnerVocabularyTests(unittest.TestCase):
self.assertTrue(set(OWNED_FIELDS) <= columns)
def test_owner_labels_say_who_wrote_it(self):
- self.assertEqual(owner_label(USER_MANUAL), "你填的")
- self.assertEqual(owner_label("review:javbus"), "你批准的 javbus")
+ self.assertEqual(owner_label(USER_MANUAL), "手动填写")
+ self.assertEqual(owner_label("review:javbus"), "复核批准 javbus")
self.assertEqual(owner_label("auto:r18dev"), "r18dev 免复核落库")
self.assertEqual(owner_label("scan:filename"), "文件名推导")
self.assertEqual(owner_label("script:clean_names"), "维护脚本 clean_names")
diff --git a/tests/test_metadata_library.py b/tests/test_metadata_library.py
index f896d244a..ce9debe7a 100644
--- a/tests/test_metadata_library.py
+++ b/tests/test_metadata_library.py
@@ -787,7 +787,7 @@ class LibraryNfoTests(unittest.TestCase):
self.assertEqual((second['status'], second['issue_count']), ('complete', 0))
self.assertEqual((first['status'], first['issue_count']), ('failed', 1))
# 状态文件里没有 `notes` 的任务,读出来要按日志把告知项和问题分开重算。
- stored = dict(second, status='failed', error='2 项需要处理,请查看详情并重试。', issue_count=2,
+ stored = dict(second, status='failed', error='2 项需要处理,可重试未完成的部分。', issue_count=2,
issue_preview=[{'asset_id': 1, 'title': 'STP-26232.mp4', 'path': '',
'message': message, 'severity': 'error'}
for message in ('外部来源没有这部片的资料,7 天内不再问',
diff --git a/tests/test_web_review.py b/tests/test_web_review.py
index 691c13fac..514de59f0 100644
--- a/tests/test_web_review.py
+++ b/tests/test_web_review.py
@@ -621,7 +621,7 @@ class ReviewQueueTests(unittest.TestCase):
row = next(item for item in rows if item["item_key"] == "III-9:studio")
self.assertEqual(row["current_owner"], USER_MANUAL)
self.assertEqual(row["asset_mutation_revision"], 1)
- self.assertIn("(你填的)", rm_review._review_evidence("metadata_fields", row))
+ self.assertIn("(手动填写)", rm_review._review_evidence("metadata_fields", row))
def test_two_sources_saying_the_same_thing_land_without_review(self):
"""数取值,不数候选条数。