From eb9441e86994f892b8eb542f370e7ed86623334a Mon Sep 17 00:00:00 2001 From: jvlflame Date: Sun, 4 Oct 2020 18:55:58 -0700 Subject: [PATCH] Add feature to use altname as actor role (#110) --- src/Javinizer/Private/Test-JVSettings.ps1 | 1 + src/Javinizer/Public/Get-JVNfo.ps1 | 34 +++++++++++++++++++++-- src/Javinizer/Public/Javinizer.ps1 | 2 +- src/Javinizer/Public/Set-JVMovie.ps1 | 11 ++++++-- src/Javinizer/jvSettings.json | 1 + 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/Javinizer/Private/Test-JVSettings.ps1 b/src/Javinizer/Private/Test-JVSettings.ps1 index c7bdb078..775cb537 100644 --- a/src/Javinizer/Private/Test-JVSettings.ps1 +++ b/src/Javinizer/Private/Test-JVSettings.ps1 @@ -91,6 +91,7 @@ function Test-JVSettings { 'sort.download.thumbimg', 'sort.download.trailervid', 'sort.metadata.genrecsv', + 'sort.metadata.nfo.altnamerole', 'sort.metadata.nfo.actresslanguageja', 'sort.metadata.nfo.firstnameorder', 'sort.metadata.nfo.translatedescription', diff --git a/src/Javinizer/Public/Get-JVNfo.ps1 b/src/Javinizer/Public/Get-JVNfo.ps1 index 1c8bf4f6..2495db7a 100644 --- a/src/Javinizer/Public/Get-JVNfo.ps1 +++ b/src/Javinizer/Public/Get-JVNfo.ps1 @@ -82,7 +82,10 @@ function Get-JVNfo { [Boolean]$NameOrder, [Parameter()] - [String]$OriginalPath + [String]$OriginalPath, + + [Parameter()] + [Boolean]$AltNameRole ) process { @@ -162,6 +165,13 @@ function Get-JVNfo { if ($ActressLanguageJa) { if ($null -ne $item.JapaneseName) { $actressName = ($item.JapaneseName) + if ($null -ne $item.FirstName -or $null -ne $item.LastName) { + if ($NameOrder) { + $altName = ("$($item.FirstName) $($item.LastName)").Trim() + } else { + $altName = ("$($item.LastName) $($item.FirstName)").Trim() + } + } } if ($null -eq $actressName) { @@ -171,6 +181,7 @@ function Get-JVNfo { } else { $actressName = ("$($item.LastName) $($item.FirstName)").Trim() } + $altName = $null } } } else { @@ -180,25 +191,42 @@ function Get-JVNfo { } else { $actressName = ("$($item.LastName) $($item.FirstName)").Trim() } + + if ($null -ne $item.JapaneseName) { + $altName = ($item.JapaneseName) + } } if ($null -eq $actressName) { if ($null -ne $item.JapaneseName) { $actressName = ($item.JapaneseName).Trim() } + $altName = $null } } + if ($AltNameRole) { + $actressNfoString = @" + + $actressName + $altName + $($item.ThumbUrl) + $altName + - $actressNfoString = @" +"@ + } else { + $actressNfoString = @" $actressName - $($item.JapaneseName) + $altName $($item.ThumbUrl) Actress "@ + } + $nfoString = $nfoString + $actressNfoString } diff --git a/src/Javinizer/Public/Javinizer.ps1 b/src/Javinizer/Public/Javinizer.ps1 index 174aa1b0..e83558db 100644 --- a/src/Javinizer/Public/Javinizer.ps1 +++ b/src/Javinizer/Public/Javinizer.ps1 @@ -532,7 +532,7 @@ function Javinizer { } if ($Nfo) { - $nfoData = $data.Data | Get-JVNfo -ActressLanguageJa:$Settings.'sort.metadata.nfo.actresslanguageja' -NameOrder:$Settings.'sort.metadata.nfo.firstnameorder' + $nfoData = $data.Data | Get-JVNfo -ActressLanguageJa:$Settings.'sort.metadata.nfo.actresslanguageja' -NameOrder:$Settings.'sort.metadata.nfo.firstnameorder' -AltNameRole:$Settings.'sort.metadata.nfo.altnamerole' Write-Output $nfoData } else { Write-Output $data.Data diff --git a/src/Javinizer/Public/Set-JVMovie.ps1 b/src/Javinizer/Public/Set-JVMovie.ps1 index bbab7b79..a36fe734 100644 --- a/src/Javinizer/Public/Set-JVMovie.ps1 +++ b/src/Javinizer/Public/Set-JVMovie.ps1 @@ -122,7 +122,11 @@ function Set-JVMovie { [Parameter(ValueFromPipelineByPropertyName = $true)] [Alias('sort.metadata.nfo.originalpath')] - [Boolean]$OriginalPath + [Boolean]$OriginalPath, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Alias('sort.metadata.nfo.altnamerole')] + [Boolean]$AltNameRole ) begin { @@ -161,6 +165,7 @@ function Set-JVMovie { $DelimiterFormat = $Settings.'sort.format.delimiter' $ActressLanguageJa = $Settings.'sort.metadata.nfo.actresslanguageja' $OriginalPath = $Settings.'sort.metadata.nfo.originalpath' + $AltNameRole = $Settings.'sort.metadata.nfo.altnamerole' } @@ -238,9 +243,9 @@ function Set-JVMovie { try { $nfoPath = Join-Path -Path $folderPath -ChildPath "$nfoName.nfo" if ($OriginalPath) { - $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -OriginalPath:$Path + $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -OriginalPath:$Path -AltNameRole:$AltNameRole } else { - $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa + $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -AltNameRole:$AltNameRole } $nfoContents | Out-File -LiteralPath $nfoPath -Force:$Force Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Nfo] created at path [$nfoPath]" diff --git a/src/Javinizer/jvSettings.json b/src/Javinizer/jvSettings.json index 7a76fa77..969a32e1 100644 --- a/src/Javinizer/jvSettings.json +++ b/src/Javinizer/jvSettings.json @@ -58,6 +58,7 @@ "sort.format.screenshotfolder": "extrafanart", "sort.format.actressimgfolder": ".actors", "sort.metadata.nfo.mediainfo": 0, + "sort.metadata.nfo.altnamerole": 0, "sort.metadata.nfo.translatedescription": 0, "sort.metadata.nfo.translatedescription.language": "en", "sort.metadata.nfo.displayname": "[] ",