低端影视.py
This commit is contained in:
@@ -172,6 +172,16 @@ class TestDDYSSpider(unittest.TestCase):
|
|||||||
self.assertIn("夸克查看$https://pan.quark.cn/s/abc123", vod["vod_play_url"])
|
self.assertIn("夸克查看$https://pan.quark.cn/s/abc123", vod["vod_play_url"])
|
||||||
self.assertIn("百度查看$https://pan.baidu.com/s/demo", vod["vod_play_url"])
|
self.assertIn("百度查看$https://pan.baidu.com/s/demo", vod["vod_play_url"])
|
||||||
|
|
||||||
|
def test_extract_pan_sources_deduplicates_same_link_with_different_labels(self):
|
||||||
|
html = """
|
||||||
|
<div class="download-type-content" id="download-type-quark">
|
||||||
|
<button onclick="trackAndOpenResource(atob('aHR0cHM6Ly9wYW4ucXVhcmsuY24vcy8xNGE0MDVhOWJiMGQ='))">查看</button>
|
||||||
|
<button onclick="trackAndOpenResource(atob('aHR0cHM6Ly9wYW4ucXVhcmsuY24vcy8xNGE0MDVhOWJiMGQ='))">一键复制</button>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
groups = self.spider._extract_pan_sources(html)
|
||||||
|
self.assertEqual(groups, [{"from": "quark", "urls": "查看$https://pan.quark.cn/s/14a405a9bb0d"}])
|
||||||
|
|
||||||
@patch.object(Spider, "_request_html")
|
@patch.object(Spider, "_request_html")
|
||||||
def test_detail_content_reads_detail_page_and_returns_single_vod(self, mock_request_html):
|
def test_detail_content_reads_detail_page_and_returns_single_vod(self, mock_request_html):
|
||||||
mock_request_html.return_value = """
|
mock_request_html.return_value = """
|
||||||
|
|||||||
+4
-2
@@ -274,6 +274,7 @@ class Spider(BaseSpider):
|
|||||||
if panel_id not in ("quark", "xunlei", "baidu"):
|
if panel_id not in ("quark", "xunlei", "baidu"):
|
||||||
continue
|
continue
|
||||||
entries = []
|
entries = []
|
||||||
|
seen_links = set()
|
||||||
for button in panel.xpath(".//button[@onclick]"):
|
for button in panel.xpath(".//button[@onclick]"):
|
||||||
onclick = (button.xpath("./@onclick") or [""])[0]
|
onclick = (button.xpath("./@onclick") or [""])[0]
|
||||||
matched = re.search(r"atob\('([^']+)'\)", onclick)
|
matched = re.search(r"atob\('([^']+)'\)", onclick)
|
||||||
@@ -284,10 +285,11 @@ class Spider(BaseSpider):
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
title = self._clean_text("".join(button.xpath(".//text()"))) or panel_id
|
title = self._clean_text("".join(button.xpath(".//text()"))) or panel_id
|
||||||
if link:
|
if link and link not in seen_links:
|
||||||
|
seen_links.add(link)
|
||||||
entries.append(f"{title}${link}")
|
entries.append(f"{title}${link}")
|
||||||
if entries:
|
if entries:
|
||||||
groups.append({"from": panel_id, "urls": "#".join(dict.fromkeys(entries))})
|
groups.append({"from": panel_id, "urls": "#".join(entries)})
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
def _parse_detail_page(self, html, vod_id):
|
def _parse_detail_page(self, html, vod_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user