Browse Source

以參數彈性設定資料檔外部化

develop
pcnick 1 year ago
parent
commit
51dae0f48e
  1. 10
      Animelibk.ps1

10
Animelibk.ps1

@ -2,6 +2,7 @@
$Path, $Path,
$Index = "H:\AnimeLib", $Index = "H:\AnimeLib",
$VarConfig, $VarConfig,
$RecorDB = "animelibk.ini",
[switch] $Single, [switch] $Single,
[switch] $Force, [switch] $Force,
[switch] $Sub [switch] $Sub
@ -55,11 +56,12 @@ if ($VarConfig) {
#$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 = "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"
$JsonPath = $("$Index\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_}) $JsonPath = $("$Index\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_})
$WorkData = $(if (Test-Path "$JsonPath\animelibk.json") { $WorkData = $(if (Test-Path $RecorDB) {
Get-Content "$JsonPath\animelibk.json" | ConvertFrom-Json Get-Content $RecorDB | ConvertFrom-Json
} else { } else {
"" | select ID, WorkName, TargetName, DestinName, Season, Episode "" | Select-Object ID, WorkName, TargetName, DestinName, Season, Episode
}) })
if ($RecorDB -notmatch ":") { $RecorDB = "$JsonPath\$RecorDB" }
# 確認資料狀態,缺少則進行物件資料建立 # 確認資料狀態,缺少則進行物件資料建立
if (-not($WorkData.WorkName)) { if (-not($WorkData.WorkName)) {
@ -167,5 +169,5 @@ $ENDResult = $BuildList | % {
#$ENDResult #$ENDResult
#$ENDResult.gettype(); #$ENDResult.gettype();
if (-not($Sub)) { $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" $RecorDB
exit 0; exit 0;
Loading…
Cancel
Save