新着動画取得用函数
このコミットが含まれているのは:
@@ -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:])
|
||||
|
||||
新しい課題から参照
ユーザをブロックする