From 6f8d2ef4db3715aec8127a42dc598df2989d0508 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Thu, 5 Sep 2024 03:51:39 +0900 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=9D=80=E5=8B=95=E7=94=BB=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E7=94=A8=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/main.py b/main.py index 0bc0908..9873ddf 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,10 @@ from datetime import datetime, timedelta +import json import time import sys from atproto import Client, models +import requests from ai.talk import Talk import account @@ -109,5 +111,31 @@ def main () -> None: time.sleep (60) +def get_nico_deerjika (): + URL = ('https://snapshot.search.nicovideo.jp/api/v2/snapshot/video' + '/contents/search') + + now = datetime.now () + + params = { 'q': '伊地知ニジカ', + 'targets': 'tagsExact', + '_sort': '-startTime', + 'fields': 'contentId,title,description,tags,startTime', + '_limit': 1, + 'jsonFilter': json.dumps ({ 'type': 'or', + 'filters': [{ + 'type': 'range', + 'field': 'startTime', + 'from': ('%04d-%02d-%02dT00:00:00+09:00' + % (now.year, now.month, now.day)), + 'to': ('%04d-%02d-%02dT23:59:59+09:00' + % (now.year, now.month, now.day)), + 'include_lower': True }] }) } + + res = requests.get (URL, params = params).json () + + return res['data'][0] if len (res['data']) > 0 else None + + if __name__ == '__main__': main (*sys.argv[1:])