fix: map hddolby hr flag to hit_and_run

HDDolby 搜索接口每条记录带 hr 字段(0/1),但适配器组装通用种子字典时未输出
hit_and_run,导致浏览资源时前端不显示 H&R 标签、刷流插件与下载通知的 H&R 判断
始终为否。按站点接口语义把 hr 映射为 hit_and_run,并复用文本工具的布尔解析以
兼容数值、字符串与字段缺失。
This commit is contained in:
warzook
2026-11-18 11:16:12 +08:00
committed by zhuek
parent 6a029e600c
commit b0a842ea0f
2 changed files with 16 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ from urllib.parse import urlparse
from app.adapters.network.http import AsyncRequestUtils, RequestUtils
from app.application.configuration import get_configured_system_config
from app.domain import site as site_rules
from app.foundation import text as text_tools
from app.runtime.log import logger
from app.runtime.settings import get_runtime_setting
from app.schemas.types import MediaType
@@ -196,6 +197,7 @@ class HddolbySpider:
'freedate': result.get('promotion_until'),
'page_url': self._pageurl % result.get('id') if self._pageurl else '',
'labels': torrentLabels,
'hit_and_run': text_tools.parse_bool(result.get('hr')),
'category': category
}
torrents.append(torrent)

View File

@@ -76,6 +76,20 @@ def test_parse_result_marks_music_torrents(hddolby_spider):
]
def test_parse_result_maps_hit_and_run(hddolby_spider):
"""
hr 标记应映射为 hit_and_run,兼容数值、字符串和缺失字段。
"""
results = hddolby_spider._HddolbySpider__parse_result([
{"id": 1, "name": "The Odyssey 2026 2160p", "category": 401, "size": 1024, "hr": 1},
{"id": 2, "name": "Example Movie 1080p", "category": 401, "size": 1024, "hr": 0},
{"id": 3, "name": "Example TV 1080p", "category": 402, "size": 1024, "hr": "1"},
{"id": 4, "name": "Example TV 2160p", "category": 402, "size": 1024},
])
assert [torrent["hit_and_run"] for torrent in results] == [True, False, True, False]
@pytest.mark.parametrize("asynchronous", [False, True])
@pytest.mark.parametrize(
("domain", "api_url", "expected_url"),