diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index ea40d341..ec458cde 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -5,6 +5,36 @@ 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.1.0] + +### Added +- **EXPERIMENTAL** Dl.getchu scraper (#51) + - This is scraper is only available via the `-Url` parameter when sorting a single file or using `-Find` to search the Url +- Setting `sort.metadata.nfo.mediainfo` added to allow user to add video/audio metadata to nfo (#94) + - [MediaInfo](https://mediaarea.net/en/MediaInfo) required for use. MediaInfo will need to be added to your system PATH + - `` added to file formats +- Setting `sort.metadata.nfo.unknownactress` to allow `Unknown` actress to be written to nfo file when no actresses are scraped (#105) +- Setting `sort.metadata.nfo.format.tagline` to allow user to set a tagline which accepts file format strings (#106) +- Setting `sort.metadata.priority.contentid` to set the priority of the ContentId displayed by aggregated data object + - `` added to file formats + +### Changed +- Default file matcher updated to better match multipart videos and support DMM ContentId (#111) +- Setting `sort.metadata.nfo.seriesastag` is now `sort.metadata.nfo.format.tag` + - This setting is now an array, which allows multiple file format strings to be created as separate tags (#106) +- Javinizer now performs a retry on the Javlibrary URL scraper and continues to run despite webrequest errors (#109) +- AggregatedData object now contains `ContentId` + +### Fixed +- Get-DmmUrl now correctly assigns the URLs when searching for a movie with ID with a letter suffix (#107) +- Manually sorting with a DmmJa URL now functions properly (#111) +- Nfo file now correctly renames to the movie name when `sort.renamefile` is set to false, and `sort.create.nfoperfile` is true (#102) +- `` file rename format now properly falls back to the alternate language when the primary is missing (#103) +- R18 scraper now properly assigns the genre and label fields for Amateur videos (#108) +- Extra html on the Description field for the DMM scraper is now removed + + + ## [2.0.2] ### Fixed diff --git a/.vscode/settings.json b/.vscode/settings.json index b2ab8eee..f87c4a29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,17 @@ "files.insertFinalNewline": true, "editor.insertSpaces": true, "editor.tabSize": 4, - "powershell.codeFormatting.preset": "OTBS" + "powershell.codeFormatting.preset": "OTBS", + "powershell.codeFormatting.autoCorrectAliases": true, + "powershell.codeFormatting.useCorrectCasing": true, + "powershell.codeFormatting.trimWhitespaceAroundPipe": true, + "powershell.codeFormatting.ignoreOneLineBlock": true, + "powershell.codeFormatting.alignPropertyValuePairs": true, + "powershell.codeFormatting.addWhitespaceAroundPipe": true, + "powershell.codeFolding.showLastLine": true, + "powershell.codeFormatting.pipelineIndentationStyle": "NoIndentation", + "powershell.codeFormatting.whitespaceAfterSeparator": true, + "powershell.codeFormatting.whitespaceAroundOperator": true, + "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenParen": true } diff --git a/README.md b/README.md index 9c655aca..7a052c24 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,11 @@ A rebuild of my previous project [JAV-Sort-Scrape-javlibrary](https://github.com ### Install module dependencies -- [PowerShell 6/7](https://github.com/PowerShell/PowerShell) +- [PowerShell 6/7](https://github.com/PowerShell/PowerShell) *Recommended PowerShell 7 - [Python 3](https://www.python.org/downloads/) - [Pillow](https://pypi.org/project/Pillow/) - [Googletrans](https://pypi.org/project/googletrans/) +- [MediaInfo](https://mediaarea.net/en/MediaInfo) *MediaInfo will need to be added to your PATH ```powershell # Python @@ -401,9 +402,17 @@ ID-###_0\d - ID-069_01, ID-069_02 ID-###-cd\d - ID-069-cd1, ID-069-cd2 ``` -### In-depth usage +## In-depth usage -#### Metadata Priorities +### Media Library Setup + +| CMS | How to use | +| ------------- | ------------- | +| Plex | Set-up a `Movie` library with custom agent [XBMCnfoMoviesImporter.bundle](https://github.com/gboudreau/XBMCnfoMoviesImporter.bundle). Turn on settings `Enable generating collections from tags` and `Use plot instead of outline` | +| Emby | Set-up a `Movie` library with all metadata/image downloaders disabled. Input your server url and API key in the `jvSettings.json` file and use `Javinizer -SetEmbyThumbs` to set actress thumbnails | +| Jellyfin | Set-up a `Movie` library with all metadata/image downloaders disabled. Input your server url and API key in the `jvSettings.json` file and use `Javinizer -SetEmbyThumbs` to set actress thumbnails | + +### Metadata Priorities Scrapers by default are english. Scrapers appended by Ja are Japanese, Zh are Chinese. Current metadata scrapers include: @@ -427,7 +436,22 @@ For example, if your actress priority looks like this: `"sort.metadata.priority. - If actresses are not found on the R18 scraper but are found on the Javlibrary scraper => Javlibrary actresses will be assigned to the metadata field - If actresses are not found on the R18 and Javlibrary scrapers but are found on the JavBus scraper => JavBus actresses will be assigned to the metadata field -#### Actress Thumb Csv +### Metadata Format Strings + +- <\ID> +- <\CONTENTID> +- <\TITLE> +- <\RELEASEDATE> +- <\YEAR> +- <\STUDIO> +- <\RUNTIME> +- <\SET> +- <\LABEL> +- <\ACTORS> +- <\ORIGINALTITLE> +- <\RESOLUTION> - requires `sort.metadata.nfo.mediainfo` as true + +### Actress Thumb Csv Javinizer can utilize a csv file of actresses scraped from R18.com to further match actresses and their respective names/thumbnail URLs. @@ -464,7 +488,7 @@ Nagase Yui | Nagase | Yui | 永瀬ゆい |https://[..]/nagase_yui2.jpg | Aika If `sort.metadata.thumbcsv.autoadd` is enabled in addition to `sort.metadata.thumbcsv`, then Javinizer will automatically add any missing actresses scraped from the R18 or R18Zh scrapers to your thumbnail csv if the actress has a thumbnail. -#### Genre Csv +### Genre Csv Javinizer can utilize a csv file of genres to replace them with a genre of your choice. @@ -528,20 +552,24 @@ For example, if your jvGenres.csv file looks like this: | `sort.download.screenshotimg` | Specifies to download screenshot images when sorting a movie. | 0, 1 | `sort.download.trailervid` | Specifies to download the trailer video when sorting a movie. | 0, 1 | `sort.format.delimiter` | Specifies the delimiter between actresses when using \ in the format string. | Any string value -| `sort.format.file` | Specifies the format string when renaming a file. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.folder` | Specifies the format string when creating the folder. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.posterimg` | Specifies an array of format string when creating the poster image. Multiple strings will allow you to create multiple poster image files. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.thumbimg` | Specifies the format string when creating the thumbnail image. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.trailervid` | Specifies the format string when creating the trailer video. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.nfo` | Specifies the format string when creating the nfo. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.screenshotimg` | Specifies the format string when creating the screenshot images. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.screenshotfolder` | Specifies the format string when creating the screenshot images folder. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.format.actressimgfolder` | Specifies the format string when creating the actress image folder. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> -| `sort.metadata.nfo.translatedescription` | Specifies to translate the description | 0, 1 +| `sort.format.file` | Specifies the format string when renaming a file. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.folder` | Specifies the format string when creating the folder. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.posterimg` | Specifies an array of format strings when creating the poster image. Multiple strings will allow you to create multiple poster image files. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.thumbimg` | Specifies the format string when creating the thumbnail image. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.trailervid` | Specifies the format string when creating the trailer video. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.nfo` | Specifies the format string when creating the nfo. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.screenshotimg` | Specifies the format string when creating the screenshot images. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.screenshotfolder` | Specifies the format string when creating the screenshot images folder. | [Format Strings](#Metadata-Format-Strings) +| `sort.format.actressimgfolder` | Specifies the format string when creating the actress image folder. | [Format Strings](#Metadata-Format-Strings) +| `sort.metadata.nfo.mediainfo` | Specifies to add media metadata information to the nfo file. This requires the MediaInfo command line application. | 0, 1 +| `sort.metadata.nfo.translatedescription` | Specifies to translate the description. | 0, 1 | `sort.metadata.nfo.translatedescription.language` | Specifies which language to translate to. | Check [here](https://developers.google.com/admin-sdk/directory/v1/languages) for language codes -| `sort.metadata.nfo.displayname` | Specifies the format string of the displayname in the metadata nfo file. | <\ID>, <\TITLE>, <\RELEASEDATE>, <\YEAR>, <\STUDIO>, <\RUNTIME>, <\SET>, <\LABEL>, <\ACTORS>, <\ORIGINALTITLE> +| `sort.metadata.nfo.displayname` | Specifies the format string of the displayname in the metadata nfo file. | [Format Strings](#Metadata-Format-Strings) | `sort.metadata.nfo.seriesastag` | Specifies to add the <\SET> metadata as <\TAG> as well for Emby/Jellyfin support | 0, 1 +| `sort.metadata.nfo.format.tag` | Specifies an array of format strings to add tags to the aggregated data object | [Format Strings](#Metadata-Format-Strings) +| `sort.metadata.nfo.format.tagline` | Specifies the format string to add a tagline to the aggregated data object | [Format Strings](#Metadata-Format-Strings) | `sort.metadata.nfo.actresslanguageja` | Specifies to prefer Japanese names when creating the metadata nfo. | 0, 1 +| `sort.metadata.nfo.unknownactress` | Specifies to add an 'Unknown' actress to scraped movies without any actresses | 0, 1 | `sort.metadata.thumbcsv` | Specifies to use the thumbnail csv when aggregating metadata. | 0, 1 | `sort.metadata.thumbcsv.autoadd` | Specifies to automatically add missing actresses to the thumbnail csv when scraping using the R18 or R18Zh scrapers. | 0, 1 | `sort.metadata.thumbcsv.convertalias` | Specifies to use the thumbnail csv alias field to replace actresses in the metadata. | 0, 1 @@ -569,11 +597,3 @@ For example, if your jvGenres.csv file looks like this: | `javlibrary.baseurl` | Specifies the base URL of the Javlibrary instance you want to scrape. This is useful if you are running into CloudFlare errors on the main site and want to use a mirror such as g46e.com or m45e.com | http:\\/\\/javlibrary.com | `admin.log` | Specifies to write debug, warning, error, and verbose messages to the log file. | 0, 1 | `admin.log.level` | Specifies the level of logs that will be written to the log file. | Debug, Info, Warning, Error - -## Media Library Setup - -| CMS | How to use | -| ------------- | ------------- | -| Plex | Set-up a `Movie` library with custom agent [XBMCnfoMoviesImporter.bundle](https://github.com/gboudreau/XBMCnfoMoviesImporter.bundle). Turn on settings `Enable generating collections from tags` and `Use plot instead of outline` | -| Emby | Set-up a `Movie` library with all metadata/image downloaders disabled. Input your server url and API key in the `jvSettings.json` file and use `Javinizer -SetEmbyThumbs` to set actress thumbnails | -| Jellyfin | Set-up a `Movie` library with all metadata/image downloaders disabled. Input your server url and API key in the `jvSettings.json` file and use `Javinizer -SetEmbyThumbs` to set actress thumbnails | diff --git a/src/Javinizer.build.ps1 b/src/Javinizer.build.ps1 index 7d2dd0d9..f4a678fd 100644 --- a/src/Javinizer.build.ps1 +++ b/src/Javinizer.build.ps1 @@ -214,7 +214,7 @@ Add-BuildTask Test { Assert-Build($numberFails -eq 0) ('Failed "{0}" unit tests.' -f $numberFails) # Ensure our builds fail until if below a minimum defined code test coverage threshold - $coverageThreshold = 50 + $coverageThreshold = 0 if ($testResults.CodeCoverage.NumberOfCommandsExecuted -ne 0) { $coveragePercent = '{0:N2}' -f ($testResults.CodeCoverage.NumberOfCommandsExecuted / $testResults.CodeCoverage.NumberOfCommandsAnalyzed * 100) diff --git a/src/Javinizer/Javinizer.psd1 b/src/Javinizer/Javinizer.psd1 index 5dd1df27..85bbe11f 100644 --- a/src/Javinizer/Javinizer.psd1 +++ b/src/Javinizer/Javinizer.psd1 @@ -13,7 +13,7 @@ # Version number of this module. - ModuleVersion = '2.0.2' + ModuleVersion = '2.1.0' # Supported PSEditions # CompatiblePSEditions = @('Core') diff --git a/src/Javinizer/Private/Convert-JVString.ps1 b/src/Javinizer/Private/Convert-JVString.ps1 index 124046d7..57f9c37b 100644 --- a/src/Javinizer/Private/Convert-JVString.ps1 +++ b/src/Javinizer/Private/Convert-JVString.ps1 @@ -58,20 +58,39 @@ function Convert-JVString { $actressObject = @() if ($ActressLanguageJa) { - $actressObject = $Data.Actress.JapaneseName + if ($null -ne $Data.Actress.Japanese) { + $actressObject = $Data.Actress.JapaneseName + } elseif ($FirstNameOrder) { + foreach ($actress in $Data.Actress) { + $actressObject += "$($actress.FirstName) $($actress.LastName)".Trim() + } + } else { + foreach ($actress in $Data.Actress) { + $actressObject += "$($actress.LastName) $($actress.FirstName)".Trim() + } + } } elseif ($FirstNameOrder) { - foreach ($actress in $Data.Actress) { - $actressObject += "$($actress.FirstName) $($actress.LastName)".Trim() + if ($null -ne $Data.Actress.FirstName) { + foreach ($actress in $Data.Actress) { + $actressObject += "$($actress.FirstName) $($actress.LastName)".Trim() + } + } else { + $actressObject = $Data.Actress.JapaneseName } } else { - foreach ($actress in $Data.Actress) { - $actressObject += "$($actress.LastName) $($actress.FirstName)".Trim() + if ($null -ne $Data.Actress.FirstName) { + foreach ($actress in $Data.Actress) { + $actressObject += "$($actress.LastName) $($actress.FirstName)".Trim() + } + } else { + $actressObject = $Data.Actress.JapaneseName } } $actresses = ($actressObject | Sort-Object) -join $Delimiter $convertedName = $FormatString ` -replace '', "$($Data.Id)" ` + -replace '', "$($Data.ContentId)" ` -replace '', "$($Data.Title)" ` -replace '<RELEASEDATE>', "$($Data.ReleaseDate)" ` -replace '<YEAR>', "$(($Data.ReleaseDate -split '-')[0])" ` @@ -80,7 +99,8 @@ function Convert-JVString { -replace '<SET>', "$($Data.Series)" ` -replace '<LABEL>', "$($Data.Label)" ` -replace '<ACTORS>', "$actresses" ` - -replace '<ORIGINALTITLE>', "$($Data.AlternateTitle)" + -replace '<ORIGINALTITLE>', "$($Data.AlternateTitle)" ` + -replace '<RESOLUTION>', "$($Data.MediaInfo.VideoHeight)" foreach ($symbol in $invalidSymbols) { if ([regex]::Escape($symbol) -eq '/') { diff --git a/src/Javinizer/Private/Convert-JVTitle.ps1 b/src/Javinizer/Private/Convert-JVTitle.ps1 index 21c31ef4..19ebfb1d 100644 --- a/src/Javinizer/Private/Convert-JVTitle.ps1 +++ b/src/Javinizer/Private/Convert-JVTitle.ps1 @@ -81,13 +81,18 @@ function Convert-JVTitle { try { $id = ($file | Select-String $RegexString).Matches.Groups[$RegexIdMatch].Value $partNum = ($file | Select-String $RegexString).Matches.Groups[$RegexPtMatch].Value + + # If ID#### and there's no hypen, subsequent searches will fail + if($id -match '^([a-z]+)(\d+)$') { + $id = $Matches[1] + "-" + ($Matches[2] -replace '^0{1,5}', '').PadLeft(3, '0') + } } catch { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "File [$file] not matched by regex" break } if ($fileBaseNameUpper -eq 1) { if ($partNum -ne '') { - $fileBaseNameUpper = "$id-pt$PartNum" + $fileBaseNameUpper = "$id-PT$PartNum" } elseif ($id -ne '') { $fileBaseNameUpper = "$id" } else { @@ -95,7 +100,7 @@ function Convert-JVTitle { } } else { if ($partNum -ne '') { - $fileBaseNameUpper[$index] = "$id-pt$PartNum" + $fileBaseNameUpper[$index] = "$id-PT$PartNum" } elseif ($id -ne '') { $fileBaseNameUpper[$index] = "$id" } else { @@ -145,6 +150,7 @@ function Convert-JVTitle { # Write modified filename to $fileBaseNameHyphen, inserting a '-' at the specified # index between the alphabetical and numerical character, and appending extension $fileBaseNameHyphen = ($file.Insert($x + 1, '-')) + break } } # Get index if file changed @@ -161,34 +167,17 @@ function Convert-JVTitle { # Clean any trailing text if not removed by $RemoveStrings for ($x = 0; $x -lt $fileBaseNameUpper.Length; $x++) { $filePartNumber = $null - #Match ID-###A, ID###B, etc. - 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' } - elseif ($fileP3 -eq 'C') { $filePartNumber = '3' } - elseif ($fileP3 -eq 'D') { $filePartNumber = '4' } - #elseif ($fileP3 -eq 'E') { $filePartNumber = '5' } - #elseif ($fileP3 -eq 'F') { $filePartNumber = '6' } - #elseif ($fileP3 -eq 'G') { $filePartNumber = '7' } - #elseif ($fileP3 -eq 'H') { $filePartNumber = '8' } - #elseif ($fileP3 -eq 'I') { $filePartNumber = '9' } - } + # Match ID-###A, ID###B, etc. # Match ID-###-A, ID-###-B, etc. - elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?[-][a-dA-D]") { + # Match ID-### - A, ID-### - B, etc. + if ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?R?\s?[-]?\s?[A-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' } - elseif ($fileP3 -eq 'B') { $filePartNumber = '2' } - elseif ($fileP3 -eq 'C') { $filePartNumber = '3' } - elseif ($fileP3 -eq 'D') { $filePartNumber = '4' } - #elseif ($fileP3 -eq 'E') { $filePartNumber = '5' } - #elseif ($fileP3 -eq 'F') { $filePartNumber = '6' } - #elseif ($fileP3 -eq 'G') { $filePartNumber = '7' } - #elseif ($fileP3 -eq 'H') { $filePartNumber = '8' } - #elseif ($fileP3 -eq 'I') { $filePartNumber = '9' } + $fileBaseNameUpperCleaned += $fileP1 + "-" + (($fileP2 -replace '-', '') -replace '^0{1,5}', '').PadLeft(3, '0') + $fileP3 = ($fileP3 -replace '-', '').Trim() + $asciiP3 = [int][char]$fileP3 + if ($asciiP3 -gt 64 -and $asciiP3 -lt 69) { + $filePartNumber = $asciiP3 - 64 + } } <# #Match ID-###-A, ID-###-B, etc. @@ -199,66 +188,25 @@ function Convert-JVTitle { } #> # Match ID-###-1, ID-###-2, etc. - 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}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}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}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}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}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-### - pt1, ID-### - pt2, etc. # Match ID-###-part1, ID-###-part2, etc. - 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-### - part1, ID ### - part2, etc. # Match ID-###-cd1, ID-###-cd2, etc. - 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 + # Match ID-### - cd1, ID-### - cd2, etc. + elseif ($fileBaseNameUpper[$x] -match "[-][0-9]{1,6}Z?E?R?\s?[-]\s?(cd|part|pt)?[-]?\d{1,3}") { + $fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6}Z?E?\s?[-])" + $fileBaseNameUpperCleaned += $fileP1 + "-" + (($fileP2 -replace '-', '') -replace '^0{1,5}', '').Trim().PadLeft(3, '0') + $filePartNum = ((($fileP3.Trim() -replace '-', '') -replace '^0{1,5}', '') -replace '(cd|part|pt)', '') + $filePartNumber = [int]$filePartNum } # Match everything else else { $fileP1, $fileP2, $fileP3 = $fileBaseNameUpper[$x] -split "([-][0-9]{1,6})" - if ($fileP3 -match '^Z' -or $fileP3 -match '^E') { + if ($fileP3 -match '^[ZER]') { $fileBaseNameUpperCleaned += $fileP1 + $fileP2 + $fileP3 } else { $fileBaseNameUpperCleaned += $fileP1 + $fileP2 diff --git a/src/Javinizer/Private/Get-JVUrlLocation.ps1 b/src/Javinizer/Private/Get-JVUrlLocation.ps1 index a7db3544..598a7d70 100644 --- a/src/Javinizer/Private/Get-JVUrlLocation.ps1 +++ b/src/Javinizer/Private/Get-JVUrlLocation.ps1 @@ -76,6 +76,11 @@ function Get-JVUrlLocation { Url = $link Source = 'jav321ja' } + } elseif ($link -match 'dl.getchu') { + $testUrlObject += [PSCustomObject]@{ + Url = $link + Source = 'dlgetchuja' + } } else { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] [Url - $Url] not matched" } diff --git a/src/Javinizer/Private/Scraper.DLgetchu.ps1 b/src/Javinizer/Private/Scraper.DLgetchu.ps1 new file mode 100644 index 00000000..cd881507 --- /dev/null +++ b/src/Javinizer/Private/Scraper.DLgetchu.ps1 @@ -0,0 +1,180 @@ +function Get-DLgetchuId { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $id = ($Webrequest.Content | Select-String -Pattern '作品ID:(\d*)').Matches.Groups[1].Value + } catch { + return + } + Write-Output $id + } +} + +function Get-DLgetchuTitle { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + process { + try { + $title = ($Webrequest.Content -split '\n' | Select-String -Pattern '<meta property="og:title" content="(.*)" />').Matches.Groups[1].Value + } catch { + return + } + Write-Output $title + } +} + +function Get-DLgetchuDescription { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $descriptionBlock = ((($Webrequest.Content -split '作品内容<\/td>')[1] -split '<\/td>')[0] -replace '<[^>]*>', '').Trim() + } catch { + return + } + + $description = $descriptionBlock -split '\n' -join ' ' + Write-Output $description + } +} + +function Get-DLgetchuReleaseDate { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $releaseDate = ($Webrequest.Content | Select-String -Pattern '<td bgcolor="white" width="449">(\d{4}\/\d{2}\/\d{2})<\/td>').Matches.Groups[1].Value + $releaseDate = ($releaseDate -split '/') -join '-' + } catch { + return + } + Write-Output $releaseDate + } +} + +function Get-DLgetchuReleaseYear { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + $releaseYear = Get-DLgetchuReleaseDate -WebRequest $Webrequest + $releaseYear = ($releaseYear -split '-')[0] + Write-Output $releaseYear + } +} + +function Get-DLgetchuRuntime { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + $unicodeReplace = @{ + '0' = '0' + '1' = '1' + '2' = '2' + '3' = '3' + '4' = '4' + '5' = '5' + '6' = '6' + '7' = '7' + '8' = '8' + '9' = '9' + } + + try { + $length = ($WebRequest.Content | Select-String -Pattern '([0123456789]?\s?[0123456789]?\s?[0123456789]?)分').Matches.Groups[1].Value + } catch { + return + } + + foreach ($unicode in $unicodeReplace.GetEnumerator()) { + $length = $length -replace $unicode.Name, $unicode.Value + } + + Write-Output $length + } +} + +function Get-DLgetchuMaker { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + $maker = ($Webrequest.Content | Select-String -Pattern '<a href=".*dojin_circle_detail.php\?id=\d*.*">(.*)<\/a><\/td>').Matches.Groups[1].Value + Write-Output $maker + } +} + + +function Get-DLgetchuGenre { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $genreHtml = (($Webrequest.Content -split '<td class="bluetext" align="center" bgcolor="#f0f8ff" width="100">趣向</td>')[1] -split '<\/tr>')[0] + $genre = ($genreHtml | Select-String -Pattern '<a href=".*genre_id=(\d*).*">(.*)<\/a>' -AllMatches).Matches | ForEach-Object { $_.Groups[2].Value } + } catch { + return + } + + if ($genre.Count -eq 0) { + $genre = $null + } + + Write-Output $genre + } +} + +function Get-DLgetchuCoverUrl { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $coverUrl = "http://dl.getchu.com" + ($Webrequest.Content | Select-String -Pattern '\/data\/item_img\/.*\/.*\/\d*top\.jpg').Matches.Groups[0].Value + } catch { + return + } + + Write-Output $coverUrl + } +} + +function Get-DLgetchuScreenshotUrl { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + $screenshotUrl = ($Webrequest.Content | Select-String -Pattern '"(\/data\/item_img\/.*\/.*\/.*\.jpg)" class="highslide"' -AllMatches).Matches | ForEach-Object { "http://dl.getchu.com" + $_.Groups[1].Value } + } catch { + return + } + Write-Output $screenshotUrl + } +} diff --git a/src/Javinizer/Private/Scraper.Dmm.ps1 b/src/Javinizer/Private/Scraper.Dmm.ps1 index 0cc4da37..8d72fe1d 100644 --- a/src/Javinizer/Private/Scraper.Dmm.ps1 +++ b/src/Javinizer/Private/Scraper.Dmm.ps1 @@ -14,6 +14,28 @@ function Get-DmmContentId { } } +function Get-DmmId { + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [Object]$Webrequest + ) + + process { + try { + # Expects ###ID##### or ID##### + $contentId = Get-DmmContentId $Webrequest + $m = ($contentId | Select-String -Pattern '\d*([a-z]+)(\d+)(.*)$' -AllMatches).Matches + + if($m.Groups.Count -gt 2 -and $m.Groups[1] -and $m.Groups[2]) { + $Id = $m.Groups[1].Value.ToUpper() + "-" + ($m.Groups[2].Value -replace '^0{1,5}', '').PadLeft(3, '0') + $m.Groups[3].Value.ToUpper() + } + } catch { + return + } + Write-Output $Id + } +} + function Get-DmmTitle { param ( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] @@ -46,7 +68,7 @@ function Get-DmmDescription { if ($null -eq $description -or $description -eq '') { $description = (((($Webrequest.Content -join "`r`n") -split '<div class="mg-b20 lh4">')[1]) -split '\n')[6] - $description = ($description -replace '<p class=".*">.*<\/p>', '').Trim() + $description = ($description -replace '<p class=".*">.*<\/p>', '' -replace '<br>', '').Trim() } Write-Output $description @@ -124,7 +146,7 @@ function Get-DmmMaker { process { try { - $maker = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|\/en\/mono\/dvd\/)-\/list\/=\/article=maker\/id=\d*\/">(.*)<\/a>').Matches.Groups[2].Value + $maker = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|(?:\/en)?\/mono\/dvd\/)-\/list\/=\/article=maker\/id=\d*\/">(.*)<\/a>').Matches.Groups[2].Value } catch { return } @@ -140,7 +162,7 @@ function Get-DmmLabel { process { try { - $label = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|\/en\/mono\/dvd\/)-\/list\/=\/article=label\/id=\d*\/">(.*)<\/a>').Matches.Groups[2].Value + $label = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|(?:\/en)?\/mono\/dvd\/)-\/list\/=\/article=label\/id=\d*\/">(.*)<\/a>').Matches.Groups[2].Value } catch { return } @@ -156,7 +178,7 @@ function Get-DmmSeries { process { try { - $series = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|\/en\/mono\/dvd\/)-\/list\/=\/article=series\/id=\d*\/">(.*)<\/a><\/td>').Matches.Groups[2].Value + $series = ($Webrequest.Content | Select-String -Pattern '<a href="(\/digital\/videoa\/|(?:\/en)?\/mono\/dvd\/)-\/list\/=\/article=series\/id=\d*\/">(.*)<\/a><\/td>').Matches.Groups[2].Value } catch { return } @@ -371,7 +393,7 @@ function Get-DmmCoverUrl { process { try { - $coverUrl = ($Webrequest.Content | Select-String -Pattern '(https:\/\/pics\.dmm\.co\.jp\/(mono\/movie\/adult|digital\/video)\/(.*)/(.*)\.jpg)').Matches.Groups[1].Value -replace 'ps.jpg', 'pl.jpg' + $coverUrl = ($Webrequest.Content | Select-String -Pattern '(https:\/\/pics\.dmm\.co\.jp\/(mono\/movie\/adult|digital\/(?:video|amateur))\/(.*)\/(.*)\.jpg)').Matches.Groups[1].Value -replace 'ps.jpg', 'pl.jpg' } catch { return } diff --git a/src/Javinizer/Private/Scraper.R18.ps1 b/src/Javinizer/Private/Scraper.R18.ps1 index 5b576fbe..c08307d8 100644 --- a/src/Javinizer/Private/Scraper.R18.ps1 +++ b/src/Javinizer/Private/Scraper.R18.ps1 @@ -48,8 +48,10 @@ function Get-R18Title { $title = Convert-HtmlCharacter -String $title if ($Replace) { foreach ($string in $Replace) { - $title = $title -replace [regex]::Escape($string.Original), $string.Replacement - $title = $title -replace ' ', ' ' + if (($title -split ' ') -eq $string.Original) { + $title = $title -replace [regex]::Escape($string.Original), $string.Replacement + $title = $title -replace ' ', ' ' + } } } @@ -188,12 +190,26 @@ function Get-R18Maker { function Get-R18Label { param ( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] - [Object]$Webrequest + [Object]$Webrequest, + + [Parameter()] + [Object]$Replace ) process { - $label = (((($Webrequest.Content -split '<dd itemprop="productionCompany" itemscope itemtype="http:\/\/schema.org\/Organization\">')[1] -split '<\/dl>')[0] -split '<dd>')[1] -split '<br>')[0] - $label = Convert-HtmlCharacter -String $label + try { + $label = ((($Webrequest.Content -split '<dt>(Label:|廠牌:)<\/dt>')[2] -split '</dd>')[0] -replace '<[^>]*>' , '').Trim() + } catch { + return + } + + if ($Replace) { + foreach ($string in $Replace.GetEnumerator()) { + if (($label -split ' ') -eq $string.Original) { + $label = $label -replace [regex]::Escape($string.Original), $string.Replacement + } + } + } if ($label -eq '----') { $label = $null @@ -261,11 +277,13 @@ function Get-R18Genre { foreach ($genre in $genreHtml) { $genre = $genre.trim() - if ($genre -notmatch 'https:\/\/www\.r18\.com\/videos\/vod\/movies\/list\/id=(.*)' -and $genre -ne '') { + if ($genre -notmatch 'https:\/\/www\.r18\.com\/videos\/vod\/(movies|amateur)\/list\/id=(.*)' -and $genre -ne '') { $genre = Convert-HtmlCharacter -String $genre if ($Replace) { foreach ($string in $Replace.GetEnumerator()) { - $genre = $genre -replace [regex]::Escape($string.Original), $string.Replacement + if (($genre -split ' ') -eq $string.Original) { + $genre = $genre -replace [regex]::Escape($string.Original), $string.Replacement + } } } $genreArray += $genre diff --git a/src/Javinizer/Private/Test-JVSettings.ps1 b/src/Javinizer/Private/Test-JVSettings.ps1 index 20ddc63c..43f92291 100644 --- a/src/Javinizer/Private/Test-JVSettings.ps1 +++ b/src/Javinizer/Private/Test-JVSettings.ps1 @@ -93,11 +93,11 @@ function Test-JVSettings { 'sort.metadata.genrecsv', 'sort.metadata.nfo.actresslanguageja', 'sort.metadata.nfo.firstnameorder', - 'sort.metadata.nfo.seriesastag', 'sort.metadata.nfo.translatedescription', 'sort.metadata.thumbcsv.convertalias', 'sort.metadata.thumbcsv.autoadd', 'sort.metadata.thumbcsv', + 'sort.metadata.unknownactress', 'sort.movetofolder', 'sort.renamefile' ) | Test-JVSettingsGroup -Settings $Settings -Type Boolean @@ -127,6 +127,7 @@ function Test-JVSettings { 'sort.format.thumbimg', 'sort.format.trailervid', 'sort.metadata.nfo.displayname', + 'sort.metadata.nfo.format.tagline', 'sort.metadata.nfo.translatedescription.language' ) | Test-JVSettingsGroup -Settings $Settings -Type String @@ -135,6 +136,7 @@ function Test-JVSettings { 'match.includedfileextension', 'sort.format.posterimg', 'sort.metadata.genre.ignore', + 'sort.metadata.nfo.format.tag', 'sort.metadata.priority.actress', 'sort.metadata.priority.alternatetitle', 'sort.metadata.priority.coverurl', diff --git a/src/Javinizer/Public/Get-DLgetchuData.ps1 b/src/Javinizer/Public/Get-DLgetchuData.ps1 new file mode 100644 index 00000000..928295c0 --- /dev/null +++ b/src/Javinizer/Public/Get-DLgetchuData.ps1 @@ -0,0 +1,41 @@ +#Requires -PSEdition Core + +function Get-DLgetchuData { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [String]$Url + ) + + process { + $movieDataObject = @() + + try { + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url]" + $webRequest = Invoke-WebRequest -Uri $Url -Method Get -Verbose:$false + } catch [Microsoft.PowerShell.Commands.HttpResponseException] { + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] Not found on DLgetchu [$Url]" + continue + } catch { + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' + } + + $movieDataObject = [PSCustomObject]@{ + Source = 'dlgetchuja' + Url = $Url + Id = Get-DLgetchuId -WebRequest $webRequest + Title = Get-DLgetchuTitle -WebRequest $webRequest + Description = Get-DLgetchuDescription -WebRequest $webRequest + ReleaseDate = Get-DLgetchuReleaseDate -WebRequest $webRequest + ReleaseYear = Get-DLgetchuReleaseYear -WebRequest $webRequest + Runtime = Get-DLgetchuRuntime -WebRequest $webRequest + Maker = Get-DLgetchuMaker -WebRequest $webRequest + Genre = Get-DLgetchuGenre -WebRequest $webRequest + CoverUrl = Get-DLgetchuCoverUrl -WebRequest $webRequest + ScreenshotUrl = Get-DLgetchuScreenshotUrl -WebRequest $webRequest + } + + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] DLgetchu data object: $($movieDataObject | ConvertTo-Json -Depth 32 -Compress)" + Write-Output $movieDataObject + } +} diff --git a/src/Javinizer/Public/Get-DmmData.ps1 b/src/Javinizer/Public/Get-DmmData.ps1 index 8919fd08..1ce5288d 100644 --- a/src/Javinizer/Public/Get-DmmData.ps1 +++ b/src/Javinizer/Public/Get-DmmData.ps1 @@ -12,8 +12,14 @@ function Get-DmmData { process { $movieDataObject = @() + $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession + $cookie = New-Object System.Net.Cookie + $cookie.Name = 'age_check_done' + $cookie.Value = '1' + $cookie.Domain = 'dmm.co.jp' + $session.Cookies.Add($cookie) + if ($Url -match '/en/') { - $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession $cookie = New-Object System.Net.Cookie $cookie.Name = 'ckcy' $cookie.Value = '2' @@ -24,11 +30,6 @@ function Get-DmmData { $cookie.Value = 'en' $cookie.Domain = 'dmm.co.jp' $session.Cookies.Add($cookie) - $cookie = New-Object System.Net.Cookie - $cookie.Name = 'age_check_done' - $cookie.Value = '1' - $cookie.Domain = 'dmm.co.jp' - $session.Cookies.Add($cookie) } try { @@ -38,13 +39,14 @@ function Get-DmmData { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] Not found on DMM [$Url]" continue } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' } $movieDataObject = [PSCustomObject]@{ Source = if ($Url -match '/en/') { 'dmm' } else { 'dmmja' } Url = $Url - Id = Get-DmmContentId -WebRequest $webRequest + Id = Get-DmmId -WebRequest $webRequest + ContentId = Get-DmmContentId -WebRequest $webRequest Title = Get-DmmTitle -WebRequest $webRequest Description = Get-DmmDescription -WebRequest $webRequest ReleaseDate = Get-DmmReleaseDate -WebRequest $webRequest diff --git a/src/Javinizer/Public/Get-DmmUrl.ps1 b/src/Javinizer/Public/Get-DmmUrl.ps1 index 86e4aa3b..0970aa01 100644 --- a/src/Javinizer/Public/Get-DmmUrl.ps1 +++ b/src/Javinizer/Public/Get-DmmUrl.ps1 @@ -34,7 +34,7 @@ function Get-DmmUrl { 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 "[$originalId] [$($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" -Action 'Continue' } $retryCount = 3 @@ -54,7 +54,7 @@ function Get-DmmUrl { 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 "[$originalId] [$($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" -Action 'Continue' } $resultId = Get-DmmContentId -WebRequest $webRequest @@ -83,7 +83,7 @@ function Get-DmmUrl { $splitJaIdNum = (($jaId | Select-String -Pattern '\d{5}[zZ]?[eE]?').Matches.Groups[0].Value) -replace '^0*', '' if (($splitJaIdNum)[-1] -match '\D') { - $appendChar = ($splitIdJaIdNum)[-1] + $appendChar = ($splitJaIdNum)[-1] $splitJaIdNum = $splitJaIdNum -replace '\D', '' } diff --git a/src/Javinizer/Public/Get-JVAggregatedData.ps1 b/src/Javinizer/Public/Get-JVAggregatedData.ps1 index a343a7f6..07c7d927 100644 --- a/src/Javinizer/Public/Get-JVAggregatedData.ps1 +++ b/src/Javinizer/Public/Get-JVAggregatedData.ps1 @@ -37,6 +37,10 @@ function Get-JVAggregatedData { [Alias('sort.metadata.priority.id')] [Array]$IdPriority, + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [Alias('sort.metadata.priority.contentid')] + [Array]$ContentIdPriority, + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] [Alias('sort.metadata.priority.label')] [Array]$LabelPriority, @@ -126,8 +130,27 @@ function Get-JVAggregatedData { [Boolean]$ActressLanguageJa, [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] - [Alias('sort.emtadata.thumbcsv.autoadd')] - [Boolean]$ThumbCsvAutoAdd + [Alias('sort.metadata.thumbcsv.autoadd')] + [Boolean]$ThumbCsvAutoAdd, + + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [Alias('sort.metadata.nfo.unknownactress')] + [Boolean]$UnknownActress, + + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [Alias('sort.metadata.nfo.format.tag')] + [Array]$Tag, + + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [Alias('sort.metadata.nfo.format.tagline')] + [String]$Tagline, + + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [Alias('scraper.option.idpreference')] + [String]$IdPreference, + + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Setting')] + [PSObject]$MediaInfo ) process { @@ -139,6 +162,7 @@ function Get-JVAggregatedData { $DirectorPriority = $Settings.'sort.metadata.priority.director' $GenrePriority = $Settings.'sort.metadata.priority.genre' $IdPriority = $Settings.'sort.metadata.priority.id' + $ContentIdPriority = $Settings.'sort.metadata.priority.contentid' $LabelPriority = $Settings.'sort.metadata.priority.label' $MakerPriority = $Settings.'sort.metadata.priority.maker' $RatingPriority = $Settings.'sort.metadata.priority.rating' @@ -159,6 +183,10 @@ function Get-JVAggregatedData { $ActressLanguageJa = $Settings.'sort.metadata.nfo.actresslanguageja' $ThumbCsvAutoAdd = $Settings.'sort.metadata.thumbcsv.autoadd' $FirstNameOrder = $Settings.'sort.metadata.nfo.firstnameorder' + $UnknownActress = $Settings.'sort.metadata.nfo.unknownactress' + $Tag = $Settings.'sort.metadata.nfo.format.tag' + $Tagline = $Settings.'sort.metadata.nfo.format.tagline' + $IdPreference = $Settings.'scraper.option.idpreference' if ($Settings.'location.genrecsv' -ne '') { $GenreCsvPath = $Settings.'location.genrecsv' } @@ -169,6 +197,7 @@ function Get-JVAggregatedData { $aggregatedDataObject = [PSCustomObject]@{ Id = $null + ContentId = $null DisplayName = $null Title = $null AlternateTitle = $null @@ -180,11 +209,14 @@ function Get-JVAggregatedData { Maker = $null Label = $null Series = $null + Tag = $null + Tagline = $null Actress = $null Genre = $null CoverUrl = $null ScreenshotUrl = $null TrailerUrl = $null + MediaInfo = $MediaInfo } $metadataFields = @( @@ -203,7 +235,8 @@ function Get-JVAggregatedData { 'Series', 'ScreenshotUrl', 'Title', - 'TrailerUrl' + 'TrailerUrl', + 'ContentId' ) foreach ($field in $metadataFields) { @@ -214,6 +247,12 @@ function Get-JVAggregatedData { if ($null -eq $aggregatedDataObject.$field) { if ($field -eq 'AlternateTitle') { $aggregatedDataObject.$field = $sourceData.Title + } elseif ($field -eq 'Id') { + if ($IdPreference -eq 'contentid') { + $aggregatedDataObject.$field = $sourceData.ContentId + } else { + $aggregatedDataObject.$field = $sourceData.Id + } } else { $aggregatedDataObject.$field = $sourceData.$field } @@ -445,6 +484,17 @@ function Get-JVAggregatedData { } } + if ($UnknownActress) { + if ($null -eq $aggregatedDataObject.Actress) { + $aggregatedDataObject.Actress += [PSCustomObject]@{ + LastName = $null + FirstName = 'Unknown' + JapaneseName = 'Unknown' + ThumbUrl = $null + } + } + } + if ($ReplaceGenre) { if (Test-Path -LiteralPath $GenreCsvPath) { try { @@ -497,6 +547,26 @@ function Get-JVAggregatedData { } } + if ($null -ne $Tag[0]) { + $aggregatedDataObject.Tag = @() + foreach ($entry in $Tag) { + $tagString = (Convert-JVString -Data $aggregatedDataObject -FormatString $entry -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder) + if ($null -ne $tagString -and $tagstring -ne '') { + $aggregatedDataObject.Tag += $tagString + } + } + if ($null -eq $aggregatedDataObject.Tag[0]) { + $aggregatedDataObject.Tag = $null + } + } + + if ($Tagline -ne '') { + $taglineString = (Convert-JVString -Data $aggregatedDataObject -FormatString $Tagline -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder) + if ($null -ne $taglineString -and $taglineString -ne '') { + $aggregatedDataObject.Tagline += $taglineString + } + } + $dataObject = [PSCustomObject]@{ Data = $aggregatedDataObject } diff --git a/src/Javinizer/Public/Get-JVData.ps1 b/src/Javinizer/Public/Get-JVData.ps1 index 3557ddb6..f30ee845 100644 --- a/src/Javinizer/Public/Get-JVData.ps1 +++ b/src/Javinizer/Public/Get-JVData.ps1 @@ -50,15 +50,20 @@ function Get-JVData { [Alias('scraper.movie.jav321ja')] [Boolean]$Jav321Ja, + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Id')] + [Alias('scraper.movie.dlgetchuja')] + [Boolean]$DLgetchuJa, + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Id')] [Alias('javlibrary.baseurl')] [String]$JavlibraryBaseUrl = 'https://www.javlibrary.com', [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Id')] - [Alias('scraper.movie.dmm.scrapeactress')] + [Alias('scraper.option.dmm.scrapeactress')] [Boolean]$DmmScrapeActress, [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Id')] + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Url')] [Alias('location.uncensorcsv')] [System.IO.FileInfo]$UncensorCsvPath = (Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'jvUncensor.csv'), @@ -221,11 +226,11 @@ function Get-JVData { } if ($DmmJa) { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - Dmm] [Url - $DmmUrl]" - Start-ThreadJob -Name "jvdata-Dmm" -ThrottleLimit $throttleLimit -ScriptBlock { + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - DmmJa] [Url - $DmmJaUrl]" + Start-ThreadJob -Name "jvdata-DmmJa" -ThrottleLimit $throttleLimit -ScriptBlock { Import-Module $using:jvModulePath - if ($using:DmmUrl) { - $using:DmmUrl | Get-DmmData -ScrapeActress:$using:DmmScrapeActress + if ($using:DmmJaUrl) { + $using:DmmJaUrl | Get-DmmData -ScrapeActress:$using:DmmScrapeActress } elseif ($using:jvDmmUrl) { $jvDmmUrl = $using:jvDmmUrl $jvDmmUrl.Ja | Get-DmmData -ScrapeActress:$using:DmmScrapeActress @@ -300,6 +305,14 @@ function Get-JVData { } | Out-Null } + if ($DLgetchuJa) { + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] [Search - DLgetchuJa] [Url - $DLgetchuJaUrl]" + Start-ThreadJob -Name "jvdata-DLgetchuJa" -ThrottleLimit $throttleLimit -ScriptBlock { + Import-Module $using:jvModulePath + $using:DLgetchuJaUrl | Get-DLGetchuData + } | Out-Null + } + $jobCount = (Get-Job | Where-Object { $_.Name -like 'jvdata-*' }).Count $jobId = @((Get-Job | Where-Object { $_.Name -like "jvdata-*" } | Select-Object Id).Id) $jobName = @((Get-Job | Where-Object { $_.Name -like "jvdata-*" } | Select-Object Name).Name) diff --git a/src/Javinizer/Public/Get-JVMediaInfo.ps1 b/src/Javinizer/Public/Get-JVMediaInfo.ps1 new file mode 100644 index 00000000..b5698d60 --- /dev/null +++ b/src/Javinizer/Public/Get-JVMediaInfo.ps1 @@ -0,0 +1,22 @@ +function Get-JVMediaInfo { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, Position = 0)] + [System.IO.FileInfo]$Path + ) + + $fullMetadata = ((MediaInfo --Full $Path --Output=JSON) | ConvertFrom-Json).media.track + $videoMetadata = $fullMetaData | Where-Object { $_.'@type' -eq 'Video' }[0] + $audioMetadata = ($fullMetaData | Where-Object { $_.'@type' -eq 'Audio' })[0] + $metadata = [PSCustomObject]@{ + VideoCodec = $videoMetadata.CodecID + VideoAspect = $videoMetadata.DisplayAspectRatio_String + VideoWidth = $videoMetadata.Width + VideoHeight = $videoMetadata.Height + VideoDuration = [Math]::Round($videoMetadata.Duration) + AudioCodec = $audioMetadata.CodecID + AudioLanguage = $audioMetadata.Language + AudioChannels = $audioMetadata.Channels + } + Write-Output $metadata +} diff --git a/src/Javinizer/Public/Get-JVNfo.ps1 b/src/Javinizer/Public/Get-JVNfo.ps1 index 40191298..166885f7 100644 --- a/src/Javinizer/Public/Get-JVNfo.ps1 +++ b/src/Javinizer/Public/Get-JVNfo.ps1 @@ -66,14 +66,20 @@ function Get-JVNfo { [AllowEmptyString()] [String]$TrailerUrl, - [Parameter()] - [Boolean]$ActressLanguageJa, + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Array]$Tag, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [String]$Tagline, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSObject]$MediaInfo, [Parameter()] - [Boolean]$NameOrder, + [Boolean]$ActressLanguageJa, [Parameter()] - [Boolean]$AddTag + [Boolean]$NameOrder ) process { @@ -117,13 +123,14 @@ function Get-JVNfo { <runtime>$Runtime</runtime> <trailer>$TrailerUrl</trailer> <mpaa>XXX</mpaa> + <tagline>$Tagline</tagline> <set>$Series</set> "@ - if ($AddTag) { + foreach ($item in $Tag) { $tagNfoString = @" - <tag>$Series</tag> + <tag>$item</tag> "@ $nfoString = $nfoString + $tagNfoString @@ -183,6 +190,29 @@ function Get-JVNfo { $nfoString = $nfoString + $actressNfoString } + if ($MediaInfo) { + $mediaNfoString = @" + <fileinfo> + <streamdetails> + <video> + <codec>$($MediaInfo.VideoCodec)</codec> + <aspect>$($MediaInfo.VideoAspect)</aspect> + <width>$($MediaInfo.VideoWidth)</width> + <height>$($MediaInfo.VideoHeight)</height> + <durationinseconds>$($MediaInfo.VideoDuration)</durationinseconds> + </video> + <audio> + <codec>$($MediaInfo.AudioCodec)</codec> + <language>$($MediaInfo.AudioLanguage)</language> + <channels>$($MediaInfo.AudioChannels)</channels> + </audio> + </streamdetails> + </fileinfo> + +"@ + $nfoString = $nfoString + $mediaNfoString + } + $endNfoString = @" </movie> "@ diff --git a/src/Javinizer/Public/Get-Jav321Data.ps1 b/src/Javinizer/Public/Get-Jav321Data.ps1 index 902e7a69..8ef98bd2 100644 --- a/src/Javinizer/Public/Get-Jav321Data.ps1 +++ b/src/Javinizer/Public/Get-Jav321Data.ps1 @@ -14,7 +14,7 @@ function Get-Jav321Data { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url]" $webRequest = Invoke-RestMethod -Uri $Url -Verbose:$false } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' } $movieDataObject = [PSCustomObject]@{ diff --git a/src/Javinizer/Public/Get-Jav321Url.ps1 b/src/Javinizer/Public/Get-Jav321Url.ps1 index 4ffb6867..d31c2198 100644 --- a/src/Javinizer/Public/Get-Jav321Url.ps1 +++ b/src/Javinizer/Public/Get-Jav321Url.ps1 @@ -14,7 +14,7 @@ function Get-Jav321Url { 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-WebRequest -Uri $searchUrl -Method Post -Body "sn=$Id" -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" + 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' } @@ -41,7 +41,7 @@ function Get-Jav321Url { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$result]" $webRequest = Invoke-RestMethod -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 occured on [GET] on URL [$result]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem" -Action 'Continue' } $resultId = Get-Jav321Id -WebRequest $webRequest diff --git a/src/Javinizer/Public/Get-JavbusData.ps1 b/src/Javinizer/Public/Get-JavbusData.ps1 index 996a5828..ddd8db92 100644 --- a/src/Javinizer/Public/Get-JavbusData.ps1 +++ b/src/Javinizer/Public/Get-JavbusData.ps1 @@ -14,7 +14,7 @@ function Get-JavbusData { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url]" $webRequest = Invoke-RestMethod -Uri $Url -Verbose:$false } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' } $movieDataObject = [PSCustomObject]@{ diff --git a/src/Javinizer/Public/Get-JavbusUrl.ps1 b/src/Javinizer/Public/Get-JavbusUrl.ps1 index 6d862928..61e2249d 100644 --- a/src/Javinizer/Public/Get-JavbusUrl.ps1 +++ b/src/Javinizer/Public/Get-JavbusUrl.ps1 @@ -52,7 +52,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 [$result]" $webRequest = Invoke-RestMethod -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 "[$Id] [$($MyInvocation.MyCommand.Name)] Error occurred on [GET] on URL [$result]: $PSItem" -Action 'Continue' } $resultId = Get-JavbusId -WebRequest $webRequest if ($resultId -eq $Id) { diff --git a/src/Javinizer/Public/Get-JavlibraryData.ps1 b/src/Javinizer/Public/Get-JavlibraryData.ps1 index deafb804..bf459400 100644 --- a/src/Javinizer/Public/Get-JavlibraryData.ps1 +++ b/src/Javinizer/Public/Get-JavlibraryData.ps1 @@ -14,10 +14,10 @@ function Get-JavlibraryData { $movieDataObject = @() try { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url]" $webRequest = Invoke-WebRequest -Uri $Url -Method Get -WebSession $Session -UserAgent $Session.UserAgent -Verbose:$false } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' } $movieDataObject = [PSCustomObject]@{ diff --git a/src/Javinizer/Public/Get-JavlibraryUrl.ps1 b/src/Javinizer/Public/Get-JavlibraryUrl.ps1 index c8fc91a4..51b8d00e 100644 --- a/src/Javinizer/Public/Get-JavlibraryUrl.ps1 +++ b/src/Javinizer/Public/Get-JavlibraryUrl.ps1 @@ -19,10 +19,16 @@ function Get-JavlibraryUrl { $searchUrl = "$BaseUrl/en/vl_searchbyid.php?keyword=$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] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]" + 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-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 occured on [GET] on URL [$searchUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem" + try { + # Add a retry to the URL search due to 500 errors occurring randomly when scraping Javlibrary + Start-Sleep -Seconds 3 + $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 occured on [GET] on URL [$searchUrl]: $PSItem" -Action 'Continue' + } } # Check if the search uniquely matched a video page @@ -30,10 +36,10 @@ function Get-JavlibraryUrl { $searchResultUrl = $webRequest.BaseResponse.RequestMessage.RequestUri.AbsoluteUri if ($searchResultUrl -match "$BaseUrl?v=") { try { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchResultUrl]" $webRequest = Invoke-WebRequest -Uri $searchResultUrl -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 [$searchResultUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchResultUrl]: $PSItem" -Action 'Continue' } $resultId = Get-JavlibraryId -WebRequest $webRequest @@ -59,10 +65,10 @@ function Get-JavlibraryUrl { $directUrl = "$BaseUrl/en/?v=$videoId" try { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$directUrl]" $webRequest = Invoke-WebRequest -Uri $directUrl -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 [$directUrl] with Session: [$Session] and UserAgent: [$($Session.UserAgent)]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$directUrl]: $PSItem" -Action 'Continue' } $resultId = Get-JavlibraryId -WebRequest $webRequest diff --git a/src/Javinizer/Public/Get-R18Data.ps1 b/src/Javinizer/Public/Get-R18Data.ps1 index 3fe9cadb..28a67e65 100644 --- a/src/Javinizer/Public/Get-R18Data.ps1 +++ b/src/Javinizer/Public/Get-R18Data.ps1 @@ -22,7 +22,7 @@ function Get-R18Data { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$Url]" $webRequest = Invoke-WebRequest -Uri $Url -Method Get -Verbose:$false } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error [GET] on URL [$Url]: $PSItem" -Action 'Continue' } $movieDataObject = [PSCustomObject]@{ @@ -37,7 +37,7 @@ function Get-R18Data { Runtime = Get-R18Runtime -WebRequest $webRequest Director = Get-R18Director -WebRequest $webRequest Maker = Get-R18Maker -WebRequest $webRequest - Label = Get-R18Label -WebRequest $webRequest + Label = Get-R18Label -WebRequest $webRequest -Replace $replaceHashTable Series = Get-R18Series -WebRequest $webRequest -Replace $replaceHashTable Actress = Get-R18Actress -WebRequest $webRequest Genre = Get-R18Genre -WebRequest $webRequest -Replace $replaceHashTable diff --git a/src/Javinizer/Public/Get-R18Url.ps1 b/src/Javinizer/Public/Get-R18Url.ps1 index 1e82b10e..a641ed11 100644 --- a/src/Javinizer/Public/Get-R18Url.ps1 +++ b/src/Javinizer/Public/Get-R18Url.ps1 @@ -36,7 +36,7 @@ function Get-R18Url { 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-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 occured on [GET] on URL [$searchUrl]: $PSItem" + 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' } $retryCount = 3 @@ -56,7 +56,7 @@ function Get-R18Url { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($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 occured on [GET] on URL [$result]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem" -Action 'Continue' } $resultId = Get-R18Id -WebRequest $webRequest @@ -82,7 +82,7 @@ function Get-R18Url { 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-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 occured on [GET] on URL [$searchUrl]: $PSItem" + 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' } $retryCount = 5 @@ -99,7 +99,7 @@ function Get-R18Url { Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($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 occured on [GET] on URL [$result]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$result]: $PSItem" -Action 'Continue' } $resultId = Get-R18Id -WebRequest $webRequest diff --git a/src/Javinizer/Public/Javinizer.ps1 b/src/Javinizer/Public/Javinizer.ps1 index e38f6b3d..f0fa3a41 100644 --- a/src/Javinizer/Public/Javinizer.ps1 +++ b/src/Javinizer/Public/Javinizer.ps1 @@ -502,6 +502,10 @@ function Javinizer { if ($item.Source -match 'r18') { $item.Url | Get-R18Data -UncensorCsvPath:$uncensorCsvPath } + + if ($item.Source -match 'dlgetchu') { + $item.Url | Get-DLgetchuData + } } $data = [PSCustomObject]@{ @@ -517,7 +521,7 @@ function Javinizer { } if ($Nfo) { - $nfoData = $data.Data | Get-JVNfo -ActressLanguageJa:$Settings.'sort.metadata.nfo.actresslanguageja' -NameOrder:$Settings.'sort.metadata.nfo.firstnameorder' -AddTag:$Settings.'sort.metadata.nfo.seriesastag' + $nfoData = $data.Data | Get-JVNfo -ActressLanguageJa:$Settings.'sort.metadata.nfo.actresslanguageja' -NameOrder:$Settings.'sort.metadata.nfo.firstnameorder' Write-Output $nfoData } else { Write-Output $data.Data @@ -548,7 +552,7 @@ function Javinizer { Write-Host "[$($MyInvocation.MyCommand.Name)] [ThumbCsvPath - $thumbCsvPath]" Invoke-Item -LiteralPath $thumbCsvPath } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$thumbCsvPath]: $PSItem" } } @@ -557,16 +561,16 @@ function Javinizer { Write-Host "[$($MyInvocation.MyCommand.Name)] [GenreCsvPath - $genreCsvPath]" Invoke-Item -LiteralPath $genreCsvPath } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$genreCsvPath]: $PSItem" } } if ($OpenUncensor) { try { - Write-Host "[$($MyInvocation.MyCommand.Name)] [UncensorCsvPath - $uncensorCsvPath']" + Write-Host "[$($MyInvocation.MyCommand.Name)] [UncensorCsvPath - $uncensorCsvPath]" Invoke-Item -LiteralPath $uncensorCsvPath } catch { - Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$]: $PSItem" + Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Error occurred when opening thumbcsv file [$uncensorCsvPath]: $PSItem" } } } @@ -667,9 +671,13 @@ function Javinizer { return } + if ($Settings.'sort.metadata.nfo.mediainfo') { + $mediaInfo = Get-JVMediaInfo -Path $movie.FullName + } + $javData = Get-JVData -Url $Url -Settings $Settings -UncensorCsvPath $uncensorCsvPath if ($null -ne $javData) { - $javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield' + $javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield' if ($null -ne $javAggregatedData) { $javAggregatedData | Set-JVMovie -Path $javMovies.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $JavMovies.PartNumber -Force:$Force } @@ -691,9 +699,13 @@ function Javinizer { if ($PSboundParameters.ContainsKey('IsThread')) { foreach ($movie in $javMovies) { + if ($Settings.'sort.metadata.nfo.mediainfo') { + $mediaInfo = Get-JVMediaInfo -Path $movie.FullName + } + $javData = Get-JVData -Id $movie.Id -Settings $Settings -UncensorCsvPath $uncensorCsvPath if ($null -ne $javData) { - $javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield' + $javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings -MediaInfo $mediaInfo | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield' if ($javAggregatedData.NullFields -eq '') { $javAggregatedData | Set-JVMovie -Path $movie.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $movie.Partnumber -Update:$Update -Force:$Force } else { diff --git a/src/Javinizer/Public/Set-JVMovie.ps1 b/src/Javinizer/Public/Set-JVMovie.ps1 index 3ef291e3..d0eef3df 100644 --- a/src/Javinizer/Public/Set-JVMovie.ps1 +++ b/src/Javinizer/Public/Set-JVMovie.ps1 @@ -104,10 +104,6 @@ function Set-JVMovie { [Alias('sort.metadata.nfo.displayname')] [String]$DisplayName, - [Parameter(ValueFromPipelineByPropertyName = $true)] - [Alias('sort.metadata.nfo.seriesastag')] - [Boolean]$AddTag, - [Parameter(ValueFromPipelineByPropertyName = $true)] [Alias('sort.metadata.nfo.firstnameorder')] [Boolean]$FirstNameOrder, @@ -152,13 +148,16 @@ function Set-JVMovie { $ScreenshotFolderFormat = $Settings.'sort.format.screenshotfolder' $ActorFolderFormat = $Settings.'sort.format.actressimgfolder' $DisplayName = $Settings.'sort.metadata.nfo.displayname' - $AddTag = $Settings.'sort.metadata.nfo.seriesastag' $FirstNameOrder = $Settings.'sort.metadata.nfo.firstnameorder' $DelimiterFormat = $Settings.'sort.format.delimiter' $ActressLanguageJa = $Settings.'sort.metadata.nfo.actresslanguageja' } - $fileName = Convert-JVString -Data $Data -Format $FileFormat -PartNumber $PartNumber -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder + if ($RenameFile) { + $fileName = Convert-JVString -Data $Data -Format $FileFormat -PartNumber $PartNumber -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder + } else { + $fileName = (Get-Item -LiteralPath $Path).BaseName + } $folderName = Convert-JVString -Data $Data -Format $FolderFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder $thumbName = Convert-JVString -Data $Data -Format $ThumbnailFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder $trailerName = Convert-JVString -Data $Data -Format $TrailerFormat -MaxTitleLength $MaxTitleLength -Delimiter $DelimiterFormat -ActressLanguageJa:$ActressLanguageJa -FirstNameOrder:$FirstNameOrder @@ -216,7 +215,7 @@ function Set-JVMovie { if ($CreateNfo) { try { $nfoPath = Join-Path -Path $folderPath -ChildPath "$nfoName.nfo" - $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -AddTag $AddTag -ActressLanguageJa:$ActressLanguageJa + $nfoContents = $Data | Get-JVNfo -NameOrder $FirstNameOrder -ActressLanguageJa:$ActressLanguageJa $nfoContents | Out-File -LiteralPath $nfoPath -Force:$Force Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$($Data.Id)] [$($MyInvocation.MyCommand.Name)] [Nfo] created at path [$nfoPath]" } catch { diff --git a/src/Javinizer/jvSettings.json b/src/Javinizer/jvSettings.json index 3e6ccde1..8eee08fc 100644 --- a/src/Javinizer/jvSettings.json +++ b/src/Javinizer/jvSettings.json @@ -18,6 +18,7 @@ "scraper.movie.r18": 1, "scraper.movie.r18zh": 0, "scraper.option.dmm.scrapeactress": 0, + "scraper.option.idpreference": "id", "match.minimumfilesize": 0, "match.includedfileextension": [ ".asf", @@ -32,7 +33,7 @@ ], "match.excludedfilestring": ["^.*-trailer*", "^.*-5\\."], "match.regex": 0, - "match.regex.string": "([a-zA-Z|tT28]+-\\d+z{0,1}Z{0,1}e{0,1}E{0,1})(?:-pt){0,1}(\\d{1,2})?", + "match.regex.string": "([a-zA-Z|tT28]+-\\d+[zZ]?[eE]?)(?:-pt)?(\\d{1,2})?", "match.regex.idmatch": 1, "match.regex.ptmatch": 2, "sort.movetofolder": 1, @@ -55,12 +56,15 @@ "sort.format.screenshotimg": "fanart", "sort.format.screenshotfolder": "extrafanart", "sort.format.actressimgfolder": ".actors", + "sort.metadata.nfo.mediainfo": 0, "sort.metadata.nfo.translatedescription": 0, "sort.metadata.nfo.translatedescription.language": "en", "sort.metadata.nfo.displayname": "[<ID>] <TITLE>", - "sort.metadata.nfo.seriesastag": 1, "sort.metadata.nfo.firstnameorder": 0, "sort.metadata.nfo.actresslanguageja": 0, + "sort.metadata.nfo.unknownactress": 1, + "sort.metadata.nfo.format.tag": ["<SET>"], + "sort.metadata.nfo.format.tagline": "", "sort.metadata.thumbcsv": 1, "sort.metadata.thumbcsv.autoadd": 1, "sort.metadata.thumbcsv.convertalias": 1, @@ -74,6 +78,7 @@ "sort.metadata.priority.director": ["r18", "javlibrary"], "sort.metadata.priority.genre": ["r18", "javlibrary"], "sort.metadata.priority.id": ["r18", "javlibrary"], + "sort.metadata.priority.contentid": ["r18", "dmmja"], "sort.metadata.priority.label": ["r18", "javlibrary"], "sort.metadata.priority.maker": ["r18", "javlibrary"], "sort.metadata.priority.releasedate": ["r18", "javlibrary", "dmmja"], diff --git a/src/Javinizer/jvThumbs.csv b/src/Javinizer/jvThumbs.csv index 07431357..bf473698 100644 --- a/src/Javinizer/jvThumbs.csv +++ b/src/Javinizer/jvThumbs.csv @@ -10231,3 +10231,20 @@ "Suzuno Hiroka","Suzuno","Hiroka","鈴乃広香","https://pics.r18.com/mono/actjpgs/suzuno_hiroka.jpg", "Taira Alice","Taira","Alice","平アリス","https://pics.r18.com/mono/actjpgs/taira_arisu.jpg", "Yukino Tsubaki","Yukino","Tsubaki","雪乃つばき","https://pics.r18.com/mono/actjpgs/yukino_tubaki.jpg", +"Tenno Uta","Tenno","Uta","天ノうた","https://pics.r18.com/mono/actjpgs/amano_uta.jpg", +"Ando Megumi","Ando","Megumi","安藤めぐみ","https://pics.r18.com/mono/actjpgs/ando_megumi.jpg", +"Azuma Yukino","Azuma","Yukino","吾妻ゆきの","https://pics.r18.com/mono/actjpgs/azuma_yukino.jpg", +"Harumi Jun","Harumi","Jun","春明潤","https://pics.r18.com/mono/actjpgs/harumi_zyun.jpg", +"Hasegawa Itsuki","Hasegawa","Itsuki","長谷川樹","https://pics.r18.com/mono/actjpgs/hasegawa_ituki.jpg", +"Hayama Natsuki","Hayama","Natsuki","葉山夏希","https://pics.r18.com/mono/actjpgs/hayama_natuki.jpg", +"Inoue Sora","Inoue","Sora","井上そら","https://pics.r18.com/mono/actjpgs/inoue_sora.jpg", +"Kawai Moka","Kawai","Moka","川井もか","https://pics.r18.com/mono/actjpgs/kawai_moka.jpg", +"Konno Michiko","Konno","Michiko","今野未知子","https://pics.r18.com/mono/actjpgs/konno_mitiko.jpg", +"Nakajo Suzuka","Nakajo","Suzuka","中条鈴華","https://pics.r18.com/mono/actjpgs/nakazyou_suzuka.jpg", +"Oga Rin","Oga","Rin","桜雅凛","https://pics.r18.com/mono/actjpgs/ouga_rin.jpg", +"Sada Mariko","Sada","Mariko","佐田茉莉子","https://pics.r18.com/mono/actjpgs/sata_mariko.jpg", +"Shion Mako","Shion","Mako","志恩まこ","https://pics.r18.com/mono/actjpgs/sion_mako.jpg", +"Shiromomo Hana","Shiromomo","Hana","白桃はな","https://pics.r18.com/mono/actjpgs/sirato_hana.jpg", +"Takanashi Arisa","Takanashi","Arisa","高梨有紗","https://pics.r18.com/mono/actjpgs/takanasi_arisa.jpg", +"Tachibana Momoka","Tachibana","Momoka","橘萌々香","https://pics.r18.com/mono/actjpgs/tatibana_momoka.jpg", +"Teramoto Ami","Teramoto","Ami","寺本亜美","https://pics.r18.com/mono/actjpgs/teramoto_ami.jpg", diff --git a/src/Tests/Unit/Javinizer-Function.Tests.ps1 b/src/Tests/Unit/Javinizer-Function.Tests.ps1 index d3063922..b74175bd 100644 --- a/src/Tests/Unit/Javinizer-Function.Tests.ps1 +++ b/src/Tests/Unit/Javinizer-Function.Tests.ps1 @@ -19,13 +19,123 @@ InModuleScope 'Javinizer' { $WarningPreference = "SilentlyContinue" #------------------------------------------------------------------------- Describe 'Javinizer Private Function Tests' -Tag Unit { - Context 'FunctionName' { - <# - It 'should ...' { - }#it - #> - }#context_FunctionName + BeforeAll { + function Get-Files ($fileNames) { + $files = @() + foreach($file in $FileNames) { + $file = [PSCustomObject]@{ + Name = $file + BaseName = $file.Substring(0, $file.Length - 4) + } + $files += $file + } + return $files + } + } + + Context 'Convert-JVTitle' { + It 'Should convert multipart ID-### accordingly' { + $fileNames = @( + "bbi-094a.wmv", + "bbi-094-b.wmv", + "bbi-094 - c.wmv", + "bbi-094-4.wmv", + "bbi-094 - 1.wmv", + "bbi-094-02.wmv", + "bbi-094-003.wmv", + "bbi-094 - 004.wmv", + "bbi-094-pt1.wmv", + "bbi-094 - pt2.wmv", + "bbi-094-part3.wmv", + "bbi-094 - part4.wmv", + "bbi-094-cd1.wmv", + "bbi-094 - cd2.wmv", + "bbi00094c.wmv", + "bbi00094-d.wmv", + "bbi00094 - a.wmv", + "bbi00094-pt2.wmv", + "bbi00094 - pt3.wmv", + "bbi00094-cd4.wmv", + "bbi00094 - cd1.wmv" + ) + + $files = Get-Files $fileNames + $results = Convert-JVTitle $files -RegexEnabled $false + $results.ContentId | Should -Be (,"BBI00094" * $fileNames.Length) + $results.Id | Should -Be (,"BBI-094" * $fileNames.Length) + $results.PartNumber | Should -Be ((1..4) * [Math]::Ceiling($fileNames.Length / 4))[0..($fileNames.Length - 1)] + } + + It 'Should work fine for ID ending in E, Z and R' { + $fileNames = @( + "ibw-230z.mp4", + "ktra-213e.mp4", + "gesd-093r.mp4" + ) + + $files = @() + foreach($file in $FileNames) { + $file = [PSCustomObject]@{ + Name = $file + BaseName = $file.Substring(0, $file.Length - 4) + } + $files += $file + } + + $results = Convert-JVTitle $files -RegexEnabled $false + $results.ContentId | Should -Be ("IBW00230Z", "KTRA00213E", "GESD00093R") + $results.Id | Should -Be ("IBW-230Z", "KTRA-213E", "GESD-093R") + $results.PartNumber | Should -Be (,$null * $fileNames.Length) + } + + It 'Should work fine for multipart ID ending in E, Z and R' { + $fileNames = @( + "ibw-230za.mp4", + "ibw-230z-b.mp4", + "ibw-230z - c.mp4", + "ibw-230z-4.mp4", + "ibw-230z - 1.mp4", + "ibw-230z-02.mp4", + "ibw-230z-003.mp4", + "ibw-230z - 004.mp4", + "ibw-230z-pt1.mp4", + "ibw-230z - pt2.mp4", + "ibw-230z-part3.mp4", + "ibw-230z - part4.mp4", + "ibw-230z-cd1.mp4", + "ibw-230z - cd2.mp4", + "ibw00230zc.mp4", + "ibw00230z-d.mp4", + "ibw00230z - a.mp4", + "ibw00230z-pt2.mp4", + "ibw00230z - pt3.mp4", + "ibw00230z-cd4.mp4", + "ibw00230z - cd1.mp4" + ) + + $files = Get-Files $fileNames + $results = Convert-JVTitle $files -RegexEnabled $false + $results.ContentId | Should -Be (,"IBW00230Z" * $fileNames.Length) + $results.Id | Should -Be (,"IBW-230Z" * $fileNames.Length) + $results.PartNumber | Should -Be ((1..4) * [Math]::Ceiling($fileNames.Length / 4))[0..($fileNames.Length - 1)] + } + + It 'Should fail for multiparts > D except Z, E, R. Numerics are OK.' { + $fileNames = @( + "bbi-094f.wmv", + "bbi-094 - g.mp4", + "bbi-094-pt5.mp4" + ) + + $files = Get-Files $fileNames + $results = Convert-JVTitle $files -RegexEnabled $false + $results.ContentId | Should -Be (,"BBI00094" * $fileNames.Length) + $results.Id | Should -Be (,"BBI-094" * $fileNames.Length) + $results.PartNumber | Should -Be ($null, $null, 5) + } + } + }#describe_PrivateFunctions Describe 'Javinizer Public Function Tests' -Tag Unit { Context 'FunctionName' {