Skip to content

Commit

Permalink
Rename Write-JVLog
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 1, 2020
1 parent d1699b6 commit c6b91ce
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion src/Javinizer/Private/Convert-HTMLCharacter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Convert-HTMLCharacter {
-replace '&#039', ''

$newString = $String.Trim()
# Write-JLog -Level Debug -Message "Begin String: [$String]; End string: [$newString]"
# Write-JVLog -Level Debug -Message "Begin String: [$String]; End string: [$newString]"
Write-Output $newString
}
}
4 changes: 2 additions & 2 deletions src/Javinizer/Private/Convert-JVTitle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Convert-JVTitle {
$id = ($file | Select-String $RegexString).Matches.Groups[$RegexIdMatch].Value
$partNum = ($file | Select-String $RegexString).Matches.Groups[$RegexPtMatch].Value
} catch {
Write-JLog -Level Debug -Message "File [$file] not matched by regex"
Write-JVLog -Level Debug -Message "File [$file] not matched by regex"
break
}
if ($fileBaseNameUpper -eq 1) {
Expand Down Expand Up @@ -198,7 +198,7 @@ function Convert-JVTitle {
<#
#Match ID-###-A, ID-###-B, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-][a-iA-I]$") {
Write-JLog -Level Debug -Message "Match 3"
Write-JVLog -Level Debug -Message "Match 3"
$fileP1, $fileP2, $fileP3, $fileP4 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})[-]([a-zA-Z])"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2 + $fileP3
}
Expand Down
2 changes: 1 addition & 1 deletion src/Javinizer/Private/Get-JVUrlLocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Get-JVUrlLocation {
Source = 'jav321'
}
} else {
Write-JLog -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] [Url - $Url] not matched"
Write-JVLog -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] [Url - $Url] not matched"
}
}
Write-Output $testUrlObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Write-JLog {
function Write-JVLog {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
Expand Down
6 changes: 3 additions & 3 deletions src/Javinizer/Public/Get-DmmData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ function Get-DmmData {
$dmmUrl = $Url

try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$dmmUrl]"
Write-JVLog -Level Debug -Message "Performing [GET] on URL [$dmmUrl]"
$webRequest = Invoke-WebRequest -Uri $dmmUrl -Method Get -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$dmmUrl]: $PSItem"
Write-JVLog -Level Error -Message "Error [GET] on URL [$dmmUrl]: $PSItem"
}

$movieDataObject = [PSCustomObject]@{
Expand All @@ -38,7 +38,7 @@ function Get-DmmData {
#TrailerUrl = Get-DmmTrailerUrl -WebRequest $webRequest
}

Write-JLog -Level Debug -Message "DMM data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-JVLog -Level Debug -Message "DMM data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-Output $movieDataObject
}
}
16 changes: 8 additions & 8 deletions src/Javinizer/Public/Get-DmmUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Get-DmmUrl {
if ($r18Url) {
$r18Id = (($r18Url -split 'id=')[1] -split '\/')[0]
$directUrl = "https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=$r18Id"
Write-JLog -Level Debug -Message "Converting R18 Id to Dmm: [$r18Id] -> [$directUrl]"
Write-JVLog -Level Debug -Message "Converting R18 Id to Dmm: [$r18Id] -> [$directUrl]"
} else {
# Convert the movie Id (ID-###) to content Id (ID00###) to match dmm naming standards
if ($Id -match '([a-zA-Z|tT28|rR18]+-\d+z{0,1}Z{0,1}e{0,1}E{0,1})') {
Expand All @@ -23,10 +23,10 @@ function Get-DmmUrl {
$searchUrl = "https://www.dmm.co.jp/search/?redirect=1&enc=UTF-8&category=&searchstr=$Id"

try {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-WebRequest -Uri $searchUrl -Method Get -Verbose:$false
} catch {
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$searchUrl]"
Write-JVLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$searchUrl]"
}

$retryCount = 3
Expand All @@ -38,19 +38,19 @@ function Get-DmmUrl {
}

if ($numResults -ge 1) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"

$count = 1
foreach ($result in $searchResults) {
try {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$result]"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$result]"
$webRequest = Invoke-WebRequest -Uri $result -Method Get -Verbose:$false
} catch {
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$result]: $PSItem"
Write-JVLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$result]: $PSItem"
}

