mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-14 02:05:13 +08:00
fix: preserve Remux in UHD BluRay resource type
This commit is contained in:
@@ -28,6 +28,22 @@ DIY_TITLE_RE = re.compile(r'-DIY@', re.IGNORECASE)
|
||||
DESCRIPTION_SPLIT_RE = re.compile(r'[\s/|]+')
|
||||
SPACE_RE = re.compile(r'\s+')
|
||||
SEASON_SUFFIX_RE = re.compile(r"SEASON$", re.IGNORECASE)
|
||||
REMUX_RESOURCE_RE = re.compile(r'(?<![A-Z0-9])REMUX(?![A-Z0-9])', re.IGNORECASE)
|
||||
|
||||
|
||||
def normalize_resource_type(resource_type: Optional[str], title: Optional[str]) -> Optional[str]:
|
||||
"""
|
||||
根据原始标题补全连续出现的复合资源类型。
|
||||
|
||||
:param resource_type: 解析器已识别的资源类型
|
||||
:param title: 原始标题
|
||||
:return: 补全后的资源类型
|
||||
"""
|
||||
if resource_type == "UHD BluRay" \
|
||||
and title \
|
||||
and REMUX_RESOURCE_RE.search(title):
|
||||
return f"{resource_type} REMUX"
|
||||
return resource_type
|
||||
|
||||
|
||||
class MetaVideo(MetaBase):
|
||||
@@ -185,7 +201,7 @@ class MetaVideo(MetaBase):
|
||||
self._effect.reverse()
|
||||
self.resource_effect = " ".join(self._effect)
|
||||
if self._source:
|
||||
self.resource_type = self._source.strip()
|
||||
self.resource_type = normalize_resource_type(self._source.strip(), original_title)
|
||||
# 提取原盘DIY
|
||||
if self.resource_type and "BluRay" in self.resource_type:
|
||||
if (self.subtitle and DIY_RE.search(self.subtitle)) \
|
||||
|
||||
@@ -11,6 +11,7 @@ from app.core.meta.infopath import (
|
||||
clear_parsed_title_for_parent_merge,
|
||||
should_use_parent_title_for_file_stem,
|
||||
)
|
||||
from app.core.meta.metavideo import normalize_resource_type
|
||||
from app.core.meta.words import WordsMatcher
|
||||
from app.log import logger
|
||||
from app.schemas.types import MediaType
|
||||
@@ -379,7 +380,10 @@ def _meta_from_rust(parsed: dict) -> Optional[MetaBase]:
|
||||
"begin_episode": parsed.get("begin_episode"),
|
||||
"end_episode": parsed.get("end_episode"),
|
||||
"part": parsed.get("part"),
|
||||
"resource_type": parsed.get("resource_type"),
|
||||
"resource_type": normalize_resource_type(
|
||||
parsed.get("resource_type"),
|
||||
parsed.get("org_string") or parsed.get("title"),
|
||||
),
|
||||
"resource_effect": parsed.get("resource_effect"),
|
||||
"resource_pix": parsed.get("resource_pix"),
|
||||
"resource_team": parsed.get("resource_team"),
|
||||
|
||||
@@ -173,6 +173,27 @@ def test_python_metainfo_fallback_preserves_xxx_movie_title():
|
||||
assert meta.audio_encode == "DDP 5.1"
|
||||
|
||||
|
||||
def test_metainfo_preserves_uhd_bluray_remux_resource_type():
|
||||
"""默认解析入口应保留 UHD、BluRay 与 REMUX 三段资源类型。"""
|
||||
meta = MetaInfo(
|
||||
"They.Will.Kill.You.2026.2160p.UHD.BluRay.Remux."
|
||||
"HEVC.DV.TrueHD.7.1.Atmos.mkv"
|
||||
)
|
||||
|
||||
assert meta.resource_type == "UHD BluRay REMUX"
|
||||
|
||||
|
||||
def test_python_metainfo_preserves_uhd_bluray_remux_resource_type():
|
||||
"""Python 兜底解析应保留 UHD、BluRay 与 REMUX 三段资源类型。"""
|
||||
with patch("app.core.metainfo.rust_accel.parse_metainfo", return_value=None):
|
||||
meta = MetaInfo(
|
||||
"They.Will.Kill.You.2026.2160p.UHD.BluRay.Remux."
|
||||
"HEVC.DV.TrueHD.7.1.Atmos.mkv"
|
||||
)
|
||||
|
||||
assert meta.resource_type == "UHD BluRay REMUX"
|
||||
|
||||
|
||||
def test_metainfo_routes_audio_filename_to_music():
|
||||
"""音频文件名应直接走音乐分支,不再进入影视季集解析。"""
|
||||
meta = MetaInfo("周杰伦 - 晴天.flac")
|
||||
|
||||
Reference in New Issue
Block a user