mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-02 21:34:32 +08:00
refactor(types): govern tnode site parser
This commit is contained in:
@@ -4,7 +4,7 @@ import re
|
||||
from typing import Optional
|
||||
|
||||
from app.foundation import temporal as time_tools
|
||||
from app.modules.indexer.parser import SiteParserBase, SiteSchema
|
||||
from app.modules.indexer.parser import SitePage, SiteParserBase, SiteSchema
|
||||
from app.runtime.log import logger
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class TNodeSiteUserInfo(SiteParserBase):
|
||||
|
||||
schema = SiteSchema.TNode
|
||||
|
||||
def _parse_site_page(self, html_text: str):
|
||||
def _parse_site_page(self, html_text: SitePage) -> None:
|
||||
"""提取 CSRF 令牌,并配置用于取得用户 ID 的当前会话接口。"""
|
||||
html_text = self._prepare_html_text(html_text)
|
||||
|
||||
@@ -26,7 +26,7 @@ class TNodeSiteUserInfo(SiteParserBase):
|
||||
self._user_detail_requires_userid = False
|
||||
self._torrent_seeding_page = "api/user/listTorrentActivity?id=&type=seeding&page=1&size=20000"
|
||||
|
||||
def _parse_logged_in(self, html_text):
|
||||
def _parse_logged_in(self, html_text: str) -> bool:
|
||||
"""
|
||||
判断是否登录成功, 通过判断是否存在用户信息
|
||||
暂时跳过检测,待后续优化
|
||||
@@ -35,15 +35,15 @@ class TNodeSiteUserInfo(SiteParserBase):
|
||||
"""
|
||||
return True
|
||||
|
||||
def _parse_user_base_info(self, html_text: str):
|
||||
def _parse_user_base_info(self, html_text: SitePage) -> None:
|
||||
"""首页不提供用户 ID,身份信息需在详情接口返回后补齐。"""
|
||||
self.username = self.userid
|
||||
|
||||
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:
|
||||
"""从当前用户接口一次解析身份、资料、流量及未读消息数量。"""
|
||||
try:
|
||||
detail = json.loads(html_text)
|
||||
@@ -105,11 +105,11 @@ class TNodeSiteUserInfo(SiteParserBase):
|
||||
|
||||
return next_page
|
||||
|
||||
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]:
|
||||
"""当前仅支持 API 返回的未读数量,不解析消息链接。"""
|
||||
return None
|
||||
|
||||
def _parse_message_content(self, html_text):
|
||||
def _parse_message_content(self, html_text: str) -> tuple[Optional[str], Optional[str], Optional[str]]:
|
||||
"""
|
||||
系统信息 api/message/listSystem?page=1&size=20
|
||||
收件箱信息 api/message/listInbox?page=1&size=20
|
||||
|
||||
Reference in New Issue
Block a user