mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix(search): fall back to title when IMDb ID is missing
This commit is contained in:
@@ -156,14 +156,14 @@ class _SearchProviderSyncOwner(_SearchOwnerBase):
|
||||
|
||||
@staticmethod
|
||||
def _torrent_keyword(
|
||||
keyword: str,
|
||||
keyword: Optional[str],
|
||||
mediainfo: Optional[MediaInfo],
|
||||
area: Optional[str],
|
||||
) -> str:
|
||||
"""投影站点实际请求关键字,IMDb 搜索只在计划边界转换一次。"""
|
||||
"""投影站点实际请求关键字,缺少 IMDb ID 时回退媒体标题。"""
|
||||
if area == "imdbid" and mediainfo:
|
||||
return mediainfo.imdb_id or keyword
|
||||
return keyword
|
||||
return mediainfo.imdb_id or keyword or mediainfo.title or ""
|
||||
return keyword or ""
|
||||
|
||||
@staticmethod
|
||||
def _torrent_type(
|
||||
@@ -378,8 +378,9 @@ class _SearchProviderSyncOwner(_SearchOwnerBase):
|
||||
"""通过共享线程 owner 按站点顺序翻页并汇总同步 provider 结果。"""
|
||||
indexer_sites = self._sync_indexers(sites)
|
||||
media_type = self._torrent_type(mediainfo, mtype)
|
||||
search_keyword = self._torrent_keyword(keyword, mediainfo, area)
|
||||
plugin_results = self.search_plugin_torrents(
|
||||
keyword=keyword,
|
||||
keyword=search_keyword,
|
||||
mtype=media_type,
|
||||
page=page,
|
||||
)
|
||||
@@ -391,7 +392,6 @@ class _SearchProviderSyncOwner(_SearchOwnerBase):
|
||||
start_time = datetime.now()
|
||||
search_pages = self._build_search_pages(page)
|
||||
results = list(plugin_results)
|
||||
search_keyword = self._torrent_keyword(keyword, mediainfo, area)
|
||||
|
||||
progress.start()
|
||||
try:
|
||||
@@ -672,13 +672,13 @@ class SearchProviderOwner(_SearchProviderSyncOwner):
|
||||
"""构造种子 provider 的 canonical 事件流。"""
|
||||
indexer_sites = await self._async_indexers(sites)
|
||||
media_type = self._torrent_type(mediainfo, mtype)
|
||||
search_keyword = self._torrent_keyword(keyword, mediainfo, area)
|
||||
plugin_results = await self.async_search_plugin_torrents(
|
||||
keyword=keyword,
|
||||
keyword=search_keyword,
|
||||
mtype=media_type,
|
||||
page=page,
|
||||
)
|
||||
search_pages = self._build_search_pages(page)
|
||||
search_keyword = self._torrent_keyword(keyword, mediainfo, area)
|
||||
|
||||
async def search_site_page(
|
||||
site: SiteIndexer,
|
||||
|
||||
@@ -830,7 +830,7 @@ class SubscribeSearchOwner(_SubscribeSearchQueueOwner):
|
||||
no_exists=no_exists,
|
||||
sites=self.get_sub_sites(subscribe),
|
||||
rule_groups=subscribe.filter_groups or get_configured_system_config().get(rule_key) or [],
|
||||
area="imdbid" if subscribe.search_imdbid else "title",
|
||||
area="imdbid" if subscribe.search_imdbid and mediainfo.imdb_id else "title",
|
||||
custom_words=subscribe.custom_words.split("\n") if subscribe.custom_words else None,
|
||||
filter_params=self.get_params(subscribe),
|
||||
)
|
||||
|
||||
@@ -117,6 +117,14 @@ def test_id_search_sync_async_share_request_and_missing_plan(monkeypatch):
|
||||
assert saved_sync == saved_async
|
||||
|
||||
|
||||
def test_imdb_search_falls_back_to_media_title_without_imdb_id():
|
||||
"""IMDb 搜索缺少 IMDb ID 且没有调用方关键字时应请求媒体标题。"""
|
||||
target = _media()
|
||||
|
||||
assert SearchChain._torrent_keyword(None, target, "imdbid") == target.title
|
||||
assert SearchChain._torrent_keyword("自定义标题", target, "imdbid") == "自定义标题"
|
||||
|
||||
|
||||
def test_media_process_sync_async_share_keyword_stop_decision(monkeypatch):
|
||||
"""双入口应按相同关键字顺序搜索,并在首个有效结果后同时停止。"""
|
||||
chain = _chain()
|
||||
|
||||
Reference in New Issue
Block a user