$resultId = Get-DmmContentId -WebRequest $webRequest
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
if ($resultId -match $Id) {
$directUrl = $result
break
Expand All @@ -66,7 +66,7 @@ function Get-DmmUrl {
}

if ($null -eq $directUrl) {
Write-JLog -Level Warning -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Search [$Id] not matched on DMM"
Write-JVLog -Level Warning -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Search [$Id] not matched on DMM"
return
} else {
$urlObject = [PSCustomObject]@{
Expand Down
14 changes: 7 additions & 7 deletions src/Javinizer/Public/Get-JVAggregatedData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function Get-JVAggregatedData {
} else {
$aggregatedDataObject.$field = $sourceData.$field
}
Write-JLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [$field - $priority] Set to [$($sourceData.$field | ConvertTo-Json -Compress)]"
Write-JVLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [$field - $priority] Set to [$($sourceData.$field | ConvertTo-Json -Compress)]"
}
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ function Get-JVAggregatedData {
$aggregatedDataObject.Actress[$x].LastName = $actressCsv[$matched[0].Index].LastName
}

Write-JLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [Alias - $aliasString] replaced by [$actressString]"
Write-JVLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [Alias - $aliasString] replaced by [$actressString]"
}
}

Expand All @@ -236,7 +236,7 @@ function Get-JVAggregatedData {
$aggregatedDataObject.Actress[$x].ThumbUrl = $matchedActress.ThumbUrl
$aggregatedDataObject.Actress[$x].JapaneseName = $matchedActress.JapaneseName
$actressString = "$($aggregatedDataObject.Actress[$x].LastName) $($aggregatedDataObject.Actress[$x].FirstName)".Trim()
Write-JLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
Write-JVLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
}
# Check if JapaneseName matches the thumb csv
} elseif ($matched = Compare-Object -ReferenceObject $actressCsv -DifferenceObject $aggregatedDataObject.Actress[$x] -IncludeEqual -ExcludeDifferent -PassThru -Property @('JapaneseName')) {
Expand All @@ -252,7 +252,7 @@ function Get-JVAggregatedData {
$aggregatedDataObject.Actress[$x].LastName = $matchedActress.LastName
$aggregatedDataObject.Actress[$x].ThumbUrl = $matchedActress.ThumbUrl
$actressString = "$($aggregatedDataObject.Actress[$x].JapaneseName)".Trim()
Write-JLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
Write-JVLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
}
# Check if FirstName matches the thumb csv for single-word names
} elseif ($null -eq $aggregatedDataObject.Actress[$x].LastName -and $null -ne $aggregatedDataObject.Actress[$x].FirstName) {
Expand All @@ -269,12 +269,12 @@ function Get-JVAggregatedData {
$aggregatedDataObject.Actress[$x].ThumbUrl = $matchedActress.ThumbUrl
$aggregatedDataObject.Actress[$x].JapaneseName = $matchedActress.JapaneseName
$actressString = "$($aggregatedDataObject.Actress[$x].FirstName)".Trim()
Write-JLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
Write-JVLog -Level Debug -Message "[$($Data[0].Id)] [$($MyInvocation.MyCommand.Name)] [ThumbUrl - $($matchedActress.ThumbUrl)] added to actress [$actressString]"
}
}
}
} else {
Write-JLog -Level Warning -Message "[$($Data[0].Id)] Thumbnail csv file is missing or cannot be found at path [$thumbCsvPath]"
Write-JVLog -Level Warning -Message "[$($Data[0].Id)] Thumbnail csv file is missing or cannot be found at path [$thumbCsvPath]"
}
}

Expand All @@ -292,7 +292,7 @@ function Get-JVAggregatedData {
$aggregatedDataObject.Description = $translatedDescription
}
} else {
Write-JLog -Level Warning -Message "[$($Data[0].Id)] Translation language is missing"
Write-JVLog -Level Warning -Message "[$($Data[0].Id)] Translation language is missing"
}
}

Expand Down
26 changes: 13 additions & 13 deletions src/Javinizer/Public/Get-JVData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,79 +70,79 @@ function Get-JVData {
$jvModulePath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'Javinizer.psm1'

if ($R18) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching R18"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching R18"
Start-ThreadJob -Name "$Id-R18" -ScriptBlock {
Import-Module $using:jvModulePath
Get-R18Url -Id $using:Id -Language en | Get-R18Data
} | Out-Null
}

