Skip to content

Commit

Permalink
Add translate/ignore genre functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Aug 31, 2020
1 parent a224378 commit d1a5137
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions src/Javinizer/Public/Get-JVAggregatedData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ function Get-JVAggregatedData {
[Alias('sort.metadata.thumbcsv.convertalias')]
[Boolean]$ThumbCsvAlias,
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')]
[Alias('sort.metadata.genre.normalize')]
[Boolean]$NormalizeGenre,
[Alias('sort.metadata.genre.replace')]
[Boolean]$ReplaceGenre,
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')]
[Alias('sort.metadata.genre.ignore')]
[Array]$IgnoreGenre,
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')]
[Alias('sort.metadata.requiredfield')]
[Array]$RequiredField,
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')]
[Alias('sort.metadata.maxtitlelength')]
[Int]$MaxTitleLength
[Alias('sort.metadata.nfo.translate')]
[Boolean]$Translate,
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')]
[Alias('sort.metadata.nfo.translate.language')]
[String]$TranslateLanguage
)

process {
Expand All @@ -96,6 +99,9 @@ function Get-JVAggregatedData {
$DisplayNameFormat = $Settings.'sort.metadata.nfo.displayname'
$ThumbCsv = $Settings.'sort.metadata.thumbcsv'
$ThumbCsvAlias = $Settings.'sort.metadata.thumbcsv.convertalias'
$IgnoreGenre = $Settings.'sort.metadata.genre.ignore'
$Translate = $Settings.'sort.metadata.nfo.translate'
$TranslateLanguage = $Settings.'sort.metadata.nfo.translate.language'
}

$aggregatedDataObject = [PSCustomObject]@{
Expand Down Expand Up @@ -243,7 +249,25 @@ function Get-JVAggregatedData {
}
}
} else {
Write-JLog -Level Warning -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] Thumbnail csv file is missing or cannot be found at path [$thumbCsvPath]"
Write-JLog -Level Warning -Message "[$($Data[0].Id)] Thumbnail csv file is missing or cannot be found at path [$thumbCsvPath]"
}
}

if ($IgnoreGenre) {
$ignoredGenres = $ignoreGenre -join '|'
$aggregatedDataObject.Genre = $aggregatedDataObject.Genre | Where-Object { $_ -notmatch $ignoredGenres }
}

if ($Translate) {
if ($TranslateLanguage) {
$descriptionTemp = $aggregatedDataObject.Description
$translatedDescription = Get-TranslatedString -String $descriptionTemp -Language $TranslateLanguage

if ($null -ne $translatedDescription -or $translatedDescription -ne '') {
$aggregatedDataObject.Description = $translatedDescription
}
} else {
Write-JLog -Level Warning -Message "[$($Data[0].Id)] Translation language is missing"
}
}

Expand Down

0 comments on commit d1a5137

Please sign in to comment.