Skip to content

Commit

Permalink
Update log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Aug 31, 2020
1 parent 45f8fbe commit 4290719
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 47 deletions.
16 changes: 8 additions & 8 deletions src/Javinizer/Public/Get-DmmUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,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 "Performing [GET] on URL [$searchUrl]"
Write-JLog -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 "Error [GET] on URL [$searchUrl]"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$searchUrl]"
}

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

if ($numResults -ge 1) {
Write-JLog -Level Debug -Message "Searching [$retryCount] of [$numResults] results for [$Id]"
Write-JLog -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 "Performing [GET] on URL [$result]"
Write-JLog -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 "Error [GET] on URL [$result]: $PSItem"
Write-JLog -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 "Result [$count] is [$resultId]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
if ($resultId -match $Id) {
$directUrl = $result
break
Expand All @@ -65,14 +65,14 @@ function Get-DmmUrl {
}

if ($null -eq $directUrl) {
Write-JLog -Level Warning -Message "Search [$Id] not matched on DMM"
Write-JLog -Level Warning -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Search [$Id] not matched on DMM"
return
} else {
$urlObject = [PSCustomObject]@{
Url = $directUrl
Language = 'ja'
}

Write-Output $urlObject
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Javinizer/Public/Get-JVData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function Get-JVData {

process {
$javinizerDataObject = @()
$Id = $Id.ToUpper()

if ($Settings) {
$R18 = $Settings.'scraper.movie.r18'
Expand Down Expand Up @@ -135,11 +136,11 @@ function Get-JVData {
}

# Wait-Job is used separately rather than in a pipeline due to the PowerShell.Exit job that is being created during the first-run of this function
Write-Debug "[$Id] [$($MyInvocation.MyCommand.Name)] Waiting for jobs to complete"
Write-Debug "[$Id] [$($MyInvocation.MyCommand.Name)] Waiting for scraper jobs to complete"
$jobId = @((Get-Job | Where-Object { $_.Name -like "$Id*" } | Select-Object Id).Id)
Wait-Job -Id $jobId | Out-Null

Write-Debug "[$Id] [$($MyInvocation.MyCommand.Name)] Jobs completed"
Write-Debug "[$Id] [$($MyInvocation.MyCommand.Name)] Scraper jobs completed"
$javinizerDataObject = Get-Job -Id $jobId | Receive-Job

$hasData = ($javinizerDataObject | Select-Object Source).Source
Expand Down
17 changes: 8 additions & 9 deletions src/Javinizer/Public/Get-Jav321Url.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ function Get-Jav321Url {
$searchUrl = "https://jp.jav321.com/search"

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


Expand All @@ -31,16 +30,16 @@ function Get-Jav321Url {
}

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

$count = 1
foreach ($result in $searchResults) {
$result = "https://jp.jav321.com/video/$result"
try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$result]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$result]"
$webRequest = Invoke-RestMethod -Uri $result -Method Get -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$result]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem"
}

$resultId = Get-Jav321Id -WebRequest $webRequest
Expand All @@ -49,7 +48,7 @@ function Get-Jav321Url {
break
}

Write-JLog -Level Debug -Message "Result [$count] is [$resultId]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
if ($count -eq $Tries) {
break
}
Expand All @@ -58,7 +57,7 @@ function Get-Jav321Url {
}

if ($null -eq $directUrl) {
Write-JLog -Level Warning -Message "Search [$Id] not matched on Jav321"
Write-JLog -Level Warning -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Search [$Id] not matched on Jav321"
return
} else {
$urlObject = [PSCustomObject]@{
Expand All @@ -68,7 +67,7 @@ function Get-Jav321Url {
Write-Output $urlObject
}
} else {
Write-JLog -Level Warning -Message "Search [$Id] not matched on Jav321"
Write-JLog -Level Warning -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Search [$Id] not matched on Jav321"
return
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Javinizer/Public/Get-JavbusUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ function Get-JavbusUrl {
$searchUrl = "https://www.javbus.com/search/$Id&type=0&parent=uc"

try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$searchUrl]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
try {
$searchUrl = "https://www.javbus.com/uncensored/search/$Id&type=0&parent=uc"
Write-JLog -Level Debug -Message "Performing [GET] on URL [$searchUrl]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
try {
$searchUrl = "https://www.javbus.org/search/$Id&type=0&parent=uc"
Write-JLog -Level Debug -Message "Performing [GET] on URL [$searchUrl]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
Write-JLog -Level Warning -Message "Search [$Id] not matched on JavBus"
Write-JLog -Level Warning -Message "[$Id] not matched on JavBus"
return
}
}
Expand All @@ -45,15 +45,15 @@ function Get-JavbusUrl {
}

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

$count = 1
foreach ($result in $searchResults) {
try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$result]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$result]"
$webRequest = Invoke-RestMethod -Uri $result -Method Get -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$result]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$result]: $PSItem"
}
$resultId = Get-JavbusId -WebRequest $webRequest
if ($resultId -eq $Id) {
Expand All @@ -75,7 +75,7 @@ function Get-JavbusUrl {
}

if ($null -eq $directUrl) {
Write-JLog -Level Warning -Message "Search [$Id] not matched on JavBus"
Write-JLog -Level Warning -Message "[$Id] not matched on JavBus"
return
} else {
$urlObject = [PSCustomObject]@{
Expand Down
18 changes: 9 additions & 9 deletions src/Javinizer/Public/Get-JavlibraryUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ function Get-JavlibraryUrl {
$searchUrl = "http://www.javlibrary.com/en/vl_searchbyid.php?keyword=$Id"

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

# Check if the search uniquely matched a video page
# If not, we will check the search results and check a few for if they are a match
$searchResultUrl = $webRequest.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
if ($searchResultUrl -match 'http:\/\/www\.javlibrary\.com\/en\/\?v=') {
try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]"
$webRequest = Invoke-WebRequest -Uri $searchResultUrl -Method Get -WebSession $Session -UserAgent $Session.UserAgent -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem"
}

$resultId = Get-JavlibraryId -WebRequest $webRequest
Write-JLog -Level Debug -Message "Result is [$resultId]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result is [$resultId]"
if ($resultId -eq $Id) {
$javlibraryUrl = $searchResultUrl
}
Expand All @@ -52,14 +52,14 @@ function Get-JavlibraryUrl {
$directUrl = "http://www.javlibrary.com/en/?v=$videoId"

try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]"
$webRequest = Invoke-WebRequest -Uri $directUrl -Method Get -WebSession $Session -UserAgent $Session.UserAgent -Verbose:$false
} catch {
Write-JLog -Level Error -Message "Error [GET] on URL [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem"
}

$resultId = Get-JavlibraryId -WebRequest $webRequest
Write-JLog -Level Debug -Message "Result [$count] is [$resultId]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"

if ($resultId -eq $Id) {
$javlibraryUrl = (Test-UrlLocation -Url $webRequest.BaseResponse.RequestMessage.RequestUri.AbsoluteUri).Url
Expand All @@ -76,7 +76,7 @@ function Get-JavlibraryUrl {
}

if ($null -eq $javlibraryUrl) {
Write-JLog -Level Warning -Message "Search [$Id] not matched on JAVLibrary"
Write-JLog -Level Warning -Message "[$Id] not matched on JavLibrary"
return
} else {
if ($Language -eq 'ja') {
Expand Down
22 changes: 11 additions & 11 deletions src/Javinizer/Public/Get-R18Url.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function Get-R18Url {

# Try matching the video with Video ID
try {
Write-JLog -Level Debug -Message "Performing [GET] on Uri [$searchUrl]"
Write-JLog -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 "Error [GET] on URL [$searchUrl]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchUrl]: $PSItem"
}

$retryCount = 3
Expand All @@ -53,10 +53,10 @@ function Get-R18Url {
$count = 1
foreach ($result in $searchResults) {
try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$result]"
Write-JLog -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 "Error [GET] on URL [$result]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem"
}

$resultId = Get-R18Id -WebRequest $webRequest
Expand All @@ -79,10 +79,10 @@ function Get-R18Url {
$searchUrl = "https://www.r18.com/common/search/searchword=$contentId/"

try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$searchUrl]"
Write-JLog -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 "Error [GET] on URL [$searchUrl]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchUrl]: $PSItem"
}

$retryCount = 5
Expand All @@ -96,10 +96,10 @@ function Get-R18Url {
$count = 1
foreach ($result in $altSearchResults) {
try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$result]"
Write-JLog -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 "Error [GET] on URL [$result]: $PSItem"
Write-JLog -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem"
}

$resultId = Get-R18Id -WebRequest $webRequest
Expand All @@ -122,23 +122,23 @@ function Get-R18Url {
$testUrl = "https://www.r18.com/videos/vod/movies/detail/-/id=$contentId/"

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

if ($null -ne $webRequest) {
$resultId = Get-R18Id -WebRequest $webRequest
Write-JLog -Level Debug -Message "Result is [$resultId]"
Write-JLog -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result is [$resultId]"
if ($resultId -eq $Id) {
$directUrl = $testUrl
}
}
}

if ($null -eq $directUrl) {
Write-JLog -Level Warning -Message "Search [$Id] not matched on R18"
Write-JLog -Level Warning -Message "[$Id] not matched on R18"
return
} else {
if ($Language -eq 'zh') {
Expand Down

0 comments on commit 4290719

Please sign in to comment.