if ($R18Zh) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching R18Zh"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching R18Zh"
Start-ThreadJob -Name "$Id-R18Zh" -ScriptBlock {
Import-Module $using:jvModulePath
Get-R18Url -Id $using:Id -Language zh | Get-R18Data
} | Out-Null
}

if ($Javlibrary) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Javlibrary"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Javlibrary"
Start-ThreadJob -Name "$Id-Javlibrary" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavlibraryUrl -Id $using:Id -Language en | Get-JavlibraryData
} | Out-Null
}

if ($JavlibraryJa) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavlibraryJa"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavlibraryJa"
Start-ThreadJob -Name "$Id-JavlibraryJa" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavlibraryUrl -Id $using:Id -Language ja | Get-JavlibraryData
} | Out-Null
}

if ($JavlibraryZh) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavlibraryZh"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavlibraryZh"
Start-ThreadJob -Name "$Id-JavlibraryZh" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavlibraryUrl -Id $using:Id -Language zh | Get-JavlibraryData
} | Out-Null
}

if ($Dmm) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Dmm"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Dmm"
Start-ThreadJob -Name "$Id-Dmm" -ScriptBlock {
Import-Module $using:jvModulePath
Get-DmmUrl -Id $using:Id | Get-DmmData
} | Out-Null
}

if ($Javbus) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Javbus"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Javbus"
Start-ThreadJob -Name "$Id-Javbus" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavbusUrl -Id $using:Id -Language en | Get-JavbusData
} | Out-Null
}

if ($JavbusJa) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavbusJa"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavbusJa"
Start-ThreadJob -Name "$Id-JavbusJa" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavbusUrl -Id $using:Id -Language ja | Get-JavbusData
} | Out-Null
}

if ($JavbusZh) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavbusZh"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching JavbusZh"
Start-ThreadJob -Name "$Id-JavbusZh" -ScriptBlock {
Import-Module $using:jvModulePath
Get-JavbusUrl -Id $using:Id -Language zh | Get-JavbusData
} | Out-Null
}

if ($Jav321) {
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Jav321"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching Jav321"
Start-ThreadJob -Name "$Id-Jav321" -ScriptBlock {
Import-Module $using:jvModulePath
Get-Jav321Url -Id $using:Id | Get-Jav321Data
Expand All @@ -158,7 +158,7 @@ function Get-JVData {
$javinizerDataObject = Get-Job -Id $jobId | Receive-Job

$hasData = ($javinizerDataObject | Select-Object Source).Source
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Data successfully retrieved from sources [$hasData]"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Data successfully retrieved from sources [$hasData]"

$dataObject = [PSCustomObject]@{
Data = $javinizerDataObject
Expand All @@ -167,11 +167,11 @@ function Get-JVData {
Write-Output $dataObject

} catch {
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured during scraper jobs: $PSItem"
Write-JVLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured during scraper jobs: $PSItem"
} finally {
# Remove all completed or running jobs before exiting this script
# If jobs remain after closure, it may cause issues in concurrent runs
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Stopping/removing all completed/running jobs"
Write-JVLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Stopping/removing all completed/running jobs"
Get-Job | Remove-Job -Force
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Javinizer/Public/Get-Jav321Data.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function Get-Jav321Data {
$movieDataObject = @()

try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$Url]"
Write-JVLog -Level Debug -Message "Performing [GET] on URL [$Url]"
$webRequest = Invoke-RestMethod -Uri $Url -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$Url]: $PSItem"
Write-JVLog -Level Error -Message "Error [GET] on URL [$Url]: $PSItem"
}

$movieDataObject = [PSCustomObject]@{
Expand All @@ -31,7 +31,7 @@ function Get-Jav321Data {
ScreenshotUrl = Get-Jav321ScreenshotUrl -WebRequest $webRequest
}

Write-JLog -Level Debug -Message "Jav321 data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-JVLog -Level Debug -Message "Jav321 data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-Output $movieDataObject
}
}
Loading

0 comments on commit c6b91ce

Please sign in to comment.