サムネ取得ミス修正

このコミットが含まれているのは:
2024-09-07 07:25:52 +09:00
コミット 4ebe43dd05
+8 -3
ファイルの表示
@@ -95,13 +95,14 @@ def main (
uri = f"https://www.nicovideo.jp/watch/{ datum['contentId'] }" uri = f"https://www.nicovideo.jp/watch/{ datum['contentId'] }"
(title, description, thumbnail) = get_embed_info (uri) (title, description, thumbnail) = get_embed_info (uri)
upload = client.com.atproto.repo.upload_blob (
io.BytesIO (requests.get (thumbnail).content))
embed_external = models.AppBskyEmbedExternal.Main ( embed_external = models.AppBskyEmbedExternal.Main (
external = models.AppBskyEmbedExternal.External ( external = models.AppBskyEmbedExternal.External (
title = title, title = title,
description = description, description = description,
thumb = client.com.atproto.repo.upload_blob ( thumb = upload.blob,
io.BytesIO (requests.get (thumbnail).content)),
uri = uri)) uri = uri))
client.post (Talk.main (f""" client.post (Talk.main (f"""
ニコニコに『{ datum['title'] }』という動画がアップされました。 ニコニコに『{ datum['title'] }』という動画がアップされました。
@@ -185,6 +186,10 @@ def get_nico_deerjika ():
def get_embed_info ( def get_embed_info (
url: str url: str
) -> (str, str, str): ) -> (str, str, str):
title: str = ''
description: str = ''
thumbnail: str = ''
try: try:
res = requests.get (url, timeout = 60) res = requests.get (url, timeout = 60)
except Exception: except Exception:
@@ -205,7 +210,7 @@ def get_embed_info (
tmp = soup.find ('meta', attrs = { 'name': 'thumbnail' }) tmp = soup.find ('meta', attrs = { 'name': 'thumbnail' })
if tmp is not None: if tmp is not None:
thumbnail = tmp.get (' content') thumbnail = tmp.get ('content')
return (title, description, thumbnail) return (title, description, thumbnail)