Skip to content

Commit

Permalink
Updates for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Nov 6, 2020
1 parent e5d682c commit 603a558
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Javinizer/Javinizer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Invoke-JVParallel',
'Javinizer',
'Get-CfSession',
'Get-DmmData',
Expand Down
5 changes: 5 additions & 0 deletions src/Javinizer/Private/Convert-HTMLCharacter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function Convert-HTMLCharacter {
-replace '&#039', ''

$newString = $String.Trim()

if ($newString -eq '') {
$newString = $null
}

Write-Output $newString
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Invoke-Parallel {
function Invoke-JVParallel {
<#
.SYNOPSIS
Function to control parallel processing using runspaces
Expand Down Expand Up @@ -186,7 +186,10 @@ function Invoke-Parallel {

[switch]$Quiet = $false,

[switch]$IsWeb = $false
[switch]$IsWeb = $false,

[ValidateSet('search', 'sort')]
[string]$IsWebType
)
begin {
#No max queue specified? Estimate one.
Expand Down Expand Up @@ -265,8 +268,14 @@ function Invoke-Parallel {
if ($IsWeb) {
$cache:totalCount = $totalCount
$cache:completedCount = $script:completedCount
$cache:currentSort = $runspaces.object.FileName
$cache:currentSortFullName = $runspaces.object.FullName
if ($IsWebType -eq 'sort') {
$cache:currentSort = $runspaces.object.Data.Id
$cache:currentSortFullname = $runspaces.object.Path
}
if ($IsWebType -eq 'search') {
$cache:currentSort = $runspaces.object.FileName
$cache:currentSortFullName = $runspaces.object.FullName
}
}

#run through each runspace.
Expand Down
40 changes: 29 additions & 11 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ function Javinizer {
[Parameter(ParameterSetName = 'Path')]
[Switch]$IsWeb,

[Parameter(ParameterSetName = 'Path')]
[ValidateSet('Search', 'Sort')]
[String]$IsWebType,

[Parameter(ParameterSetName = 'Info', Mandatory = $true, Position = 0)]
[Alias ('f')]
[PSObject]$Find,
Expand Down Expand Up @@ -840,15 +844,25 @@ function Javinizer {
if (!($PSboundParameters.ContainsKey('IsThread'))) {
$jvModulePath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'Javinizer.psm1'
if ($PSBoundParameters.ContainsKey('IsWeb')) {
$javMovies | Invoke-Parallel -IsWeb -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$HideProgress -ScriptBlock {
Import-Module $using:jvModulePath
$jvMovie = $_
$Settings = $using:Settings
$a = Javinizer -IsThread -IsWeb -Path $jvMovie.FullName -DestinationPath $using:DestinationPath -Set $using:Set -MoveToFolder:$Settings.'sort.movetofolder' -RenameFile:$Settings.'sort.renamefile' -CfSession:$using:CfSession -Update:$using:Update -SettingsPath:$using:SettingsPath -Strict:$using:Strict -Force:$using:Force -Verbose:$using:VerbosePreference -Debug:$using:DebugPreference
Write-Output $a
if ($IsWebType -eq 'Search') {
$javMovies | Invoke-JVParallel -IsWeb -IsWebType 'search' -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$true -ScriptBlock {
Import-Module $using:jvModulePath
$jvMovie = $_
$Settings = $using:Settings
$jvData = Javinizer -IsThread -IsWeb -IsWebType $using:IsWebType -Path $jvMovie.FullName -DestinationPath $using:DestinationPath -Set $using:Set -MoveToFolder:$Settings.'sort.movetofolder' -RenameFile:$Settings.'sort.renamefile' -CfSession:$using:CfSession -Update:$using:Update -SettingsPath:$using:SettingsPath -Strict:$using:Strict -Force:$using:Force -Verbose:$using:VerbosePreference -Debug:$using:DebugPreference
Write-Output $jvData
}
} else {
$javMovies | Invoke-JVParallel -IsWeb -IsWebType 'search' -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$true -ScriptBlock {
Import-Module $using:jvModulePath
$jvMovie = $_
$Settings = $using:Settings
Javinizer -IsThread -Path $jvMovie.FullName -DestinationPath $using:DestinationPath -Set $using:Set -MoveToFolder:$Settings.'sort.movetofolder' -RenameFile:$Settings.'sort.renamefile' -CfSession:$using:CfSession -Update:$using:Update -SettingsPath:$using:SettingsPath -Strict:$using:Strict -Force:$using:Force -Verbose:$using:VerbosePreference -Debug:$using:DebugPreference
}
}

} else {
$javMovies | Invoke-Parallel -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$HideProgress -ScriptBlock {
$javMovies | Invoke-JVParallel -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$HideProgress -ScriptBlock {
Import-Module $using:jvModulePath
$jvMovie = $_
$Settings = $using:Settings
Expand All @@ -868,10 +882,14 @@ function Javinizer {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
if ($javAggregatedData.NullFields -eq '') {
if ($PSBoundParameters.ContainsKey('IsWeb')) {
[PSCustomObject]@{
Path = $movie.FullName
Data = $javAggregatedData.Data
PartNumber = $movie.PartNumber
if ($IsWebType -eq 'Search') {
[PSCustomObject]@{
Path = $movie.FullName
Data = $javAggregatedData.Data
PartNumber = $movie.PartNumber
}
} elseif ($IsWebType -eq 'Sort') {
$javAggregatedData | Set-JVMovie -Path $movie.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $movie.Partnumber -Update:$Update -Force:$Force
}
} else {
$javAggregatedData | Set-JVMovie -Path $movie.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $movie.Partnumber -Update:$Update -Force:$Force
Expand Down
11 changes: 6 additions & 5 deletions src/Javinizer/Public/Set-JVMovie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ function Set-JVMovie {
}
}

if ($OriginalPath) {
$nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -OriginalPath:$Path -AltNameRole:$AltNameRole
} else {
$nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -AltNameRole:$AltNameRole
}

if ($MoveToFolder) {
if ($DestinationPath) {
if ($outputFolderName -ne '' -and $null -ne $outputFolderName) {
Expand Down Expand Up @@ -244,11 +250,6 @@ function Set-JVMovie {
if ($CreateNfo) {
try {
$nfoPath = Join-Path -Path $folderPath -ChildPath "$nfoName.nfo"
if ($OriginalPath) {
$nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa -OriginalPath:$Path -AltNameRole:$AltNameRole
} else {
$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]"
} catch {
Expand Down
2 changes: 2 additions & 0 deletions src/Javinizer/jvSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
"javlibrary.cookie.userid": "",
"web.sort.recurse": 1,
"web.sort.strict": 0,
"web.sort.interactive": 1,
"web.sort.update": 1,
"web.navigation.pagesize": 5,
"admin.log": 1,
"admin.log.level": "info"
Expand Down

0 comments on commit 603a558

Please sign in to comment.