Skip to content

Commit

Permalink
Add gui parameters (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Oct 18, 2020
1 parent 3bd7d72 commit 50d7841
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
26 changes: 23 additions & 3 deletions src/Javinizer/Private/Invoke-Parallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,29 @@ function Invoke-Parallel {
[PSObject]$Parameter,

[switch]$ImportVariables,

[switch]$ImportModules,

[switch]$ImportFunctions,

[int]$Throttle = 20,

[int]$SleepTimer = 200,

[int]$RunspaceTimeout = 0,

[switch]$NoCloseOnTimeout = $false,

[int]$MaxQueue,

[validatescript( { Test-Path (Split-Path $_ -parent) })]
[switch] $AppendLog = $false,
[switch]$AppendLog = $false,

[string]$LogFile,

[switch] $Quiet = $false
[switch]$Quiet = $false,

[switch]$IsWeb = $false
)
begin {
#No max queue specified? Estimate one.
Expand Down Expand Up @@ -253,6 +262,13 @@ function Invoke-Parallel {
Write-Progress -Id 2 -ParentId $ProgressId -Activity "Max threads: [$Throttle]" -Status "Sorting: $($runspaces.object.FileName -join ', ')"
}

if ($IsWeb) {
$cache:totalCount = $totalCount
$cache:completedCount = $script:completedCount
$cache:currentSort = $runspaces.object.FileName
$cache:currentSortFullName = $runspaces.object.FullName
}

#run through each runspace.
Foreach ($runspace in $runspaces) {

Expand Down Expand Up @@ -431,6 +447,10 @@ function Invoke-Parallel {
$runspacepool = [runspacefactory]::CreateRunspacePool(1, $Throttle, $sessionstate, $Host)
$runspacepool.Open()

if ($IsWeb) {
$cache:runspacepool = $runspacepool
}

#Write-Verbose "Creating empty collection to hold runspace jobs"
$runspaces = New-Object System.Collections.ArrayList

Expand Down Expand Up @@ -536,7 +556,7 @@ function Invoke-Parallel {
}
#Write-Verbose ( "Finish processing the remaining runspace jobs: {0}" -f ( @($runspaces | Where-Object { $null -ne $_.Runspace }).Count) )

Get-RunspaceData -wait
Get-RunspaceData -Wait
if (-not $quiet) {
Write-Progress -Id $ProgressId -Activity "Javinizer" -Status "Starting threads" -Completed
}
Expand Down
25 changes: 15 additions & 10 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -857,21 +857,26 @@ function Javinizer {
}

$javData = Get-JVData -Id $movie.Id -Settings $Settings -UncensorCsvPath $uncensorCsvPath -Strict:$Strict -Session:$CfSession
if ($null -ne $javData) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
if ($javAggregatedData.NullFields -eq '') {
if ($PSBoundParameters.ContainsKey('IsWeb')) {
Write-Output ($javAggregatedData).Data
} else {
if ($PSBoundParameters.ContainsKey('IsWeb')) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo
[PSCustomObject]@{
Data = $javAggregatedData.Data
Path = $movie.FullName
PartNumber = $movie.PartNumber
}
} else {
if ($null -ne $javData) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
if ($javAggregatedData.NullFields -eq '') {
$javAggregatedData | Set-JVMovie -Path $movie.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $movie.Partnumber -Update:$Update -Force:$Force
} else {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- missing required fields [$($javAggregatedData.NullFields)]"
return
}
} else {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- missing required fields [$($javAggregatedData.NullFields)]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- not matched"
return
}
} else {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- not matched"
return
}
}
}
Expand Down

0 comments on commit 50d7841

Please sign in to comment.