Skip to content

Commit

Permalink
Fix actress name order on dmm scraper (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Dec 14, 2020
1 parent 87bd17a commit e8600f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
33 changes: 22 additions & 11 deletions src/Javinizer/Private/Scraper.Javbus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ function Get-JavbusActress {
foreach ($actress in $actresses) {
$baseUrl = ($actress.Groups[1].Value) -replace '/ja', '' -replace '/en', ''
if ($baseUrl -match '/uncensored') {
$engActressUrl = "https://www.javbus.com/en/uncensored/star/$($actress.Groups[2].Value)"
$enActressUrl = "https://www.javbus.com/en/uncensored/star/$($actress.Groups[2].Value)"
$jaActressUrl = "https://www.javbus.com/ja/uncensored/star/$($actress.Groups[2].Value)"
} else {
$engActressUrl = "$baseUrl/en/star/$($actress.Groups[2].Value)"
$enActressUrl = "$baseUrl/en/star/$($actress.Groups[2].Value)"
$jaActressUrl = "$baseUrl/ja/star/$($actress.Groups[2].Value)"
}

Expand All @@ -239,19 +239,25 @@ function Get-JavbusActress {
# Match if the name contains Japanese characters
if ($actressName -match '[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff66-\uff9f]|[\u4e00-\u9faf]') {
try {
$engActressName = ((Invoke-RestMethod -Uri $engactressUrl | Select-String -Pattern '<title>(.*)<\/title>').Matches.Groups[1].Value -split '-')[0].Trim()
$wr = Invoke-RestMethod -Uri $enActressUrl | Out-Null
$enActressName = (($wr | Select-String -Pattern '<title>(.*)<\/title>').Matches.Groups[1].Value -split '-')[0].Trim()
} catch {
$engActressName = $null
$enActressName = $null
}

if ($engActressName -notmatch '[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff66-\uff9f]|[\u4e00-\u9faf]') {
$nameParts = ($engActressName -split ' ').Count
if ($enActressName -notmatch '[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff66-\uff9f]|[\u4e00-\u9faf]') {
$nameParts = ($enActressName -split ' ').Count
if ($nameParts -eq 1) {
$lastName = $null
$firstName = $engActressName
$firstName = $enActressName
} else {
$lastName = ($engActressName -split ' ')[0]
$firstName = ($engActressName -split ' ')[1]
if ($wr -match 'D\.O\.B:') {
$lastName = ($enActressName -split ' ')[0]
$firstName = ($enActressName -split ' ')[1]
} else {
$lastName = ($enActressName -split ' ')[1]
$firstName = ($enActressName -split ' ')[0]
}
}

if ($null -ne $firstName) {
Expand Down Expand Up @@ -284,8 +290,13 @@ function Get-JavbusActress {
$lastName = $null
$firstName = $actressName
} else {
$lastName = ($actressName -split ' ')[0]
$firstName = ($actressName -split ' ')[1]
if ($wr -match 'D\.O\.B:') {
$lastName = ($actressName -split ' ')[0]
$firstName = ($actressName -split ' ')[1]
} else {
$lastName = ($actressName -split ' ')[1]
$firstName = ($actressName -split ' ')[0]
}
}

if ($null -ne $firstName) {
Expand Down
9 changes: 3 additions & 6 deletions src/Javinizer/Public/Get-JavbusUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ function Get-JavbusUrl {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
try {
Start-Sleep -Seconds 3
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchUrl]: $PSItem" -Action 'Continue'
}
# Do nothing
}

$retryCount = 3
Expand Down Expand Up @@ -67,6 +62,7 @@ function Get-JavbusUrl {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
# Do nothing
}

$retryCount = 3
Expand Down Expand Up @@ -117,6 +113,7 @@ function Get-JavbusUrl {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
# Do nothing
}

$retryCount = 3
Expand Down

0 comments on commit e8600f7

Please sign in to comment.