feat: complete shuangxing spider
This commit is contained in:
@@ -109,6 +109,63 @@ class TestShuangXingSpider(unittest.TestCase):
|
||||
def test_search_content_short_circuits_blank_keyword(self):
|
||||
self.assertEqual(self.spider.searchContent("", False, "1"), {"page": 1, "total": 0, "list": []})
|
||||
|
||||
@patch.object(Spider, "_get_html")
|
||||
def test_detail_content_extracts_title_and_sorted_deduplicated_pan_lines(self, mock_get_html):
|
||||
mock_get_html.return_value = """
|
||||
<body>
|
||||
<div>
|
||||
<div class="s20erx erx-m-bot erx-content">
|
||||
<main><article><h1>双星示例</h1></article></main>
|
||||
</div>
|
||||
</div>
|
||||
<div id="maximg">
|
||||
<div class="dlipp-cont-wp"><div><div class="dlipp-cont-bd">
|
||||
<a href="https://pan.baidu.com/s/b-demo"></a>
|
||||
<a href="https://pan.quark.cn/s/q-demo"></a>
|
||||
<a href="https://pan.baidu.com/s/b-demo"></a>
|
||||
<a href="https://example.com/ignored"></a>
|
||||
</div></div></div>
|
||||
</div>
|
||||
</body>
|
||||
"""
|
||||
result = self.spider.detailContent(["/post/demo"])
|
||||
self.assertEqual(mock_get_html.call_args.args[0], "https://1.star2.cn/post/demo")
|
||||
self.assertEqual(
|
||||
result,
|
||||
{
|
||||
"list": [
|
||||
{
|
||||
"vod_id": "/post/demo",
|
||||
"vod_name": "双星示例",
|
||||
"vod_pic": "",
|
||||
"vod_remarks": "",
|
||||
"vod_content": "",
|
||||
"vod_director": "",
|
||||
"vod_actor": "",
|
||||
"vod_play_from": "quark$$$baidu",
|
||||
"vod_play_url": "夸克资源$https://pan.quark.cn/s/q-demo$$$百度资源$https://pan.baidu.com/s/b-demo",
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
@patch.object(Spider, "_get_html")
|
||||
def test_detail_content_returns_empty_list_for_blank_html(self, mock_get_html):
|
||||
mock_get_html.return_value = ""
|
||||
self.assertEqual(self.spider.detailContent(["/post/missing"]), {"list": []})
|
||||
|
||||
def test_player_content_passthroughs_supported_pan_links(self):
|
||||
self.assertEqual(
|
||||
self.spider.playerContent("quark", "https://pan.quark.cn/s/demo", {}),
|
||||
{"parse": 0, "playUrl": "", "url": "https://pan.quark.cn/s/demo"},
|
||||
)
|
||||
|
||||
def test_player_content_rejects_unknown_links(self):
|
||||
self.assertEqual(
|
||||
self.spider.playerContent("site", "https://example.com/video", {}),
|
||||
{"parse": 0, "playUrl": "", "url": ""},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user