mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-01 21:07:01 +08:00
refactor(types): govern hddolby site parser
This commit is contained in:
@@ -3,12 +3,13 @@ import json
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from app.domain import site as site_rules
|
||||
from app.modules.indexer.parser import SiteParserBase, SiteSchema
|
||||
from app.modules.indexer.parser import SitePage, SiteParserBase, SiteSchema
|
||||
from app.modules.indexer.parser.nexus_php import NexusPhpSiteUserInfo
|
||||
from app.runtime.log import logger
|
||||
|
||||
|
||||
class HDDolbySiteUserInfo(SiteParserBase):
|
||||
"""解析 HDDolby 站点的用户资料、流量与消息。"""
|
||||
schema = SiteSchema.HDDolby
|
||||
request_mode = "apikey"
|
||||
|
||||
@@ -39,7 +40,7 @@ class HDDolbySiteUserInfo(SiteParserBase):
|
||||
"22": "Staff Leader",
|
||||
}
|
||||
|
||||
def _parse_site_page(self, html_text: str):
|
||||
def _parse_site_page(self, html_text: SitePage) -> None:
|
||||
"""
|
||||
获取站点页面地址
|
||||
"""
|
||||
@@ -66,7 +67,7 @@ class HDDolbySiteUserInfo(SiteParserBase):
|
||||
"x-api-key": self.apikey,
|
||||
}
|
||||
|
||||
def _parse_logged_in(self, html_text):
|
||||
def _parse_logged_in(self, html_text: str) -> bool:
|
||||
"""
|
||||
判断是否登录成功, 通过判断是否存在用户信息
|
||||
暂时跳过检测,待后续优化
|
||||
@@ -75,12 +76,14 @@ class HDDolbySiteUserInfo(SiteParserBase):
|
||||
"""
|
||||
return True
|
||||
|
||||
def _parse_user_base_info(self, html_text: str):
|
||||
def _parse_user_base_info(self, html_text: SitePage) -> None:
|
||||
"""
|
||||
解析用户基本信息,这里把_parse_user_traffic_info和_parse_user_detail_info合并到这里
|
||||
"""
|
||||
if not html_text:
|
||||
return None
|
||||
if isinstance(html_text, dict):
|
||||
raise TypeError("the JSON object must be str, bytes or bytearray, not dict")
|
||||
detail = json.loads(html_text)
|
||||
if not detail or detail.get("status") != 0:
|
||||
return
|
||||
@@ -111,13 +114,13 @@ class HDDolbySiteUserInfo(SiteParserBase):
|
||||
self.bonus = float(user_info.get("seedbonus") or "0")
|
||||
self.message_unread = int(user_info.get("unread_messages") or '0')
|
||||
|
||||
def _parse_user_traffic_info(self, html_text: str):
|
||||
def _parse_user_traffic_info(self, html_text: str) -> None:
|
||||
"""
|
||||
解析用户流量信息
|
||||
"""
|
||||
pass
|
||||
|
||||
def _parse_user_detail_info(self, html_text: str):
|
||||
def _parse_user_detail_info(self, html_text: str) -> None:
|
||||
"""
|
||||
解析用户详细信息
|
||||
"""
|
||||
@@ -146,21 +149,21 @@ class HDDolbySiteUserInfo(SiteParserBase):
|
||||
|
||||
return None
|
||||
|
||||
def _parse_message_unread_links(self, html_text: str, msg_links: list) -> Optional[str]:
|
||||
def _parse_message_unread_links(self, html_text: str, msg_links: list[str]) -> Optional[str]:
|
||||
"""
|
||||
解析未读消息链接
|
||||
HDDolby 使用 API 模式,消息正文通过 _pase_unread_msgs 走网页接口读取。
|
||||
"""
|
||||
return None
|
||||
|
||||
def _parse_message_content(self, html_text) -> Tuple[Optional[str], Optional[str], Optional[str]]:
|
||||
def _parse_message_content(self, html_text: str) -> Tuple[Optional[str], Optional[str], Optional[str]]:
|
||||
"""
|
||||
解析消息内容
|
||||
HDDolby 使用 API 模式,消息正文通过 _pase_unread_msgs 走网页接口读取。
|
||||
"""
|
||||
return None, None, None
|
||||
|
||||
def _pase_unread_msgs(self):
|
||||
def _pase_unread_msgs(self) -> None:
|
||||
"""
|
||||
HDDolby API 仅返回未读消息数量,正文需通过 NexusPHP 网页接口读取。
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user