このコミットが含まれているのは:
2025-08-16 18:45:03 +09:00
コミット cf6391d15c
+26
ファイルの表示
@@ -116,6 +116,32 @@ def fetch_embed_info (
return (title, description, thumbnail) 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 ( def _create_bs_from_url (
url: str, url: str,
params: dict | None = None, params: dict | None = None,