Browse Source

サムネ取得ミス修正

main
みてるぞ 1 week ago
parent
commit
4ebe43dd05
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      main.py

+ 8
- 3
main.py View File

@@ -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)



Loading…
Cancel
Save