Skip to content

Commit

Permalink
Update url scraper outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Aug 12, 2020
1 parent d7b4967 commit 7446fbf
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 23 deletions.
7 changes: 6 additions & 1 deletion src/Javinizer/Public/Get-DmmUrl.ps1
Expand Up @@ -64,6 +64,11 @@ function Get-DmmUrl {
}
}

Write-Output $directUrl
$urlObject = [PSCustomObject]@{
Url = $directUrl
Language = 'ja'
}

Write-Output $urlObject
}
}
4 changes: 2 additions & 2 deletions src/Javinizer/Public/Get-Jav321Data.ps1
@@ -1,8 +1,8 @@
function Get-Jav321Data {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Url
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Url
)

process {
Expand Down
8 changes: 6 additions & 2 deletions src/Javinizer/Public/Get-Jav321Url.ps1
Expand Up @@ -2,7 +2,7 @@ function Get-Jav321Url {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Id
[String]$Id
)

process {
Expand Down Expand Up @@ -61,7 +61,11 @@ function Get-Jav321Url {
Write-JLog -Level Warning -Message "Search [$Id] not matched on Jav321"
return
} else {
Write-Output $directUrl
$urlObject = [PSCustomObject]@{
Url = $directUrl
Language = 'ja'
}
Write-Output $urlObject
}
} else {
Write-JLog -Level Warning -Message "Search [$Id] not matched on Jav321"
Expand Down
10 changes: 6 additions & 4 deletions src/Javinizer/Public/Get-JavbusData.ps1
@@ -1,14 +1,16 @@
function Get-JavbusData {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Url
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Url,
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[ValidateSet('en', 'ja', 'zh')]
[String]$Language = 'en'
)

process {
$movieDataObject = @()


try {
Write-JLog -Level Debug -Message "Performing [GET] on URL [$Url]"
$webRequest = Invoke-RestMethod -Uri $Url -Verbose:$false
Expand All @@ -17,7 +19,7 @@ function Get-JavbusData {
}

$movieDataObject = [pscustomobject]@{
Source = 'javbus'
Source = if ($Language -eq 'en') { 'javbus' } elseif ($Language -eq 'ja') { 'javbusja' } elseif ($Language -eq 'zh') { 'javbuszh' }
Url = $Url
Id = Get-JavbusId -WebRequest $webRequest
Title = Get-JavbusTitle -WebRequest $webRequest
Expand Down
13 changes: 11 additions & 2 deletions src/Javinizer/Public/Get-JavbusUrl.ps1
Expand Up @@ -33,7 +33,11 @@ function Get-JavbusUrl {

$Tries = 5
# Get the page search results
$searchResults = (($webRequest | ForEach-Object { $_ -split '\n' } | Select-String '<a class="movie-box" href="(.*)">').Matches) | ForEach-Object { $_.Groups[1].Value }
try {
$searchResults = (($webRequest | ForEach-Object { $_ -split '\n' } | Select-String '<a class="movie-box" href="(.*)">').Matches) | ForEach-Object { $_.Groups[1].Value }
} catch {
return
}
$numResults = $searchResults.Count

if ($Tries -gt $numResults) {
Expand Down Expand Up @@ -74,7 +78,12 @@ function Get-JavbusUrl {
Write-JLog -Level Warning -Message "Search [$Id] not matched on JavBus"
return
} else {
Write-Output $directUrl
$urlObject = [PSCustomObject]@{
Url = $directUrl
Language = $Language
}

Write-Output $urlObject
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Javinizer/Public/Get-JavlibraryData.ps1
@@ -1,8 +1,11 @@
function Get-JavlibraryData {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Url
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Url,
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[ValidateSet('en', 'ja', 'zh')]
[String]$Language = 'en'
)

process {
Expand All @@ -16,7 +19,7 @@ function Get-JavlibraryData {
}

$movieDataObject = [pscustomobject]@{
Source = 'javlibrary'
Source = if ($Language -eq 'en') { 'javlibrary' } elseif ($Language -eq 'ja') { 'javlibraryja' } elseif ($Language -eq 'zh') { 'javlibraryzh' }
Url = $Url
Id = Get-JavlibraryId -WebRequest $webRequest
AjaxId = Get-JavlibraryAjaxId -WebRequest $webRequest
Expand Down
11 changes: 8 additions & 3 deletions src/Javinizer/Public/Get-JavlibraryUrl.ps1
Expand Up @@ -2,10 +2,10 @@ function Get-JavlibraryUrl {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Id,
[String]$Id,
[Parameter(Mandatory = $true, Position = 1)]
[ValidateSet('en', 'ja', 'zh')]
[string]$Language
[String]$Language
)

process {
Expand Down Expand Up @@ -85,7 +85,12 @@ function Get-JavlibraryUrl {
$javlibraryUrl = $javlibraryUrl -replace '/en/', '/cn/'
}

Write-Output $javlibraryUrl
$urlObject = [PSCustomObject]@{
Url = $javlibraryUrl
Language = $Language
}

Write-Output $urlObject
}
}
}
9 changes: 6 additions & 3 deletions src/Javinizer/Public/Get-R18Data.ps1
@@ -1,8 +1,11 @@
function Get-R18Data {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Url
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Url,
[Parameter( Position = 1, ValueFromPipelineByPropertyName = $true)]
[ValidateSet('en', 'zh')]
[String]$Language = 'en'
)

process {
Expand Down Expand Up @@ -64,7 +67,7 @@ function Get-R18Data {
}

$movieDataObject = [pscustomobject]@{
Source = 'r18'
Source = if ($Language -eq 'en') { 'r18' } elseif ($Language -eq 'zh') { 'r18zh' }
Url = $Url
ContentId = Get-R18ContentId -WebRequest $webRequest
Id = Get-R18Id -WebRequest $webRequest
Expand Down
12 changes: 9 additions & 3 deletions src/Javinizer/Public/Get-R18Url.ps1
Expand Up @@ -2,10 +2,10 @@ function Get-R18Url {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[string]$Id,
[String]$Id,
[Parameter(Mandatory = $true, Position = 1)]
[ValidateSet('en', 'zh')]
[string]$Language
[String]$Language
)

process {
Expand Down Expand Up @@ -144,7 +144,13 @@ function Get-R18Url {
if ($Language -eq 'zh') {
$directUrl = $directUrl + '&lg=zh'
}
Write-Output $directUrl

$urlObject = [PSCustomObject]@{
Url = $directUrl
Language = $Language
}

Write-Output $urlObject
}
}
}

0 comments on commit 7446fbf

Please sign in to comment.