Skip to content

Commit

Permalink
Add feature to use altname as actor role (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Oct 5, 2020
1 parent 3c5186f commit eb9441e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Javinizer/Private/Test-JVSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
34 changes: 31 additions & 3 deletions src/Javinizer/Public/Get-JVNfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ function Get-JVNfo {
[Boolean]$NameOrder,

[Parameter()]
[String]$OriginalPath
[String]$OriginalPath,

[Parameter()]
[Boolean]$AltNameRole
)

process {
Expand Down Expand Up @@ -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) {
Expand All @@ -171,6 +181,7 @@ function Get-JVNfo {
} else {
$actressName = ("$($item.LastName) $($item.FirstName)").Trim()
}
$altName = $null
}
}
} else {
Expand All @@ -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 = @"
<actor>
<name>$actressName</name>
<altname>$altName</altname>
<thumb>$($item.ThumbUrl)</thumb>
<role>$altName</role>
</actor>
$actressNfoString = @"
"@
} else {
$actressNfoString = @"
<actor>
<name>$actressName</name>
<altname>$($item.JapaneseName)</altname>
<altname>$altName</altname>
<thumb>$($item.ThumbUrl)</thumb>
<role>Actress</role>
</actor>
"@
}

$nfoString = $nfoString + $actressNfoString
}

Expand Down
2 changes: 1 addition & 1 deletion src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/Javinizer/Public/Set-JVMovie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'

}

Expand Down Expand Up @@ -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]"
Expand Down
1 change: 1 addition & 0 deletions src/Javinizer/jvSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[<ID>] <TITLE>",
Expand Down

0 comments on commit eb9441e

Please sign in to comment.