From 378acc90cbcb95750075fff247f0b6b0764fa077 Mon Sep 17 00:00:00 2001 From: Estrella Pan Date: Tue, 7 Jul 2026 10:19:26 +0200 Subject: [PATCH 1/2] feat(webui): NexusPHP PT-site preset for search providers Add PT (private-tracker) support via the existing RSS-based search pipeline. The Add Search Provider dialog gains a "PT Site (NexusPHP)" mode that builds a torrentrss.php search template from base URL + passkey + optional category ID (e.g. Audiences.me anime = 402), so search -> subscribe -> auto-download -> rename works end-to-end on NexusPHP trackers with no backend changes. - webui/src/utils/nexusphp.ts: URL-template builder (vitest-covered) - config-search-provider.vue: segmented custom/NexusPHP add dialog with live URL preview; en + zh-CN strings - backend test_nexusphp_rss.py: regression tests proving NexusPHP torrentrss output (enclosure and linktype=dl variants) parses through the generic rss_parser path Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JhTduCYBGeHETU7dSWoh37 --- backend/src/test/test_nexusphp_rss.py | 63 ++++++++ .../setting/config-search-provider.vue | 145 ++++++++++++++++-- webui/src/i18n/en.json | 12 +- webui/src/i18n/zh-CN.json | 12 +- webui/src/utils/__tests__/nexusphp.test.ts | 79 ++++++++++ webui/src/utils/nexusphp.ts | 30 ++++ webui/types/dts/auto-imports.d.ts | 1 + 7 files changed, 323 insertions(+), 19 deletions(-) create mode 100644 backend/src/test/test_nexusphp_rss.py create mode 100644 webui/src/utils/__tests__/nexusphp.test.ts create mode 100644 webui/src/utils/nexusphp.ts diff --git a/backend/src/test/test_nexusphp_rss.py b/backend/src/test/test_nexusphp_rss.py new file mode 100644 index 00000000..7d9fdf58 --- /dev/null +++ b/backend/src/test/test_nexusphp_rss.py @@ -0,0 +1,63 @@ +"""NexusPHP PT 站点(如 Audiences.me)torrentrss.php 输出的解析回归测试。 + +PT 支持依赖通用 RSS 解析路径:条目带 (.torrent 下载地址含 +passkey)时取 enclosure 为下载链接、(details.php)为主页; +linktype=dl 且无 enclosure 时 本身就是下载地址。 +""" + +import xml.etree.ElementTree as ET + +from module.network.site import rss_parser + +NEXUSPHP_RSS_WITH_ENCLOSURE = """ + + + Audiences :: torrents + https://audiences.me + + [Sakurato] Kusuriya no Hitorigoto [21][AVC-8bit 1080p AAC][CHS] + https://audiences.me/details.php?id=12345 + + https://audiences.me/details.php?id=12345 + Sat, 04 Jul 2026 12:00:00 +0800 + + +""" + +NEXUSPHP_RSS_LINKTYPE_DL = """ + + + Audiences :: torrents + https://audiences.me + + [ANi] Boku no Hero Academia S07 - 08 [1080P][WEB-DL][AAC AVC][CHT] + https://audiences.me/download.php?id=67890&passkey=abc123 + https://audiences.me/details.php?id=67890 + Sat, 04 Jul 2026 12:00:00 +0800 + + +""" + + +def test_rss_parser_nexusphp_enclosure_yields_download_url() -> None: + soup = ET.fromstring(NEXUSPHP_RSS_WITH_ENCLOSURE) + results = rss_parser(soup) + assert results == [ + ( + "[Sakurato] Kusuriya no Hitorigoto [21][AVC-8bit 1080p AAC][CHS]", + "https://audiences.me/download.php?id=12345&passkey=abc123", + "https://audiences.me/details.php?id=12345", + ) + ] + + +def test_rss_parser_nexusphp_linktype_dl_uses_link_as_download_url() -> None: + soup = ET.fromstring(NEXUSPHP_RSS_LINKTYPE_DL) + results = rss_parser(soup) + assert results == [ + ( + "[ANi] Boku no Hero Academia S07 - 08 [1080P][WEB-DL][AAC AVC][CHT]", + "https://audiences.me/download.php?id=67890&passkey=abc123", + "", + ) + ] diff --git a/webui/src/components/setting/config-search-provider.vue b/webui/src/components/setting/config-search-provider.vue index d5b2f0c0..31bc33f2 100644 --- a/webui/src/components/setting/config-search-provider.vue +++ b/webui/src/components/setting/config-search-provider.vue @@ -1,6 +1,7 @@