- 内嵌 ASS 抽取与字体抽取挂到 verdict == TRANSCODE(extract-subs / --extract-internal 仍可强制),直传片源不再生成外挂副本 - 外挂 SRT 兜底仅在 [Subtitles] export 不含 ass 时启用,避免同语言双份 - 新增同语言判重(含旧命名 <stem>.<lang>.srt),重复抽取不再产生重复字幕 - 识别中英双语轨为 zh-en,语言白名单加入 zh-en - 外挂字幕统一 <stem>.internal.<lang>.srt 命名 - 右键菜单合并为 SceneMarshal 级联子菜单(ExtendedSubCommandsKey), 四项:媒体整理 / 媒体归档 / 补外挂字幕 / 入库校验,图标 assets/menu 自绘 - HANDOFF 补右键菜单说明;新增 docs/movie-duplicates.md 记录电影库清理
78 lines
2.3 KiB
PowerShell
78 lines
2.3 KiB
PowerShell
#Requires -Version 7.0
|
|
<#
|
|
.SYNOPSIS
|
|
资源管理器右键菜单的入口:把选中的文件夹(或视频文件所在目录)交给对应动作。
|
|
|
|
.DESCRIPTION
|
|
由 install-explorer-menu.ps1 注册成一个级联子菜单(SceneMarshal):
|
|
1. 重命名(自动) auto
|
|
2. 归档… media-archive
|
|
3. 补外挂字幕(转码片源) extract-subs
|
|
4. 入库前体检(只读) check
|
|
|
|
.PARAMETER Action
|
|
rename(默认)/ archive / extract-subs / check。
|
|
|
|
.PARAMETER Pause
|
|
执行结束后停住窗口,便于查看输出(由右键菜单传入)。
|
|
|
|
.PARAMETER DryRun
|
|
只打印将要执行的远端命令,不真正执行(调试 / 验证路径翻译用)。
|
|
|
|
.PARAMETER Paths
|
|
资源管理器传入的选中项(通常一个)。
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet('rename', 'archive', 'extract-subs', 'check')]
|
|
[string]$Action = 'rename',
|
|
[switch]$Pause,
|
|
[switch]$DryRun,
|
|
[Parameter(ValueFromRemainingArguments = $true)][string[]]$Paths = @()
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
try { [Console]::OutputEncoding = [Text.Encoding]::UTF8 } catch { }
|
|
|
|
# 动作 → (执行脚本, 附带模式参数)
|
|
$plan = switch ($Action) {
|
|
'archive' { @{ Runner = 'media-archive.ps1'; Extra = @() } }
|
|
'extract-subs' { @{ Runner = 'media-rename.ps1'; Extra = @('extract-subs') } }
|
|
'check' { @{ Runner = 'media-rename.ps1'; Extra = @('check') } }
|
|
default { @{ Runner = 'media-rename.ps1'; Extra = @() } }
|
|
}
|
|
|
|
$target = $Paths | Where-Object { $_ } | Select-Object -First 1
|
|
|
|
if (-not $target) {
|
|
Write-Host '❌ 没有收到要处理的路径' -ForegroundColor Red
|
|
if ($Pause) { Write-Host ''; Read-Host '按 Enter 关闭' | Out-Null }
|
|
exit 1
|
|
}
|
|
|
|
if (Test-Path -LiteralPath $target -PathType Leaf) {
|
|
$target = Split-Path -Parent $target
|
|
}
|
|
|
|
Write-Host "📁 目标: $target" -ForegroundColor DarkGray
|
|
Write-Host ("▶ 动作: {0}" -f $Action) -ForegroundColor DarkGray
|
|
|
|
$runnerPath = Join-Path $PSScriptRoot $plan.Runner
|
|
$tokens = @($target) + $plan.Extra
|
|
|
|
if ($DryRun) {
|
|
& $runnerPath -Tokens $tokens -DryRun
|
|
}
|
|
else {
|
|
& $runnerPath -Tokens $tokens
|
|
}
|
|
|
|
$code = $LASTEXITCODE
|
|
if ($null -eq $code) { $code = 0 }
|
|
|
|
if ($Pause) {
|
|
Write-Host ''
|
|
Read-Host '按 Enter 关闭窗口' | Out-Null
|
|
}
|
|
exit $code
|