diff --git a/py/tests/test_低端影视.py b/py/tests/test_低端影视.py index 87e3eb4..7ceddca 100644 --- a/py/tests/test_低端影视.py +++ b/py/tests/test_低端影视.py @@ -172,6 +172,16 @@ class TestDDYSSpider(unittest.TestCase): self.assertIn("夸克查看$https://pan.quark.cn/s/abc123", 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 = """ +
+ + +
+ """ + groups = self.spider._extract_pan_sources(html) + self.assertEqual(groups, [{"from": "quark", "urls": "查看$https://pan.quark.cn/s/14a405a9bb0d"}]) + @patch.object(Spider, "_request_html") def test_detail_content_reads_detail_page_and_returns_single_vod(self, mock_request_html): mock_request_html.return_value = """ diff --git a/py/低端影视.py b/py/低端影视.py index f8351a5..56994f3 100644 --- a/py/低端影视.py +++ b/py/低端影视.py @@ -274,6 +274,7 @@ class Spider(BaseSpider): if panel_id not in ("quark", "xunlei", "baidu"): continue entries = [] + seen_links = set() for button in panel.xpath(".//button[@onclick]"): onclick = (button.xpath("./@onclick") or [""])[0] matched = re.search(r"atob\('([^']+)'\)", onclick) @@ -284,10 +285,11 @@ class Spider(BaseSpider): except Exception: continue 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}") if entries: - groups.append({"from": panel_id, "urls": "#".join(dict.fromkeys(entries))}) + groups.append({"from": panel_id, "urls": "#".join(entries)}) return groups def _parse_detail_page(self, html, vod_id):