diff --git a/src/api/models.py b/src/api/models.py index 58abc40..e98df8c 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -95,6 +95,12 @@ class HoYoPostVideo(BaseModel): def is_youtube(self) -> bool: return "www.youtube.com" in self.url + @property + def html(self) -> str: + if self.is_youtube: + return f'\n' + return f'\n' + class HoYoPostMultiLang(BaseModel): lang_subject: dict diff --git a/src/data/bg.json b/src/data/bg.json index d7e0309..def0dd1 100644 --- a/src/data/bg.json +++ b/src/data/bg.json @@ -35,9 +35,9 @@ { "id": "4", "icon": "https://hyl-static-res-prod.hoyolab.com/communityweb/business/nxx_hoyoverse.png", - "bg": "https://upload-os-bbs.hoyolab.com/upload/2023/10/24/d97b3eb5763dba18bc137929ce53ba24_8118580296436267822.png", + "bg": "https://upload-os-bbs.hoyolab.com/upload/2024/07/12/6884e4a2d1200dac51ac55391b377a74_8800404318031699849.png?x-oss-process=image/auto-orient,0/interlace,1/format,webp/quality,q_70", "name": "未定事件簿", - "bg_color": "#2E3857", + "bg_color": "#1D1D1F", "focus_channel_id": "0" }, { diff --git a/src/render/article_hoyolab.py b/src/render/article_hoyolab.py index 89ffba9..09fcfb5 100644 --- a/src/render/article_hoyolab.py +++ b/src/render/article_hoyolab.py @@ -42,8 +42,8 @@ async def process_article_video( json_data = json.loads(post_info.content) description = json_data.get("describe", "") article = "" - if post_info.video and post_info.video.is_youtube: - article += f'\n' + if post_info.video: + article += post_info.video.html if description: article += f"

{description}

\n" return template.render( diff --git a/tests/test_hoyolab_article.py b/tests/test_hoyolab_article.py index f259c84..0d1a1c0 100644 --- a/tests/test_hoyolab_article.py +++ b/tests/test_hoyolab_article.py @@ -42,7 +42,7 @@ class TestHoyolabArticle: assert "The people of Liyue love drinking tea." in content @staticmethod - async def test_get_hoyo_video_article(): + async def test_get_hoyo_youtube_video_article(): content = await process_article(21124034, "zh-cn") assert content is not None assert "《原神》「流光拾遗之旅」——仙闻篇·龙泉青瓷" in content @@ -50,9 +50,17 @@ class TestHoyolabArticle: assert "璃月人爱喝茶,用青色茶盏盛一碗茶汤,茶香似乎都变得更悠长。" in content @staticmethod - async def test_get_hoyo_big_video_article(): + async def test_get_hoyo_big_youtube_video_article(): content = await process_article(17958970, "zh-cn") assert content is not None assert "Spiral-Abyss-3.6 甘雨暴风雪 & 融甘视频 (面板置放2和3楼)" in content assert "0jVRnQHwQ_g" in content assert "这次的都是用加HP%加充能和E技能伤害没和伤害直接挂钩的buff" in content + + @staticmethod + async def test_get_hoyo_big_video_article(): + content = await process_article(31107135, "zh-cn") + assert content is not None + assert "Voice Actor Reveal: Belle" in content + assert "141812841564491837440_1080p" in content + assert "Good luck, guys. Let's get started." in content