add monster-siren

This commit is contained in:
felinae98
2021-04-08 12:33:29 +08:00
parent 4f82ae2518
commit 83178261d5
4 changed files with 42 additions and 1 deletions
@@ -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)
@@ -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(),
}