修复
This commit is contained in:
@@ -73,49 +73,6 @@ class TestJuQuanQuanSpider(unittest.TestCase):
|
||||
self.assertEqual(len(result["list"]), 40)
|
||||
self.assertEqual(result["list"][0]["vod_id"], "vod/1")
|
||||
|
||||
@patch.object(Spider, "_request_html")
|
||||
def test_category_content_prefers_vodshow_page_result(self, mock_request_html):
|
||||
mock_request_html.return_value = """
|
||||
<a class="module-poster-item module-item" href="/vod/456.html">
|
||||
<div class="module-poster-item-title">分类影片</div>
|
||||
</a>
|
||||
"""
|
||||
result = self.spider.categoryContent("juji", "2", False, {})
|
||||
self.assertEqual(mock_request_html.call_args.args[0], "https://www.jqqzx.cc/vodshow/id/juji/page/2.html")
|
||||
self.assertEqual(result["page"], 2)
|
||||
self.assertNotIn("pagecount", result)
|
||||
self.assertEqual(result["list"][0]["vod_id"], "vod/456")
|
||||
|
||||
@patch.object(Spider, "_request_html")
|
||||
def test_category_content_falls_back_to_type_and_stops_retrying_vodshow(self, mock_request_html):
|
||||
mock_request_html.side_effect = [
|
||||
"<title>系统安全验证</title>",
|
||||
"""
|
||||
<a class="module-poster-item module-item" href="/vod/456.html">
|
||||
<div class="module-poster-item-title">分类影片</div>
|
||||
</a>
|
||||
""",
|
||||
"""
|
||||
<a class="module-poster-item module-item" href="/vod/789.html">
|
||||
<div class="module-poster-item-title">后续分类影片</div>
|
||||
</a>
|
||||
""",
|
||||
]
|
||||
|
||||
first_result = self.spider.categoryContent("juji", "2", False, {})
|
||||
second_result = self.spider.categoryContent("juji", "3", False, {})
|
||||
|
||||
self.assertEqual(
|
||||
mock_request_html.call_args_list,
|
||||
[
|
||||
call("https://www.jqqzx.cc/vodshow/id/juji/page/2.html"),
|
||||
call("https://www.jqqzx.cc/type/juji/page/2.html"),
|
||||
call("https://www.jqqzx.cc/type/juji/page/3.html"),
|
||||
],
|
||||
)
|
||||
self.assertEqual(first_result["list"][0]["vod_id"], "vod/456")
|
||||
self.assertEqual(second_result["list"][0]["vod_id"], "vod/789")
|
||||
|
||||
@patch.object(Spider, "_request_html")
|
||||
def test_search_content_uses_suggest_api(self, mock_request_html):
|
||||
mock_request_html.return_value = '{"list":[{"id":"777","name":"搜索结果","pic":"/pic.jpg"}]}'
|
||||
|
||||
+2
-2
@@ -232,7 +232,7 @@ class Spider(BaseSpider):
|
||||
videos = []
|
||||
for name in ("电影", "剧集", "综艺", "动漫"):
|
||||
videos.extend(self._get_class_list(name, 1, {"by": "hits"}).get("list", []))
|
||||
return {"page": 1, "limit": len(videos), "total": len(videos), "list": videos}
|
||||
return {"page": 1, "limit": len(videos), "total": int(pg) * 30 + len(videos), "list": videos}
|
||||
return self._get_class_list(type_name, int(pg), extend or {})
|
||||
|
||||
def detailContent(self, ids):
|
||||
@@ -474,7 +474,7 @@ class Spider(BaseSpider):
|
||||
},
|
||||
)
|
||||
items = self._convert_json_to_vods(payload.get("data") or [])
|
||||
return {"page": int(page), "limit": len(items), "total": len(items), "list": items}
|
||||
return {"page": int(page), "limit": len(items), "total": page * 30 + len(items), "list": items}
|
||||
|
||||
def _extract_decode_url(self, payload):
|
||||
if isinstance(payload, dict):
|
||||
|
||||
Reference in New Issue
Block a user