mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
fix(audiences): correctly filter unread messages by icon class and attributes
This commit is contained in:
@@ -42,6 +42,30 @@ class NexusAudiencesSiteUserInfo(NexusPhpSiteUserInfo):
|
|||||||
if html is not None:
|
if html is not None:
|
||||||
del html
|
del html
|
||||||
|
|
||||||
|
def _parse_message_unread_links(self, html_text: str, msg_links: list):
|
||||||
|
"""
|
||||||
|
解析 Audiences 未读消息链接。
|
||||||
|
"""
|
||||||
|
html = etree.HTML(html_text)
|
||||||
|
try:
|
||||||
|
if not StringUtils.is_valid_html_element(html):
|
||||||
|
return None
|
||||||
|
|
||||||
|
message_links = html.xpath(
|
||||||
|
'//tr[.//img[contains(concat(" ", normalize-space(@class), " "), " unreadpm ") '
|
||||||
|
'or @alt="Unread" or @title="未读"]]/td/a[contains(@href, "viewmessage")]/@href'
|
||||||
|
)
|
||||||
|
msg_links.extend(message_links)
|
||||||
|
next_page = None
|
||||||
|
next_page_text = html.xpath('//a[contains(.//text(), "下一页") or contains(.//text(), "下一頁")]/@href')
|
||||||
|
if next_page_text:
|
||||||
|
next_page = next_page_text[-1].strip()
|
||||||
|
finally:
|
||||||
|
if html is not None:
|
||||||
|
del html
|
||||||
|
|
||||||
|
return next_page
|
||||||
|
|
||||||
def _parse_user_traffic_info(self, html_text):
|
def _parse_user_traffic_info(self, html_text):
|
||||||
"""
|
"""
|
||||||
解析用户流量信息
|
解析用户流量信息
|
||||||
|
|||||||
@@ -120,6 +120,26 @@ def test_audiences_table_unread_links_ignore_content_rows():
|
|||||||
<td class="rowfollow" nowrap=""><span title="2026-05-07 23:01:58">8天17时前</span></td>
|
<td class="rowfollow" nowrap=""><span title="2026-05-07 23:01:58">8天17时前</span></td>
|
||||||
<td class="rowfollow"><input class="checkbox" type="checkbox" name="messages[]" value="4318000"></td>
|
<td class="rowfollow"><input class="checkbox" type="checkbox" name="messages[]" value="4318000"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="rowfollow" align="center">
|
||||||
|
<img class="readpm" src="pic/trans.gif" title="已读">
|
||||||
|
</td>
|
||||||
|
<td class="rowfollow" align="left">
|
||||||
|
<a href="messages.php?action=viewmessage&id=4317999">无英文 alt 的已读消息</a>
|
||||||
|
</td>
|
||||||
|
<td class="rowfollow" align="left">系统</td>
|
||||||
|
<td class="rowfollow" nowrap=""><span title="2026-05-07 23:01:58">8天17时前</span></td>
|
||||||
|
<td class="rowfollow"><input class="checkbox" type="checkbox" name="messages[]" value="4317999"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="rowfollow" align="center"></td>
|
||||||
|
<td class="rowfollow" align="left">
|
||||||
|
<a href="messages.php?action=viewmessage&id=4317998">无状态图标消息</a>
|
||||||
|
</td>
|
||||||
|
<td class="rowfollow" align="left">系统</td>
|
||||||
|
<td class="rowfollow" nowrap=""><span title="2026-05-07 23:01:58">8天17时前</span></td>
|
||||||
|
<td class="rowfollow"><input class="checkbox" type="checkbox" name="messages[]" value="4317998"></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -130,3 +150,34 @@ def test_audiences_table_unread_links_ignore_content_rows():
|
|||||||
|
|
||||||
assert msg_links == ["messages.php?action=viewmessage&id=4318225"]
|
assert msg_links == ["messages.php?action=viewmessage&id=4318225"]
|
||||||
assert next_page is None
|
assert next_page is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_audiences_readpm_row_is_not_unread_message():
|
||||||
|
parser = NexusAudiencesSiteUserInfo(
|
||||||
|
site_name="Audiences",
|
||||||
|
url="https://audiences.me/",
|
||||||
|
site_cookie="",
|
||||||
|
apikey=None,
|
||||||
|
token=None,
|
||||||
|
)
|
||||||
|
html_text = """
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="rowfollow" align="center">
|
||||||
|
<img class="readpm" src="pic/trans.gif" alt="Read" title="已读">
|
||||||
|
</td>
|
||||||
|
<td class="rowfollow" align="left">
|
||||||
|
<a href="messages.php?action=viewmessage&id=4318000">已读消息</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
msg_links = []
|
||||||
|
|
||||||
|
parser._parse_message_unread_links(html_text, msg_links)
|
||||||
|
|
||||||
|
assert msg_links == []
|
||||||
|
|||||||
Reference in New Issue
Block a user