feat: package docker deployment and publish flow

This commit is contained in:
theshy
2026-04-22 16:20:03 +08:00
parent 055474360e
commit 2146687dc6
178 changed files with 24318 additions and 20855 deletions

View File

@ -88,7 +88,7 @@ class BilibiliTopCommentProviderTests(unittest.TestCase):
self.assertEqual(result["split"]["reason"], "comment_disabled")
self.assertEqual(len(api.reply_calls), 1)
self.assertIn("P1:\n1. Song A — Artist A", api.reply_calls[0]["content"])
self.assertIn("P2:\n1. Song B — Artist B", api.reply_calls[0]["content"])
self.assertIn("P2:\n2. Song B — Artist B", api.reply_calls[0]["content"])
def test_split_comment_skips_on_non_anchor_task(self) -> None:
api = _FakeBilibiliApi()
@ -212,6 +212,63 @@ class BilibiliTopCommentProviderTests(unittest.TestCase):
self.assertEqual(result["split"]["reason"], "comment_disabled")
self.assertTrue((work_dir / "comment_done.flag").exists())
def test_comment_format_can_be_configured_from_upload_config(self) -> None:
api = _FakeBilibiliApi()
provider = BilibiliTopCommentProvider(bilibili_api=api)
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
work_dir = root / "task-1"
work_dir.mkdir(parents=True, exist_ok=True)
task = Task(
id="task-1",
source_type="local_file",
source_path=str(work_dir / "source.mp4"),
title="task-1",
status="published",
created_at=utc_now_iso(),
updated_at=utc_now_iso(),
)
(work_dir / "songs.txt").write_text("00:00:00 Song From Text — Artist T\n", encoding="utf-8")
(work_dir / "songs.json").write_text(
json.dumps({"songs": [{"title": "Song A", "artist": "Artist A"}]}),
encoding="utf-8",
)
(work_dir / "bvid.txt").write_text("BV1COMMENT123", encoding="utf-8")
(work_dir / "full_video_bvid.txt").write_text("BV1FULL12345", encoding="utf-8")
cookies_file = root / "cookies.json"
cookies_file.write_text("{}", encoding="utf-8")
upload_config = root / "upload_config.json"
upload_config.write_text(
json.dumps(
{
"comment_template": {
"split_header": "这是纯享:{current_full_video_link}\n上一场:{previous_full_video_link}",
"split_song_line": "#{song_index} {title} / {artist}",
}
}
),
encoding="utf-8",
)
result = provider.comment(
task,
{
"session_dir": str(root),
"cookies_file": str(cookies_file),
"upload_config_file": str(upload_config),
"post_split_comment": True,
"post_full_video_timeline_comment": False,
},
)
self.assertEqual(result["status"], "ok")
self.assertEqual(result["split"]["reason"], "comment_disabled")
self.assertEqual(len(api.reply_calls), 1)
content = str(api.reply_calls[0]["content"])
self.assertIn("这是纯享https://www.bilibili.com/video/BV1FULL12345", content)
self.assertNotIn("上一场:", content)
self.assertIn("#1 Song A / Artist A", content)
def test_full_comment_aggregates_session_parts_on_anchor_task(self) -> None:
api = _FakeBilibiliApi()
provider = BilibiliTopCommentProvider(bilibili_api=api)
@ -263,8 +320,8 @@ class BilibiliTopCommentProviderTests(unittest.TestCase):
self.assertEqual(result["full"]["status"], "skipped")
self.assertEqual(result["full"]["reason"], "comment_disabled")
self.assertEqual(len(api.reply_calls), 1)
self.assertIn("P1:\n00:00:01 Song A\n00:02:00 Song B", api.reply_calls[0]["content"])
self.assertIn("P2:\n00:00:03 Song C", api.reply_calls[0]["content"])
self.assertIn("P1:\n1. 00:00:01 Song A\n2. 00:02:00 Song B", api.reply_calls[0]["content"])
self.assertIn("P2:\n3. 00:00:03 Song C", api.reply_calls[0]["content"])
def test_full_comment_skips_on_non_anchor_task(self) -> None:
api = _FakeBilibiliApi()