Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0-alpha8 #79

Merged
merged 9 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.0-alpha8]

### Changed
- Default matcher now supports IDs ending with a letter (IBW-###z, KTRA-###e)
- Logging messages updated to be more consistent

### Fixed

- Jav321 scraper not running properly
- Javinizer now properly uses the thumb csv when a custom path is set in `location.thumbcsv`
- Error thrown when scraped genres are null and ignored genres are present


## [2.0.0-alpha7]

### Added
Expand All @@ -21,7 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Actresses being matched incorrectly due to false positives with FirstName/LastName matching
- Dmm match when searching for IDs ending with a letter (IBW-###z, KTRA-###e, etc)
- Dmm match when searching for IDs ending with a letter (IBW-###z, KTRA-###e)
- Error being thrown when trying to trim a null translated description
- Actress names containing backslash `\` in R18 fixed

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Choose one of the methods below:
- Install the module directly from [PowerShell Gallery](https://www.powershellgallery.com/packages/Javinizer/) using PowerShell 6/7
```powershell
# Install the module from PowerShell gallery (This will install the latest version by default)
# Add -AllowPrelease to download a preview build
# Add -AllowPrerelease to download a preview build
PS> Install-Module Javinizer

# Update the module to the newest version from PowerShell gallery
# Add -AllowPrelease to download a preview build
# Add -AllowPrerelease to download a preview build
PS> Update-Module Javinizer
```

Expand Down
2 changes: 1 addition & 1 deletion src/Javinizer/Javinizer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
ReleaseNotes = 'https://github.com/jvlflame/Javinizer/blob/master/.github/CHANGELOG.md'

# Prerelease string of this module
Prerelease = 'alpha7'
Prerelease = 'alpha8'

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false
Expand Down
53 changes: 31 additions & 22 deletions src/Javinizer/Private/Convert-JVTitle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ function Convert-JVTitle {
for ($x = 0; $x -lt $fileBaseNameUpper.Length; $x++) {
$filePartNumber = $null
#Match ID-###A, ID###B, etc.
if ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[a-dA-D]") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
if ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[a-dA-D]") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
if ($fileP3 -eq 'A') { $filePartNumber = '1' }
elseif ($fileP3 -eq 'B') { $filePartNumber = '2' }
Expand All @@ -181,8 +181,8 @@ function Convert-JVTitle {
#elseif ($fileP3 -eq 'I') { $filePartNumber = '9' }
}
# Match ID-###-A, ID-###-B, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-][a-dA-D]") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-][a-dA-D]") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$fileP3 = $fileP3 -replace '-', ''
if ($fileP3 -eq 'A') { $filePartNumber = '1' }
Expand All @@ -204,57 +204,57 @@ function Convert-JVTitle {
}
#>
# Match ID-###-1, ID-###-2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ($fileP3 -replace '-', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-###-01, ID-###-02, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]0\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]0\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = (($fileP3 -replace '-', '') -replace '0', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-###-001, ID-###-002, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]00\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]00\d$") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = (($fileP3 -replace '-', '') -replace '0', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-### - pt1, ID-### - pt2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6} [-] pt|PT") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E? [-] pt|PT") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ((($fileP3 -replace '-', '') -replace '0', '') -replace 'pt', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-### - part1, ID ### - part2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6} [-] part|PART") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E? [-] part|PART") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ((($fileP3 -replace '-', '') -replace '0', '') -replace 'pt', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-###-pt1, ID-###-pt2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]pt|PT") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]pt|PT") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ((($fileP3 -replace '-', '') -replace '0', '') -replace 'pt', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-###-part1, ID-###-part2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]part|PART") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]part|PART") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ((($fileP3 -replace '-', '') -replace '0', '') -replace 'pt', '')[1]
$filePartNumber = $filePartNum
}
# Match ID-###-cd1, ID-###-cd2, etc.
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}[-]cd|CD") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-]cd|CD") {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?)"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
$filePartNum = ((($fileP3 -replace '-', '') -replace '0', '') -replace 'cd', '')[1]
$filePartNumber = $filePartNum
Expand All @@ -263,7 +263,11 @@ function Convert-JVTitle {
# Match everything else
else {
$fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})"
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
if ($fileP3 -match '^Z' -or $fileP3 -match '^E') {
$fileBaseNameUpperCleaned += $fileP1 + $fileP2 + $fileP3
} else {
$fileBaseNameUpperCleaned += $fileP1 + $fileP2
}
}
<# if ($fileBaseNameUpper[$x] -match '([a-zA-Z|tT28]+-\d+z{0,1}Z{0,1}e{0,1}E{0,1})') {
$movieId = $fileBaseNameUpper[$x]
Expand All @@ -278,7 +282,12 @@ function Convert-JVTitle {
if ($fileBaseNameUpper[$x] -match '(([a-zA-Z|tT28|rR18]+)-(\d+z{0,1}Z{0,1}e{0,1}E{0,1}))') {
$movieId = $fileBaseNameUpperCleaned[$x]
$splitId = $fileBaseNameUpperCleaned[$x] -split '-'
$contentId = $splitId[0] + $splitId[1].PadLeft(5, '0')
if (($splitId[1])[-1] -match '\D') {
$appendChar = ($splitId[1])[-1]
$splitId[1] = $splitId[1] -replace '\D', ''
}
$contentId = $splitId[0] + $splitId[1].PadLeft(5, '0') + $appendChar
$contentId = $contentId.Trim()
} else {
$movieId = ($fileBaseNameUpperCleaned[$x] -split '\d', 3 | Where-Object { $_ -ne '' }) -join '-'
$contentId = $fileBaseNameUpperCleaned[$x]
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 @@ -12,10 +12,10 @@ function Get-DmmData {
$dmmUrl = $Url

try {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "Performing [GET] on URL [$dmmUrl]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$dmmUrl]"
$webRequest = Invoke-WebRequest -Uri $dmmUrl -Method Get -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "Error [GET] on URL [$dmmUrl]: $PSItem"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$dmmUrl]: $PSItem"
}

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

Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "DMM data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] DMM data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)"
Write-Output $movieDataObject
}
}
19 changes: 9 additions & 10 deletions src/Javinizer/Public/Get-DmmUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ function Get-DmmUrl {
)

process {
$originalId = $Id
if ($r18Url) {
$r18Id = (($r18Url -split 'id=')[1] -split '\/')[0]
$directUrl = "https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=$r18Id"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "Converting R18 Id to Dmm: [$r18Id] -> [$directUrl]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] 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})') {
$splitId = $Id -split '-'
if (($splitId[1])[-1] -match '\D') {
$appendChar = ($splitId[1])[-1]
Write-Debug $appendChar
$splitId[1] = $splitId[1] -replace '\D', ''
Write-Debug $splitId[1]
}
$Id = $splitId[0] + $splitId[1].PadLeft(5, '0') + $appendChar
$Id = $Id.Trim()
Expand All @@ -32,10 +31,10 @@ function Get-DmmUrl {
$searchUrl = "https://www.dmm.co.jp/search/?redirect=1&enc=UTF-8&category=&searchstr=$Id"

try {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-WebRequest -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 occurred on [GET] on URL [$searchUrl]: $PSItem"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$searchUrl]: $PSItem"
}

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

if ($numResults -ge 1) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$originalId]"

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

$resultId = Get-DmmContentId -WebRequest $webRequest
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] Result [$count] is [$resultId]"
if ($resultId -match "^(.*_)?\d*$Id") {
$directUrl = $result
break
Expand All @@ -75,7 +74,7 @@ function Get-DmmUrl {
}

if ($null -eq $directUrl) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$Id] not matched on DMM"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$originalId] [$($MyInvocation.MyCommand.Name)] not matched on DMM"
return
} else {
$urlObject = [PSCustomObject]@{
Expand Down
Loading