From cf6391d15cb546e4b897462f5b8783549fbaad8b Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sat, 16 Aug 2025 18:45:03 +0900 Subject: [PATCH] #1 --- module.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/module.py b/module.py index 9a9dd70..d52e481 100644 --- a/module.py +++ b/module.py @@ -116,6 +116,32 @@ def fetch_embed_info ( return (title, description, thumbnail) +def fetch_latest_video ( + tags: list[str], +) -> VideoInfo | None: + tag = ' OR '.join (tags) + url = f"https://www.nicovideo.jp/tag/{ tag }" + + params = { 'sort': 'f', + 'order': 'd' } + + video_info = { } + + bs = _create_bs_from_url (url, params) + if bs is None: + return None + + try: + video = (bs.find_all ('ul', class_ = 'videoListInner')[1] + .find ('li', class_ = 'item')) + + video_info['contentId'] = video['data-video-id'] + except Exception: + return None + + return fetch_video_info (video_info['contentId']) + + def _create_bs_from_url ( url: str, params: dict | None = None,