feat(subtitle): 文本字幕外置化仅限 TRANSCODE 源;右键菜单合并为级联子菜单
- 内嵌 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 记录电影库清理
This commit is contained in:
@@ -1,37 +1,45 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
资源管理器右键菜单的入口:把选中的文件夹(或视频文件所在目录)交给 media-rename / media-archive。
|
||||
资源管理器右键菜单的入口:把选中的文件夹(或视频文件所在目录)交给对应动作。
|
||||
|
||||
.DESCRIPTION
|
||||
由 install-explorer-menu.ps1 注册到:
|
||||
- 文件夹右键
|
||||
- 文件夹空白处右键(当前目录)
|
||||
- .mkv / .mp4 / .avi 文件右键(取其所在目录)
|
||||
由 install-explorer-menu.ps1 注册成一个级联子菜单(SceneMarshal):
|
||||
1. 重命名(自动) auto
|
||||
2. 归档… media-archive
|
||||
3. 补外挂字幕(转码片源) extract-subs
|
||||
4. 入库前体检(只读) check
|
||||
|
||||
.PARAMETER Action
|
||||
rename(默认)= 规范化流水线;archive = 归档进媒体库。
|
||||
rename(默认)/ archive / extract-subs / check。
|
||||
|
||||
.PARAMETER Pause
|
||||
执行结束后停住窗口,便于查看输出(由右键菜单传入)。
|
||||
|
||||
.PARAMETER DryRun
|
||||
只打印将要执行的远端命令,不真正执行(调试 / 验证路径翻译用)。
|
||||
|
||||
.PARAMETER Paths
|
||||
资源管理器传入的选中项(通常一个)。
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet('rename', 'archive')]
|
||||
[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 { }
|
||||
|
||||
$runner = switch ($Action) {
|
||||
'archive' { 'media-archive.ps1' }
|
||||
default { 'media-rename.ps1' }
|
||||
# 动作 → (执行脚本, 附带模式参数)
|
||||
$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
|
||||
@@ -47,7 +55,18 @@ if (Test-Path -LiteralPath $target -PathType Leaf) {
|
||||
}
|
||||
|
||||
Write-Host "📁 目标: $target" -ForegroundColor DarkGray
|
||||
& (Join-Path $PSScriptRoot $runner) -Tokens @($target)
|
||||
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 }
|
||||
|
||||
|
||||
@@ -1,21 +1,36 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
在 Windows 资源管理器右键菜单里注册 SceneMarshal 的「重命名」「归档」两项。
|
||||
在 Windows 资源管理器右键菜单注册 SceneMarshal 菜单(当前用户,无需管理员)。
|
||||
|
||||
.DESCRIPTION
|
||||
只写 HKCU(当前用户),不需要管理员权限,可随时用 uninstall-explorer-menu.ps1 移除。
|
||||
注册位置(每处两个菜单项):
|
||||
HKCU\Software\Classes\Directory\shell\<Key> (文件夹右键)
|
||||
HKCU\Software\Classes\Directory\Background\shell\<Key> (文件夹空白处右键)
|
||||
HKCU\Software\Classes\SystemFileAssociations\.mkv\shell\<Key>
|
||||
默认注册成「SceneMarshal ▸」级联子菜单,子项:
|
||||
1. 重命名(自动) → auto
|
||||
2. 归档… → media-archive(交互选分类)
|
||||
3. 补外挂字幕(转码片源) → extract-subs
|
||||
4. 入库前体检(只读) → check
|
||||
|
||||
级联写法与 Windows 自带项(UpdateEncryptionSettingsWork)一致:
|
||||
父键上写 ExtendedSubCommandsKey = 该键自身的 HKCR 相对路径,子项放在父键的 Shell\ 下。
|
||||
|
||||
注册位置(每处一个父菜单):
|
||||
HKCU\Software\Classes\Directory\shell\SceneMarshal (文件夹右键)
|
||||
HKCU\Software\Classes\Directory\Background\shell\SceneMarshal (文件夹空白处右键)
|
||||
HKCU\Software\Classes\SystemFileAssociations\.mkv\shell\SceneMarshal
|
||||
... 同上 .mp4 / .avi(文件右键,取其所在目录)
|
||||
|
||||
.PARAMETER Flat
|
||||
兜底模式:不级联,直接注册 4 个平级菜单项(名称带「SceneMarshal ▸ 」前缀)。
|
||||
|
||||
.EXAMPLE
|
||||
.\install-explorer-menu.ps1
|
||||
.EXAMPLE
|
||||
.\install-explorer-menu.ps1 -Flat
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
param(
|
||||
[switch]$Flat
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
@@ -35,37 +50,101 @@ $repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$iconPath = Join-Path $repoRoot 'assets\scenemarshal.ico'
|
||||
if (-not (Test-Path -LiteralPath $iconPath)) { $iconPath = $pwsh }
|
||||
|
||||
$actions = @(
|
||||
@{ Key = 'SceneMarshal'; Text = 'SceneMarshal 重命名'; Action = 'rename' },
|
||||
@{ Key = 'SceneMarshalArchive'; Text = 'SceneMarshal 归档'; Action = 'archive' }
|
||||
$menuName = 'SceneMarshal'
|
||||
|
||||
$iconsDir = Join-Path $repoRoot 'assets\menu'
|
||||
function Get-ItemIcon([string]$name) {
|
||||
$p = Join-Path $iconsDir $name
|
||||
if (Test-Path -LiteralPath $p) { return $p }
|
||||
return $iconPath
|
||||
}
|
||||
|
||||
# 级联子项:ExtendedSubCommandsKey 模式下 Explorer 取 MUIVerb 作为显示名
|
||||
$items = @(
|
||||
@{ Key = '01-rename'; Text = '媒体整理'; Action = 'rename'; Icon = (Get-ItemIcon 'rename.ico') },
|
||||
@{ Key = '02-archive'; Text = '媒体归档'; Action = 'archive'; Icon = (Get-ItemIcon 'archive.ico') },
|
||||
@{ Key = '03-extract-subs'; Text = '补外挂字幕'; Action = 'extract-subs'; Icon = (Get-ItemIcon 'subtitle.ico') },
|
||||
@{ Key = '04-check'; Text = '入库校验'; Action = 'check'; Icon = (Get-ItemIcon 'check.ico') }
|
||||
)
|
||||
|
||||
# Relative = ExtendedSubCommandsKey 的值(相对 HKEY_CLASSES_ROOT),同时用于定位注册表路径
|
||||
$locations = @(
|
||||
@{ Shell = 'HKCU:\Software\Classes\Directory\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\Directory\Background\shell'; Token = '%V' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.mkv\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.mp4\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.avi\shell'; Token = '%1' }
|
||||
@{ Relative = 'Directory\shell\SceneMarshal'; Token = '%1' },
|
||||
@{ Relative = 'Directory\Background\shell\SceneMarshal'; Token = '%V' },
|
||||
@{ Relative = 'SystemFileAssociations\.mkv\shell\SceneMarshal'; Token = '%1' },
|
||||
@{ Relative = 'SystemFileAssociations\.mp4\shell\SceneMarshal'; Token = '%1' },
|
||||
@{ Relative = 'SystemFileAssociations\.avi\shell\SceneMarshal'; Token = '%1' }
|
||||
)
|
||||
|
||||
function New-MenuCommand([string]$Action, [string]$Token) {
|
||||
'"' + $pwsh + '" -NoLogo -NoProfile -File "' + $runner + '" -Action ' + $Action + ' -Pause "' + $Token + '"'
|
||||
}
|
||||
|
||||
function Get-RegPath([string]$relative) {
|
||||
return "HKCU:\Software\Classes\$relative"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 清理旧结构
|
||||
foreach ($loc in $locations) {
|
||||
foreach ($item in $actions) {
|
||||
$key = Join-Path $loc.Shell $item.Key
|
||||
$commandKey = Join-Path $key 'command'
|
||||
New-Item -Path $key -Force | Out-Null
|
||||
foreach ($name in @($menuName, 'SceneMarshalArchive')) {
|
||||
$old = Join-Path (Split-Path -Parent (Get-RegPath $loc.Relative)) $name
|
||||
if (Test-Path -LiteralPath $old) { Remove-Item -LiteralPath $old -Recurse -Force }
|
||||
}
|
||||
# 兜底模式的平级项
|
||||
$shellOf = Split-Path -Parent (Get-RegPath $loc.Relative)
|
||||
Get-ChildItem -LiteralPath $shellOf -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.PSChildName -like 'SceneMarshal-*' } |
|
||||
ForEach-Object { Remove-Item -LiteralPath $_.PSPath -Recurse -Force }
|
||||
}
|
||||
# 早期尝试留下的共享子菜单键
|
||||
foreach ($sub in @('SceneMarshalMenu', 'SceneMarshalMenuBg')) {
|
||||
$old = "HKCU:\Software\Classes\$sub"
|
||||
if (Test-Path -LiteralPath $old) { Remove-Item -LiteralPath $old -Recurse -Force }
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 注册
|
||||
foreach ($loc in $locations) {
|
||||
$parent = Get-RegPath $loc.Relative
|
||||
if (-not (Test-Path -LiteralPath $parent)) { New-Item -Path $parent -Force | Out-Null }
|
||||
|
||||
if ($Flat) {
|
||||
# 兜底:每个位置注册 4 个平级项
|
||||
foreach ($item in $items) {
|
||||
$key = Join-Path $parent ("SceneMarshal-{0}" -f $item.Action)
|
||||
$commandKey = Join-Path $key 'command'
|
||||
New-Item -Path $commandKey -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name 'MUIVerb' -Value ("$menuName ▸ " + $item.Text) -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name 'Icon' -Value $item.Icon -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $commandKey -Name '(default)' -Value (New-MenuCommand $item.Action $loc.Token) -PropertyType String -Force | Out-Null
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
New-ItemProperty -Path $parent -Name 'MUIVerb' -Value $menuName -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $parent -Name 'ExtendedSubCommandsKey' -Value $loc.Relative -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $parent -Name 'Icon' -Value $iconPath -PropertyType String -Force | Out-Null
|
||||
|
||||
$childrenShell = Join-Path $parent 'Shell'
|
||||
New-Item -Path $childrenShell -Force | Out-Null
|
||||
foreach ($item in $items) {
|
||||
$child = Join-Path $childrenShell $item.Key
|
||||
$commandKey = Join-Path $child 'command'
|
||||
New-Item -Path $commandKey -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name '(default)' -Value $item.Text -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name 'Icon' -Value $iconPath -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $child -Name 'MUIVerb' -Value $item.Text -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $child -Name 'Icon' -Value $item.Icon -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $commandKey -Name '(default)' -Value (New-MenuCommand $item.Action $loc.Token) -PropertyType String -Force | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host '✔ 已注册右键菜单(当前用户)' -ForegroundColor Green
|
||||
foreach ($item in $actions) {
|
||||
Write-Host (" - 「{0}」 × 文件夹 / 空白处 / mkv,mp4,avi" -f $item.Text) -ForegroundColor DarkGray
|
||||
if ($Flat) {
|
||||
Write-Host '✔ 已注册平级菜单项(兜底模式)' -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host '✔ 已注册右键级联菜单(ExtendedSubCommandsKey 自引用)' -ForegroundColor Green
|
||||
}
|
||||
Write-Host " $menuName ▸" -ForegroundColor Cyan
|
||||
foreach ($item in $items) {
|
||||
Write-Host (" {0}" -f $item.Text) -ForegroundColor DarkGray
|
||||
}
|
||||
Write-Host ' 位置:文件夹 / 空白处 / .mkv / .mp4 / .avi' -ForegroundColor DarkGray
|
||||
Write-Host '提示:若菜单未立即出现,重启一次 explorer.exe 或重新登录。' -ForegroundColor Yellow
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
移除 install-explorer-menu.ps1 注册的右键菜单(重命名 + 归档)。
|
||||
移除 install-explorer-menu.ps1 注册的 SceneMarshal 右键菜单。
|
||||
|
||||
.DESCRIPTION
|
||||
清理范围:
|
||||
- 5 处位置上的 SceneMarshal 父菜单(级联)及旧版平级项
|
||||
- 级联用的共享子菜单键 SceneMarshalMenu / SceneMarshalMenuBg
|
||||
- 兜底模式(-Flat)注册的 SceneMarshal-<action> 平级项
|
||||
|
||||
.EXAMPLE
|
||||
.\uninstall-explorer-menu.ps1
|
||||
@@ -11,7 +17,6 @@ param()
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$keyNames = @('SceneMarshal', 'SceneMarshalArchive')
|
||||
$shells = @(
|
||||
'HKCU:\Software\Classes\Directory\shell',
|
||||
'HKCU:\Software\Classes\Directory\Background\shell',
|
||||
@@ -19,6 +24,7 @@ $shells = @(
|
||||
'HKCU:\Software\Classes\SystemFileAssociations\.mp4\shell',
|
||||
'HKCU:\Software\Classes\SystemFileAssociations\.avi\shell'
|
||||
)
|
||||
$keyNames = @('SceneMarshal', 'SceneMarshalArchive')
|
||||
|
||||
$removed = 0
|
||||
foreach ($shell in $shells) {
|
||||
@@ -30,6 +36,24 @@ foreach ($shell in $shells) {
|
||||
Write-Host " - 已移除 $key" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
# 兜底模式留下的平级项
|
||||
Get-ChildItem -LiteralPath $shell -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.PSChildName -like 'SceneMarshal-*' } |
|
||||
ForEach-Object {
|
||||
Remove-Item -LiteralPath $_.PSPath -Recurse -Force
|
||||
$script:removed++
|
||||
Write-Host (" - 已移除 {0}" -f $_.PSChildName) -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "✔ 右键菜单已清理($removed 项)" -ForegroundColor Green
|
||||
# 共享子菜单
|
||||
foreach ($sub in @('SceneMarshalMenu', 'SceneMarshalMenuBg')) {
|
||||
$key = "HKCU:\Software\Classes\$sub"
|
||||
if (Test-Path -LiteralPath $key) {
|
||||
Remove-Item -LiteralPath $key -Recurse -Force
|
||||
$script:removed++
|
||||
Write-Host " - 已移除 $key" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ("✔ 右键菜单已清理({0} 项)" -f $removed) -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user