add monster-siren

This commit is contained in:
felinae98 2021-04-08 12:33:29 +08:00
parent 4f82ae2518
commit 83178261d5
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
4 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,35 @@
from typing import Any
import httpx
import json
from .platform import PlatformNoTarget
from ..utils import Singleton
from ..types import RawPost
from ..post import Post
class MonsterSiren(PlatformNoTarget):
categories = {}
platform_name = 'monster-siren'
enable_tag = False
@staticmethod
async def get_account_name(_) -> str:
return '塞壬唱片新闻'
async def get_sub_list(self) -> list[RawPost]:
async with httpx.AsyncClient() as client:
raw_data = await client.get('https://monster-siren.hypergryph.com/api/news')
return raw_data.json()['data']['list']
def get_id(self, post: RawPost) -> Any:
return post['cid']
def get_date(self, _) -> None:
return None
async def parse(self, raw_post: RawPost) -> Post:
url = f'https://monster-siren.hypergryph.com/info/{raw_post["cid"]}'
return Post('monster-siren', text=raw_post['title'],
url=url, target_name="塞壬唱片新闻", compress=True,
override_use_pic=False)

View File

@ -5,6 +5,7 @@ from typing import Type
from .arknights import Arknights
from .weibo import Weibo
from .bilibili import Bilibili
from .monster_siren import MonsterSiren
from .rss import Rss
from .wechat import Wechat
from .platform import PlatformProto
@ -20,6 +21,7 @@ platform_manager: dict[str, PlatformProto] = {
'weibo': Weibo(),
'rss': Rss(),
'arknights': Arknights(),
'monster-siren': MonsterSiren(),
# 'wechat': Wechat(),
}

View File

@ -22,6 +22,10 @@ async def rss_check():
async def arknights_check():
await fetch_and_send('arknights')
@scheduler.scheduled_job('interval', seconds=30)
async def monster_siren_check():
await fetch_and_send('monster-siren')
# @scheduler.scheduled_job('interval', seconds=30)
# async def wechat_check():
# await fetch_and_send('wechat')

View File

@ -21,7 +21,7 @@ class Singleton(type):
return cls._instances[cls]
# supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights', 'wechat')
supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights')
supported_target_type = ('weibo', 'bilibili', 'rss', 'arknights', 'monster-siren')
if not plugin_config.hk_reporter_use_local and not check_chromium():
os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'