Browse Source

Anime Link Libary: add Sub parameter, make subtitle hardlink

* 新增參數 Sub,忽略 json 文件季數設定並建立字幕檔連結
master
pcnick 3 years ago
parent
commit
a638c7d6a2
  1. 39
      Animelibk.ps1

39
Animelibk.ps1

@ -1,12 +1,17 @@
param( param(
$Path, $Path,
$Index = "H:\AnimeLib", $Index = "H:\AnimeLib",
[switch] $Single [switch] $Single,
[switch] $Force,
[switch] $Sub
) )
#$TargetName = "俺だけ入れる隠しダンジョン〜こっそり鍛えて世界最強〜"; #$TargetName = "俺だけ入れる隠しダンジョン〜こっそり鍛えて世界最強〜";
$TargetName = "" $TargetName = ""
#$DestinName = "真の仲間" #$DestinName = "真の仲間"
Write-Output $Path Write-Output $Path
#$Index = "L:\AnimeLib"
#$Path = "L:\Anime\202001 ネコぱら\[Nekomoe kissaten][Nekopara][01-12][BDRip][1080p][CHT]\[Nekomoe kissaten][Nekopara][12][1080p][CHT].mp4"
#$Path = "L:\Anime\202004 ストライク・ザ・ブラッド OVA IV\[Suzu-Kaze][Strike_the_Blood_IV_OVA][01-12FIN][BDRip_1080P][HEVC_YUV420P10]\[Suzu-Kaze] Strike the Blood IV 12FIN [BDRip 1920x1080 HEVC YUV420P10 FLAC].mkv"
#$Path = "H:\Anime\201901 盾の勇者の成り上がり\[LKSUB][Tate no Yuusha no Nariagari][01-25][GB][720P][MP4]\[LKSUB][Tate no Yuusha no Nariagari][01][GB][720P].mp4" #$Path = "H:\Anime\201901 盾の勇者の成り上がり\[LKSUB][Tate no Yuusha no Nariagari][01-25][GB][720P][MP4]\[LKSUB][Tate no Yuusha no Nariagari][01][GB][720P].mp4"
#$Path = "H:\Data\Downloads\因為不是真正的夥伴而被逐出勇者隊伍\[Shin no Nakama][01][BIG5][1080P].mp4" #$Path = "H:\Data\Downloads\因為不是真正的夥伴而被逐出勇者隊伍\[Shin no Nakama][01][BIG5][1080P].mp4"
$JsonPath = $("$Index\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_}) $JsonPath = $("$Index\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_})
@ -62,8 +67,10 @@ function Get-StandName {
# 因應檔名不同而設定多組正規方式 # 因應檔名不同而設定多組正規方式
$Result = @($( $Result = @($(
#$($TestName[-1] -match "\[([^\]]*)\]\[(\d{1,2})\]")
#$($File.Name -match "[\[\s]([^\]]*?)(?:[\]\[\-\s]+)(\d{1,2})[\]\s]") #$($File.Name -match "[\[\s]([^\]]*?)(?:[\]\[\-\s]+)(\d{1,2})[\]\s]")
$($File.Name -match "[\[\s](?<Name>\b[^\]]*\b)(?:[\]\[\-\s]+)(?<Episode>\d{1,2})(?:[vV]\d|FIN|END)?[\]\s]") $($File.Name -match "[\[\s](?<Name>\b[^\]]*\b)(?:[\]\[\-\s]+)(?<Episode>\d{1,2})(?:[vV]\d|FIN|END)?[\]\s]")
#$($TestName[-1] -match "[\[\s](?<Name>[^\]]*?)(?:[\]\[\-\s]+)(?<Episode>\d{1,2})(?:[vV]\d)?[\]\s]")
) | % { if ($_) { $Matches }}) ) | % { if ($_) { $Matches }})
# 檔名分析測試用 # 檔名分析測試用
@ -94,7 +101,7 @@ function Get-StandName {
$OutputData.newName = $Result.Name; $OutputData.newName = $Result.Name;
$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}{2}" -f $Result.Name, $Result.Episode, $File.Extension, $WorkData.Season; $OutputData.newFullName = "{0} S{3:00}E{1}{4}{2}" -f $Result.Name, $Result.Episode, $File.Extension, $WorkData.Season, $(if($Sub) {".default"});
#$OutputData | ConvertTo-Json; #$OutputData | ConvertTo-Json;
# Type 2,在輸出顯示上,此型態建立較傾向 Hash,而上面 select 建立的,較偏向 pscustomobject # Type 2,在輸出顯示上,此型態建立較傾向 Hash,而上面 select 建立的,較偏向 pscustomobject
@ -140,6 +147,9 @@ if ($Single) {
$List = @(Get-Item -Path $($Path -replace '([\[\]])', '`$1')) $List = @(Get-Item -Path $($Path -replace '([\[\]])', '`$1'))
$BuildList = $List | select $FileObj, $StructPathObj, $NewNameObj | ? {$_.NewName.Episode -notin $WorkData.Episode} $BuildList = $List | select $FileObj, $StructPathObj, $NewNameObj | ? {$_.NewName.Episode -notin $WorkData.Episode}
#$BuildList | ? {$_.NewName.Episode -notin $WorkData.Episode} | Format-List #$BuildList | ? {$_.NewName.Episode -notin $WorkData.Episode} | Format-List
} elseif ($Sub) {
$List = @(Get-Item -Path $($Path -replace '([\[\]])', '`$1'))
$BuildList = $List | select $FileObj, $StructPathObj, $NewNameObj | ? {$_.File.Extension -in @(".ass", ".ssa")}
} }
$ENDResult = $BuildList | % { $ENDResult = $BuildList | % {
@ -149,15 +159,16 @@ $ENDResult = $BuildList | % {
Target = $($_.File.Fullname -replace '([\[\]])', '`$1') Target = $($_.File.Fullname -replace '([\[\]])', '`$1')
} }
#try { #try {
# 判斷 New-Item @Command 是否成功,將 NEWNAME 物件作為回傳值 if (New-Item @Command) {
if (New-Item @Command) { $_.NewName } Write-Host $_.NewName.newFullName
$_.NewName }
#} catch { #} catch {
#} #}
} }
#$ENDResult #$ENDResult
#$ENDResult.gettype(); #$ENDResult.gettype();
$ENDResult | % { if ($_.Episode) { $WorkData.Episode += $_.Episode }} if (-not($Sub)) { $ENDResult | % { if ($_.Episode) { $WorkData.Episode += $_.Episode }}}
$WorkData | ConvertTo-Json | Out-File -Encoding "UTF8" "$JsonPath\animelibk.json" $WorkData | ConvertTo-Json | Out-File -Encoding "UTF8" "$JsonPath\animelibk.json"
exit 0; exit 0;
@ -165,8 +176,8 @@ exit 0;
# SIG # Begin signature block # SIG # Begin signature block
# MIIFxwYJKoZIhvcNAQcCoIIFuDCCBbQCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # MIIFxwYJKoZIhvcNAQcCoIIFuDCCBbQCAQExCzAJ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FebKDzg==
# SIG # End signature block # SIG # End signature block

Loading…
Cancel
Save