Skip to content

Commit

Permalink
Update throttle settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 3, 2020
1 parent 4a93682 commit ebefd35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
20 changes: 10 additions & 10 deletions src/Javinizer/Public/Get-JVData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Get-JVData {

if ($R18) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - R18] [Url - $R18Url]"
Start-ThreadJob -Name "jvdata-R18" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-R18" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:R18Url) {
$using:R18Url | Get-R18Data
Expand All @@ -110,7 +110,7 @@ function Get-JVData {

if ($R18Zh) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - R18Zh] [Url - $R18ZhUrl]"
Start-ThreadJob -Name "jvdata-R18Zh" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-R18Zh" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:R18ZhUrl) {
$using:R18ZhUrl | Get-R18Data
Expand All @@ -122,7 +122,7 @@ function Get-JVData {

if ($Javlibrary) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - Javlibrary] [Url - $JavlibraryUrl]"
Start-ThreadJob -Name "jvdata-Javlibrary" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-Javlibrary" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavlibraryUrl) {
$using:JavlibraryUrl | Get-JavlibraryData
Expand All @@ -134,7 +134,7 @@ function Get-JVData {

if ($JavlibraryJa) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - JavlibraryJa] [Url - $JavlibraryJaUrl]"
Start-ThreadJob -Name "jvdata-JavlibraryJa" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-JavlibraryJa" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavlibraryJaUrl) {
$using:JavlibraryJaUrl | Get-JavlibraryData
Expand All @@ -146,7 +146,7 @@ function Get-JVData {

if ($JavlibraryZh) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - JavlibraryZh] [Url - $JavlibraryZhUrl]"
Start-ThreadJob -Name "jvdata-JavlibraryZh" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-JavlibraryZh" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavlibraryZhUrl) {
$using:JavlibraryZhUrl | Get-JavlibraryData
Expand All @@ -158,7 +158,7 @@ function Get-JVData {

if ($Dmm) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - Dmm] [Url - $DmmUrl]"
Start-ThreadJob -Name "jvdata-Dmm" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-Dmm" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:DmmUrl) {
$using:DmmUrl | Get-DmmData
Expand All @@ -170,7 +170,7 @@ function Get-JVData {

if ($Javbus) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - Javbus] [Url - $JavbusUrl]"
Start-ThreadJob -Name "jvdata-Javbus" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-Javbus" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavbusUrl) {
$using:JavbusUrl | Get-JavbusData
Expand All @@ -182,7 +182,7 @@ function Get-JVData {

if ($JavbusJa) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - JavbusJa] [Url - $JavbusJaUrl]"
Start-ThreadJob -Name "jvdata-JavbusJa" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-JavbusJa" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavbusJaUrl) {
$using:JavbusJaUrl | Get-JavbusData
Expand All @@ -194,7 +194,7 @@ function Get-JVData {

if ($JavbusZh) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - JavbusZh] [Url - $JavbusZhUrl]"
Start-ThreadJob -Name "jvdata-JavbusZh" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-JavbusZh" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:JavbusZhUrl) {
$using:JavbusZhUrl | Get-JavbusData
Expand All @@ -206,7 +206,7 @@ function Get-JVData {

if ($Jav321) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - Jav321] [$Url - $Jav321Url]"
Start-ThreadJob -Name "jvdata-Jav321" -ThrottleLimit 25 -ScriptBlock {
Start-ThreadJob -Name "jvdata-Jav321" -ThrottleLimit 100 -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:Jav321Url) {
$using:Jav321Url | Get-Jav321Data
Expand Down
21 changes: 11 additions & 10 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Javinizer {
A command-line based tool to scrape and sort your local Japanese Adult Video (JAV) files
.DESCRIPTION
Javinizer is used to pull data from online data sources such as JAVLibrary, DMM, and R18 to aggregate data into a CMS (Plex,Emby,Jellyfin) parseable format.
Javinizer detects your local JAV files and sorts them into a CMS-readable
.PARAMETER Find
The find parameter will output a list-formatted data output from the data sources specified using a movie ID, file path, or URL.
Expand Down Expand Up @@ -61,6 +61,9 @@ function Javinizer {
[Parameter(ParameterSetName = 'Path')]
[Switch]$HideProgress,

[Parameter(ParameterSetName = 'Path')]
[Switch]$IsThread,

[Parameter(ParameterSetName = 'Info', Mandatory = $true, Position = 0)]
[Alias ('f')]
[PSObject]$Find,
Expand Down Expand Up @@ -383,27 +386,25 @@ function Javinizer {
}
}
} else {
if ($Settings.'throttlelimit' -lt 1 -or $Settings.'throttlelimit' -gt 5) {
if ($Settings.'throttlelimit' -lt 1 -or $Settings.'throttlelimit' -gt 10) {
Write-JVLog -Write $script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Setting 'scraper.throttlelimit' must be within accepted values (1-5)"
}
if ($PSBoundParameters.ContainsKey('Multi')) {

if (!($PSboundParameters.ContainsKey('IsThread'))) {
$jvModulePath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'Javinizer.psm1'
try {
$javMovies | Invoke-Parallel -MaxQueue $Settings.'throttlelimit' -Throttle $Settings.'throttlelimit' -Quiet:$HideProgress -ScriptBlock {
Import-Module $using:jvModulePath
$jvMovie = $_
Javinizer -Path $jvMovie.FullName -DestinationPath $using:DestinationPath -Set $using:Set -SettingsPath:$using:SettingsPath -Strict:$using:Strict -Force:$using:Force -Verbose:$using:VerbosePreference -Debug:$using:DebugPreference
Javinizer -IsThread -Path $jvMovie.FullName -DestinationPath $using:DestinationPath -Set $using:Set -SettingsPath:$using:SettingsPath -Strict:$using:Strict -Force:$using:Force -Verbose:$using:VerbosePreference -Debug:$using:DebugPreference
}
} catch {
Write-JVLog -Write $script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occured while starting multi sort: $PSItem"
}
} else {
$index = 1
}

if ($PSboundParameters.ContainsKey('IsThread')) {
foreach ($movie in $javMovies) {
# Write-Host "Sorting [$($movie.FileName)] as [$($movie.Id)]"
#$script:JVProgressId = Get-Random
#Write-Progress -Id $script:JVProgressId -Activity 'Javinizer' -Status "Sorting: $($movie.FullName)" -PercentComplete (1 / $script:JVProgress * 100)
$index++
$javData = Get-JVData -Id $movie.Id -Settings $Settings
if ($null -ne $javData) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
Expand Down
2 changes: 1 addition & 1 deletion src/Javinizer/jvSettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"throttlelimit": 3,
"location.input": "C:\\Downloads\\Unsorted",
"location.output": "C:\\Downloads\\Sorted",
"location.thumbcsv": "",
"location.genrecsv": "",
"location.log": "",
"scraper.throttlelimit": 3,
"scraper.movie.dmm": 1,
"scraper.movie.jav321": 0,
"scraper.movie.javbus": 0,
Expand Down

0 comments on commit ebefd35

Please sign in to comment.