From 4ebe43dd05c1623ef0377553f1499fced668d8a3 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sat, 7 Sep 2024 07:25:52 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=83=A0=E3=83=8D=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=83=9F=E3=82=B9=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index da16e3f..d6f8a94 100644 --- a/main.py +++ b/main.py @@ -95,13 +95,14 @@ def main ( uri = f"https://www.nicovideo.jp/watch/{ datum['contentId'] }" (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 ( external = models.AppBskyEmbedExternal.External ( title = title, description = description, - thumb = client.com.atproto.repo.upload_blob ( - io.BytesIO (requests.get (thumbnail).content)), + thumb = upload.blob, uri = uri)) client.post (Talk.main (f""" ニコニコに『{ datum['title'] }』という動画がアップされました。 @@ -185,6 +186,10 @@ def get_nico_deerjika (): def get_embed_info ( url: str ) -> (str, str, str): + title: str = '' + description: str = '' + thumbnail: str = '' + try: res = requests.get (url, timeout = 60) except Exception: @@ -205,7 +210,7 @@ def get_embed_info ( tmp = soup.find ('meta', attrs = { 'name': 'thumbnail' }) if tmp is not None: - thumbnail = tmp.get (' content') + thumbnail = tmp.get ('content') return (title, description, thumbnail)