Browse Source

新着動画取得用函数

main
みてるぞ 2 weeks ago
parent
commit
6f8d2ef4db
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      main.py

+ 28
- 0
main.py View File

@@ -1,8 +1,10 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
import json
import time import time
import sys import sys


from atproto import Client, models from atproto import Client, models
import requests


from ai.talk import Talk from ai.talk import Talk
import account import account
@@ -109,5 +111,31 @@ def main () -> None:
time.sleep (60) 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__': if __name__ == '__main__':
main (*sys.argv[1:]) main (*sys.argv[1:])

Loading…
Cancel
Save