Files
archived-MoviePilot/tests/test_subtitle_links.py
2026-05-13 17:57:25 +08:00

46 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from lxml import etree
from app.modules.subtitle import SubtitleModule
def test_parse_subtitle_links_filters_detail_page_action_links():
html_text = """
<tr>
<td class="rowhead" valign="top">字幕</td>
<td class="rowfollow" align="left" valign="top">
<table border="0" cellspacing="0">
<tbody>
<tr>
<td class="embedded">
<img border="0" src="pic/flag/china.gif" alt="简体中文" title="简体中文">
</td>
<td class="embedded">
<a href="downloadsubs.php?torrentid=621182&amp;subid=2148">
<u>[雪飘+白恋] 光之美少女 All Stars NewStage未来的朋友</u>
</a>
</td>
</tr>
</tbody>
</table>
<form method="post" action="subtitles.php">
<a href="javascript:void(0)" onclick="this.closest(&quot;form&quot;).submit()">上传字幕</a>
</form>
<form method="get" action="http://shooter.cn/sub/" target="_blank">
<a href="javascript:void(0)" onclick="this.closest(&quot;form&quot;).submit()">搜索射手网</a>
</form>
<form method="get" action="https://www.opensubtitles.org/en/search2/" target="_blank">
<a href="javascript:void(0)" onclick="this.closest('form').submit()">搜索Opensubtitles</a>
</form>
</td>
</tr>
"""
html = etree.HTML(html_text)
links = SubtitleModule._parse_subtitle_links(
html, "https://audiences.me/details.php?id=599860&hit=1"
)
assert links == [
"https://audiences.me/downloadsubs.php?torrentid=621182&subid=2148"
]