mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-26 05:42:04 +08:00
Merge pull request #7385 from jxxghp/fix/issue-7369
fix(transfer): honor scrape defaults and music track overwrite
This commit is contained in:
@@ -1788,6 +1788,8 @@ class ScrapingChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
|
||||
"""
|
||||
为每张专辑按整批双向唯一证据对位,拒绝整轨 CUE 和身份冲突。
|
||||
|
||||
手动覆盖或已锁定具体发行版本时,允许用唯一曲序纠正旧曲名;仅拿到
|
||||
发行组代表版本时仍要求曲名或艺人证据,避免不同版本的曲序差异误配。
|
||||
远端音频在对位与实际写入时分别下载,写入前重新核对证据;
|
||||
不依赖文件排序或把尚未匹配的剩余文件强行分配给曲目。
|
||||
"""
|
||||
@@ -1816,7 +1818,9 @@ class ScrapingChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
|
||||
# 不完整的本地证据无法证明整批文件与线上曲目之间的双向唯一性。
|
||||
continue
|
||||
aligned = align_music_tracks(
|
||||
[meta for _, meta in eligible], tracks, allow_title_override=allow_title_override,
|
||||
[meta for _, meta in eligible],
|
||||
tracks,
|
||||
allow_title_override=allow_title_override or bool(key[2]),
|
||||
)
|
||||
for index, remote in aligned.items():
|
||||
item, meta = eligible[index]
|
||||
|
||||
@@ -380,7 +380,10 @@ class ManualTransferItem(OptionalMediaIdentityMixin, BaseModel):
|
||||
episode_part: Optional[str] = Field(default=None, description="指定PART")
|
||||
episode_offset: Optional[str] = Field(default=None, description="集数偏移")
|
||||
min_filesize: Optional[int] = Field(default=0, description="最低文件大小阈值,单位为 MiB;0 不限制,启用时仅保留严格大于阈值的文件")
|
||||
scrape: Optional[bool] = Field(default=False, description="刮削")
|
||||
scrape: Optional[bool] = Field(
|
||||
default=None,
|
||||
description="刮削;为空时跟随目标目录的刮削设置",
|
||||
)
|
||||
library_type_folder: Optional[bool] = Field(default=None, description="媒体库类型子目录")
|
||||
library_category_folder: Optional[bool] = Field(default=None, description="媒体库类别子目录")
|
||||
from_history: Optional[bool] = Field(default=False, description="复用历史识别信息")
|
||||
|
||||
@@ -182,6 +182,25 @@ def test_manual_transfer_history_after_move_uses_destination_snapshot(batch):
|
||||
assert [item.path for item in items] == ["/library/movie.mkv"]
|
||||
|
||||
|
||||
def test_manual_transfer_default_scrape_follows_target_directory(monkeypatch):
|
||||
"""
|
||||
未显式指定刮削时保留空值,让整理链按目标目录的刮削设置执行。
|
||||
"""
|
||||
execute = Mock(return_value=(True, ""))
|
||||
monkeypatch.setattr(transfer, "TransferChain", lambda: SimpleNamespace(manual_transfer=execute))
|
||||
|
||||
result = transfer.manual_transfer(
|
||||
transer_item=ManualTransferItem(
|
||||
fileitem=FileItem(storage="local", path="/downloads/test.flac", type="file"),
|
||||
),
|
||||
background=True,
|
||||
history_query=Mock(),
|
||||
)
|
||||
|
||||
assert result.success is True
|
||||
assert execute.call_args.kwargs["scrape"] is None
|
||||
|
||||
|
||||
def test_manual_target_path_skips_source_without_path(monkeypatch):
|
||||
"""
|
||||
缺少源路径的项被去重阶段过滤,不把当前工作目录用作整理路径匹配条件。
|
||||
|
||||
@@ -250,7 +250,7 @@ def test_overwrite_preserves_track_on_duration_conflict(tmp_path, monkeypatch):
|
||||
|
||||
def test_automatic_overwrite_does_not_guess_from_position_alone(tmp_path, monkeypatch):
|
||||
"""
|
||||
自动刮削即使启用覆盖,也不能把手动选择专辑时的曲名纠正放宽到普通自动识别。
|
||||
自动刮削仅拿到发行组代表版本时,不能只凭曲序推断另一个版本的曲名。
|
||||
"""
|
||||
album = _album()
|
||||
path = _audio(tmp_path / "01.flac", "本地不同曲名", "本地歌手", 1)
|
||||
@@ -263,6 +263,24 @@ def test_automatic_overwrite_does_not_guess_from_position_alone(tmp_path, monkey
|
||||
assert AudioMetadataHelper.read_tags(path).title == "本地不同曲名"
|
||||
|
||||
|
||||
def test_automatic_overwrite_uses_locked_release_track_credit(tmp_path, monkeypatch):
|
||||
"""
|
||||
自动整理锁定具体发行版本时,覆盖策略应按唯一曲序写入线上曲名和艺人。
|
||||
"""
|
||||
album = _album()
|
||||
album.musicbrainz_release_id = _OTHER_RECORDING
|
||||
for track in album.tracks:
|
||||
track.musicbrainz_release_id = _OTHER_RECORDING
|
||||
path = _audio(tmp_path / "01.flac", "The Story Of Us", "JJ Lin", 1)
|
||||
chain = _chain(monkeypatch, album, "overwrite")
|
||||
|
||||
success, message = _scrape(chain, album, [_item(path)], overwrite=False)
|
||||
|
||||
result = AudioMetadataHelper.read_tags(path)
|
||||
assert success and "匹配 1" in message
|
||||
assert (result.title, result.artists) == ("正确一", ["线上歌手一"])
|
||||
|
||||
|
||||
def test_automatic_overwrite_corrects_position_with_strict_title_evidence(tmp_path, monkeypatch):
|
||||
"""
|
||||
自动刮削在曲名和艺人有严格证据时,覆盖策略仍可修正错标曲序。
|
||||
|
||||
Reference in New Issue
Block a user