Skip to content

Commit

Permalink
Allow creation of multiple poster images
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 6, 2020
1 parent 56534c2 commit 5f785f5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/Javinizer/Private/Test-JVSettings.ps1
Expand Up @@ -92,7 +92,7 @@ function Test-JVSettings {
'sort.metadata.nfo.actresslanguageja',
'sort.metadata.nfo.firstnameorder',
'sort.metadata.nfo.seriesastag',
'sort.metadata.nfo.translate',
'sort.metadata.nfo.translatedescription',
'sort.metadata.thumbcsv.convertalias',
'sort.metadata.thumbcsv',
'sort.movetofolder',
Expand All @@ -119,18 +119,18 @@ function Test-JVSettings {
'sort.format.file',
'sort.format.folder',
'sort.format.nfo',
'sort.format.posterimg',
'sort.format.screenshotfolder',
'sort.format.screenshotimg',
'sort.format.thumbimg',
'sort.format.trailervid',
'sort.metadata.nfo.displayname',
'sort.metadata.nfo.translate.language'
'sort.metadata.nfo.translatedescription.language'
) | Test-JVSettingsGroup -Settings $Settings -Type String

$arraySettings = @(
'match.excludedfilestring',
'match.includedfileextension',
'sort.format.posterimg',
'sort.metadata.genre.ignore',
'sort.metadata.priority.actress',
'sort.metadata.priority.alternatetitle',
Expand Down
69 changes: 38 additions & 31 deletions src/Javinizer/Public/Set-JVMovie.ps1
Expand Up @@ -71,7 +71,7 @@ function Set-JVMovie {

[Parameter(ValueFromPipelineByPropertyName = $true)]
[Alias('sort.format.posterimg')]
[String]$PosterFormat,
[Array]$PosterFormat,

[Parameter(ValueFromPipelineByPropertyName = $true)]
[Alias('sort.format.thumbimg')]
Expand Down Expand Up @@ -158,12 +158,16 @@ function Set-JVMovie {
$fileName = Convert-JVString -Data $Data -Format $FileFormat -PartNumber $PartNumber -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$folderName = Convert-JVString -Data $Data -Format $FolderFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$thumbName = Convert-JVString -Data $Data -Format $ThumbnailFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$posterName = Convert-JVString -Data $Data -Format $PosterFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$trailerName = Convert-JVString -Data $Data -Format $TrailerFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$screenshotImgName = Convert-JVString -Data $Data -Format $ScreenshotImgFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$screenshotFolderName = Convert-JVString -Data $Data -Format $ScreenshotFolderFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
$actorFolderName = Convert-JVString -Data $Data -Format $ActorFolderFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder

$posterName = @()
foreach ($format in $PosterFormat) {
$posterName += Convert-JVString -Data $Data -Format $format -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
}

if ($CreateNfo) {
$nfoName = Convert-JVString -Data $Data -Format $NfoFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder
if ($CreateNfoPerFile) {
Expand Down Expand Up @@ -246,45 +250,48 @@ function Set-JVMovie {
try {
$cropScriptPath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'crop.py'
if (Test-Path -LiteralPath $cropScriptPath) {
$posterPath = Join-Path $folderPath -ChildPath "$posterName.jpg"
$pythonThumbPath = $thumbPath -replace '\\', '/'
$pythonPosterPath = $posterPath -replace '\\', '/'
if ($PartNumber -eq 0 -or $PartNumber -eq 1) {
if ($Force) {
if (Test-Path -LiteralPath $posterPath) {
Remove-Item -LiteralPath $posterPath -Force
}
if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') {
python $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
} elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') {
python3 $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
}
} elseif (!(Test-Path -LiteralPath $posterPath)) {
if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') {
python $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
} elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') {
python3 $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"

}
}
} else {
if (!(Test-Path -LiteralPath $posterPath)) {
Start-Sleep -Seconds 2
if (!(Test-Path -LiteralPath $posterPath)) {
foreach ($poster in $posterName) {
$posterPath = Join-Path $folderPath -ChildPath "$poster.jpg"
$pythonThumbPath = $thumbPath -replace '\\', '/'
$pythonPosterPath = $posterPath -replace '\\', '/'
if ($PartNumber -eq 0 -or $PartNumber -eq 1) {
if ($Force) {
if (Test-Path -LiteralPath $posterPath) {
Remove-Item -LiteralPath $posterPath -Force
}
if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') {
python $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
} elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') {
python3 $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
}
} elseif (!(Test-Path -LiteralPath $posterPath)) {
if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') {
python $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
} elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') {
python3 $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"

}
}
} else {
if (!(Test-Path -LiteralPath $posterPath)) {
Start-Sleep -Seconds 2
if (!(Test-Path -LiteralPath $posterPath)) {
if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') {
python $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
} elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') {
python3 $cropScriptPath $pythonThumbPath $pythonPosterPath
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Poster - $thumbPath] cropped to path [$posterPath]"
}
}
}
}
}

} else {
Write-JLog -Level Error -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] Crop.py file is missing or cannot be found at path [$cropScriptPath]"
}
Expand Down

0 comments on commit 5f785f5

Please sign in to comment.