コミットを比較

..

2 コミット

作成者 SHA1 メッセージ 日付
みてるぞ 9fec1cf5f9 #1 2025-08-16 18:46:53 +09:00
みてるぞ cf6391d15c #1 2025-08-16 18:45:03 +09:00
2個のファイルの変更31行の追加1行の削除
+5 -1
ファイルの表示
@@ -1 +1,5 @@
from .module import VideoInfo, fetch_comments, fetch_embed_info, fetch_video_info
from .module import (VideoInfo,
fetch_comments,
fetch_embed_info,
fetch_latest_video,
fetch_video_info)
+26
ファイルの表示
@@ -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,