|
|
@@ -71,7 +71,8 @@ def main ( |
|
|
|
client.login (account.USER_ID, account.PASSWORD) |
|
|
|
|
|
|
|
got_kiriban_at: date = datetime.now ().date () - timedelta (days = datetime.now ().hour < 15) |
|
|
|
kiriban_list: list[tuple[int, nico.VideoInfo]] = nico.get_kiriban_list (got_kiriban_at) |
|
|
|
kiriban_list: list[tuple[int, nico.VideoInfo, datetime]] = ( |
|
|
|
nico.get_kiriban_list (got_kiriban_at)) |
|
|
|
kiriban_interval: timedelta = ((get_kiriban_dt_to_update () - datetime.now ()) |
|
|
|
/ len (kiriban_list)) |
|
|
|
next_kiriban_at = datetime.now () |
|
|
@@ -109,8 +110,9 @@ def main ( |
|
|
|
root = records[-1]['strong_ref'])) |
|
|
|
|
|
|
|
if kiriban_list and datetime.now () >= next_kiriban_at: |
|
|
|
(views_count, video_info) = ( |
|
|
|
(views_count, video_info, uploaded_at) = ( |
|
|
|
kiriban_list.pop (random.randint (0, len (kiriban_list) - 1))) |
|
|
|
since_posted = datetime.now () - uploaded_at |
|
|
|
uri = f"https://www.nicovideo.jp/watch/{ video_info['contentId'] }" |
|
|
|
(title, description, thumbnail) = get_embed_info (uri) |
|
|
|
try: |
|
|
@@ -120,21 +122,33 @@ def main ( |
|
|
|
thumb = upload.blob |
|
|
|
except Timeout: |
|
|
|
thumb = None |
|
|
|
comments = nico.get_comments (video_info['contentId']) |
|
|
|
popular_comments = sorted (comments, |
|
|
|
key = lambda c: c.nico_count, |
|
|
|
reverse = True)[:10] |
|
|
|
latest_comments = sorted (comments, |
|
|
|
key = lambda c: c.posted_at, |
|
|
|
reverse = True)[:10] |
|
|
|
embed_external = models.AppBskyEmbedExternal.Main ( |
|
|
|
external = models.AppBskyEmbedExternal.External ( |
|
|
|
title = title, |
|
|
|
description = description, |
|
|
|
thumb = thumb, |
|
|
|
uri = uri)) |
|
|
|
client.post (Talk.main (f""" |
|
|
|
ニコニコの『{ video_info['title'] }』という動画が{ views_count }再生を突破しました。 |
|
|
|
つけられたタグは「{ '」、「'.join (video_info['tags']) }」です。 |
|
|
|
prompt = f"{ since_posted.days }日と{ since_posted.seconds }秒前にニコニコに投稿された『{ video_info['title'] }』という動画が{ views_count }再生を突破しました。\n" |
|
|
|
if video_info['tags']: |
|
|
|
prompt += f"つけられたタグは「{ '」、「'.join (video_info['tags']) }」です。\n" |
|
|
|
if comments: |
|
|
|
prompt += f"人気のコメントは次の通りです:「{ '」、「'.join (c.content for c in popular_comments) }」\n" |
|
|
|
prompt += f"最新のコメントは次の通りです:「{ '」、「'.join (c.content for c in latest_comments) }」\n" |
|
|
|
prompt += f""" |
|
|
|
概要には次のように書かれています: |
|
|
|
```html |
|
|
|
{ video_info['description'] } |
|
|
|
``` |
|
|
|
このことについて、ニジカちゃんからのお祝いメッセージを下さい。"""), |
|
|
|
embed = embed_external) |
|
|
|
このことについて、ニジカちゃんからのお祝いメッセージを下さい。 |
|
|
|
ただし、そのメッセージ内には再生数の数値とその多さに応じたリアクション(「すっご~い!」や「しょぼ~い」など)を添えてください。""" |
|
|
|
client.post (Talk.main (prompt), embed = embed_external) |
|
|
|
next_kiriban_at += kiriban_interval |
|
|
|
last_posted_at = now |
|
|
|
|
|
|
|