Compare commits

...

2 Commits

Author SHA1 Message Date
pcnick 8d579decdb 新增集數偏移功能 3 weeks ago
pcnick 2f0658b578 修正錯誤 3 weeks ago
  1. 17
      Animelibk.ps1

17
Animelibk.ps1

@ -68,7 +68,7 @@ $WorkData = $(if (Test-Path $RecorDB) {
Get-Content $RecorDB | ConvertFrom-Json Get-Content $RecorDB | ConvertFrom-Json
} else { } else {
"" ""
}) | Select-Object ID, WorkName, TargetName, DestinName, Latinization, Standard, Season, Episode }) | Select-Object ID, WorkName, TargetName, DestinName, Latinization, Standard, Season, Offset, Episode
$RecorDB $RecorDB
# 確認資料狀態,缺少則進行物件資料建立 # 確認資料狀態,缺少則進行物件資料建立
@ -84,6 +84,13 @@ if (-not($WorkData.DestinName)) {
if (-not($WorkData.Season)) { if (-not($WorkData.Season)) {
[int] $WorkData.Season = Read-Host "請輸入季別:"; [int] $WorkData.Season = Read-Host "請輸入季別:";
} }
if (-not($WorkData.Offset)) {
[int] $WorkData.Offset = if ($WorkData.Season -gt 1) {
Read-Host "請輸入集數偏移修正";
} else {
0
}
}
if (-not($WorkData.Episode)) { if (-not($WorkData.Episode)) {
$WorkData.Episode = @(); $WorkData.Episode = @();
} }
@ -92,7 +99,7 @@ $Latinization = {
param($String) param($String)
# 載入置換檔 # 載入置換檔
$C = if ($WorkData.Standard -and (Test-path $PSScriptRoot\C2E.csv)) {Import-Csv -Encoding UTF8 $PSScriptRoot\C2E.csv} $C = if (!$WorkData.Standard -and (Test-path $PSScriptRoot\C2E.csv)) {Import-Csv -Encoding UTF8 $PSScriptRoot\C2E.csv}
if ($WorkData.Latinization.Length -eq 0) { if ($WorkData.Latinization.Length -eq 0) {
$T = Read-Host "請輸入拉丁化作品名稱" $T = Read-Host "請輸入拉丁化作品名稱"
@ -163,7 +170,7 @@ function Get-StandName {
$OutputData.newName = if ($LS) { $WorkData.Latinization } else { $Result.Name.Trim() } $OutputData.newName = if ($LS) { $WorkData.Latinization } else { $Result.Name.Trim() }
$OutputData.Season = $WorkData.Season; $OutputData.Season = $WorkData.Season;
$OutputData.Episode = [int] $Result.Episode; $OutputData.Episode = [int] $Result.Episode;
$OutputData.newFullName = "{0} S{3:00}E{1:00}{4}{2}" -f $OutputData.newName, $OutputData.Episode, $File.Extension, $WorkData.Season, $(if($File.Extension -in $SubExt) {".default"}); $OutputData.newFullName = "{0} S{3:00}E{1:00}{4}{2}" -f $OutputData.newName, $(if (($nE = $OutputData.Episode + $WorkData.Offset) -gt 0) { $nE } else { $OutputData.Episode }), $File.Extension, $WorkData.Season, $(if($File.Extension -in $SubExt) {".default"});
return $OutputData; return $OutputData;
} }
@ -206,7 +213,7 @@ if ($Single) {
} else { } else {
exit 0; exit 0;
} }
$_.NewName | Out-Host
$ENDResult = $BuildList | ForEach-Object { $ENDResult = $BuildList | ForEach-Object {
if ($_.NewName.Episode -and ($_.NewName.newName.Length -gt 0)) { if ($_.NewName.Episode -and ($_.NewName.newName.Length -gt 0)) {
$Command = @{ $Command = @{
@ -222,7 +229,7 @@ $ENDResult = $BuildList | ForEach-Object {
} else { } else {
"{0} 處理錯誤" -f $_.File.FullName | Write-Error "{0} 處理錯誤" -f $_.File.FullName | Write-Error
$_.NewName $_.NewName | Out-Host
} }
} }
#$ENDResult #$ENDResult

Loading…
Cancel
Save