summaryrefslogtreecommitdiff
path: root/AyaBot/plugins/bilibilitest
diff options
context:
space:
mode:
Diffstat (limited to 'AyaBot/plugins/bilibilitest')
-rw-r--r--AyaBot/plugins/bilibilitest/__init__.py5
-rw-r--r--AyaBot/plugins/bilibilitest/__pycache__/__init__.cpython-37.pycbin259 -> 0 bytes
-rw-r--r--AyaBot/plugins/bilibilitest/__pycache__/index.cpython-37.pycbin3333 -> 0 bytes
-rw-r--r--AyaBot/plugins/bilibilitest/aio/__init__.py8
-rw-r--r--AyaBot/plugins/bilibilitest/aio/__pycache__/__init__.cpython-37.pycbin445 -> 0 bytes
-rw-r--r--AyaBot/plugins/bilibilitest/aio/requests.py71
-rw-r--r--AyaBot/plugins/bilibilitest/index.py91
7 files changed, 0 insertions, 175 deletions
diff --git a/AyaBot/plugins/bilibilitest/__init__.py b/AyaBot/plugins/bilibilitest/__init__.py
deleted file mode 100644
index 05f2855..0000000
--- a/AyaBot/plugins/bilibilitest/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from nonebot import CommandGroup
-
-__plugin_name__ = 'BiliBili搜番'
-
-from . import index \ No newline at end of file
diff --git a/AyaBot/plugins/bilibilitest/__pycache__/__init__.cpython-37.pyc b/AyaBot/plugins/bilibilitest/__pycache__/__init__.cpython-37.pyc
deleted file mode 100644
index d409765..0000000
--- a/AyaBot/plugins/bilibilitest/__pycache__/__init__.cpython-37.pyc
+++ /dev/null
Binary files differ
diff --git a/AyaBot/plugins/bilibilitest/__pycache__/index.cpython-37.pyc b/AyaBot/plugins/bilibilitest/__pycache__/index.cpython-37.pyc
deleted file mode 100644
index 6ba7b16..0000000
--- a/AyaBot/plugins/bilibilitest/__pycache__/index.cpython-37.pyc
+++ /dev/null
Binary files differ
diff --git a/AyaBot/plugins/bilibilitest/aio/__init__.py b/AyaBot/plugins/bilibilitest/aio/__init__.py
deleted file mode 100644
index 3cc81f0..0000000
--- a/AyaBot/plugins/bilibilitest/aio/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import asyncio
-from functools import partial
-from typing import Any
-
-
-async def run_sync_func(func, *args, **kwargs) -> Any:
- return await asyncio.get_event_loop().run_in_executor(
- None, partial(func, *args, **kwargs))
diff --git a/AyaBot/plugins/bilibilitest/aio/__pycache__/__init__.cpython-37.pyc b/AyaBot/plugins/bilibilitest/aio/__pycache__/__init__.cpython-37.pyc
deleted file mode 100644
index b379548..0000000
--- a/AyaBot/plugins/bilibilitest/aio/__pycache__/__init__.cpython-37.pyc
+++ /dev/null
Binary files differ
diff --git a/AyaBot/plugins/bilibilitest/aio/requests.py b/AyaBot/plugins/bilibilitest/aio/requests.py
deleted file mode 100644
index 4f7b9d3..0000000
--- a/AyaBot/plugins/bilibilitest/aio/requests.py
+++ /dev/null
@@ -1,71 +0,0 @@
-from typing import Optional, Any
-
-import requests
-from requests import *
-
-from . import run_sync_func
-
-
-class AsyncResponse:
- def __init__(self, response: requests.Response):
- self.raw_response = response
-
- @property
- def ok(self) -> bool:
- return self.raw_response.ok
-
- def __repr__(self):
- return '<AsyncResponse [%s]>' % self.raw_response.status_code
-
- def __bool__(self):
- return self.ok
-
- @property
- async def content(self) -> Optional[bytes]:
- return await run_sync_func(lambda: self.raw_response.content)
-
- @property
- async def text(self) -> str:
- return await run_sync_func(lambda: self.raw_response.text)
-
- async def json(self, **kwargs) -> Any:
- return await run_sync_func(self.raw_response.json, **kwargs)
-
-
-async def request(method, url, **kwargs) -> AsyncResponse:
- return AsyncResponse(await run_sync_func(requests.request,
- method=method, url=url, **kwargs))
-
-
-async def get(url, params=None, **kwargs) -> AsyncResponse:
- return AsyncResponse(
- await run_sync_func(requests.get, url=url, params=params, **kwargs))
-
-
-async def options(url, **kwargs) -> AsyncResponse:
- return AsyncResponse(
- await run_sync_func(requests.options, url=url, **kwargs))
-
-
-async def head(url, **kwargs) -> AsyncResponse:
- return AsyncResponse(await run_sync_func(requests.head, url=url, **kwargs))
-
-
-async def post(url, data=None, json=None, **kwargs) -> AsyncResponse:
- return AsyncResponse(await run_sync_func(requests.post, url=url,
- data=data, json=json, **kwargs))
-
-
-async def put(url, data=None, **kwargs) -> AsyncResponse:
- return AsyncResponse(
- await run_sync_func(requests.put, url=url, data=data, **kwargs))
-
-
-async def patch(url, data=None, **kwargs) -> AsyncResponse:
- return AsyncResponse(
- await run_sync_func(requests.patch, url=url, data=data, **kwargs))
-
-
-async def delete(url, **kwargs) -> AsyncResponse:
- return AsyncResponse(
- await run_sync_func(requests.delete, url=url, **kwargs))
diff --git a/AyaBot/plugins/bilibilitest/index.py b/AyaBot/plugins/bilibilitest/index.py
deleted file mode 100644
index 144ff7e..0000000
--- a/AyaBot/plugins/bilibilitest/index.py
+++ /dev/null
@@ -1,91 +0,0 @@
-import math
-import re
-import requests
-from typing import Optional, List, Any, Dict
-from nonebot import CommandSession, CommandGroup
-from aiocache import cached
-
-from datetime import datetime
-import pytz
-from pandas import Timestamp
-
-# from .aio import *
-
-#get TIME
-CST = 'Asia/Shanghai'
-
-def beijing_time_now(freq: Optional[str] = None) -> datetime:
- now = datetime.now(pytz.timezone(CST))
- if freq is not None:
- now = Timestamp(now).round(freq)
- return now
-
-
-def beijing_from_timestamp(timestamp: int) -> datetime:
- return datetime.fromtimestamp(timestamp, pytz.timezone(CST))
-
-
-
-cg = CommandGroup('bilibili_anime')
-
-API_URL = 'https://bangumi.bilibili.com/media/web_api/search/result?season_version=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month={month}&pub_date={year}&style_id=-1&order=3&st=1&sort=0&page=1&season_type=1&pagesize=20'
-WEB_URL = 'https://www.bilibili.com/anime/index/#season_version=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month={month}&pub_date={year}&style_id=-1&order=3&st=1&sort=0&page=1'
-
-
-@cached(ttl= 5 * 60)
-async def get_anime_list(year: int, month: int) -> Optional[List[Dict[str, Any]]]:
- api_url = API_URL.format(year=year, month=month)
- res = await requests.get(api_url)
- payload = await res.json()
-
- if not payload or payload.get('code') != 0:
- return None
-
- return payload['result']['data']
-
-
[email protected]('fan', aliases=['新番', '番剧索引', '番剧'], only_to_me=False)
-async def fan(session: CommandSession):
- now = beijing_time_now()
- year = session.state.get('year', now.year)
- month = session.state.get('month', now.month)
- month = math.ceil(month / 3) * 3 - 3 + 1
-
- anime_list = await get_anime_list(year, month)
- if not anime_list:
- session.finish('并没有找到相关的番剧...再试一次..?')
-
- reply = f'{year}/{month}番剧\n按照热度进行排序,前20部如下: \n'
- for anime in anime_list:
- title = anime.get('title')
- index_show = anime.get('index_show', 'Error')
- if not title:
- continue
- reply += f'{title} {index_show}\n'
-
- web_url = WEB_URL.format(year=year, month=month)
- reply += f'\n详细请见官网 {web_url}'
- session.finish(reply)
-
-
-async def _(session: CommandSession):
- arg = session.current_arg_text.split()
-
- year = None
- month = None
- if len(arg) == 2 and re.fullmatch(r'(?:20)?\d{2}', arg[0]) and re.fullmatch(r'\d{1,2}', arg[1]):
- year = int(arg[0]) if len(arg[0]) > 2 else 2000 + int (arg[0])
- month = int(arg[1])
- elif len(arg) == 1 and re.fullmatch(r'\d{1,2}', arg[0]):
- month = int(arg[0])
- elif len(arg) == 1 and re.fullmatch(r'(?:20)?\d{2}-\d{1,2}', arg[0]):
- year, month = [int(x) for x in arg[0].split('-')]
- year = 2000 + year if year < 1000 else year
- elif len(arg):
- await session.send('脑子变奇怪了...无法识别master的信息,先给份本季的番8...')
-
- if year is not None:
- session.state['year'] = year
- if month is not None:
- session.state['month'] = month \ No newline at end of file