Skip to content

Commit

Permalink
Merge pull request #112 from seeyabye/feature/dmm-id
Browse files Browse the repository at this point in the history
[Proposal][Feature] Convert DMM's ContentID to standard ID
  • Loading branch information
jvlflame committed Sep 29, 2020
2 parents e33b972 + df942c9 commit 79bef59
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/Javinizer/Private/Convert-JVString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function Convert-JVString {
$actresses = ($actressObject | Sort-Object) -join $Delimiter
$convertedName = $FormatString `
-replace '<ID>', "$($Data.Id)" `
-replace '<CONTENTID>', "$($Data.ContentId)" `
-replace '<TITLE>', "$($Data.Title)" `
-replace '<RELEASEDATE>', "$($Data.ReleaseDate)" `
-replace '<YEAR>', "$(($Data.ReleaseDate -split '-')[0])" `
Expand Down
28 changes: 25 additions & 3 deletions src/Javinizer/Private/Scraper.Dmm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
16 changes: 9 additions & 7 deletions src/Javinizer/Public/Get-DmmData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand All @@ -44,7 +45,8 @@ function Get-DmmData {
$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
Expand Down
16 changes: 14 additions & 2 deletions src/Javinizer/Public/Get-JVAggregatedData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -141,6 +145,10 @@ function Get-JVAggregatedData {
[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
)
Expand All @@ -154,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'
Expand All @@ -177,6 +186,7 @@ function Get-JVAggregatedData {
$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'
}
Expand All @@ -187,6 +197,7 @@ function Get-JVAggregatedData {

$aggregatedDataObject = [PSCustomObject]@{
Id = $null
ContentId = $null
DisplayName = $null
Title = $null
AlternateTitle = $null
Expand Down Expand Up @@ -224,7 +235,8 @@ function Get-JVAggregatedData {
'Series',
'ScreenshotUrl',
'Title',
'TrailerUrl'
'TrailerUrl',
'ContentId'
)

foreach ($field in $metadataFields) {
Expand All @@ -239,7 +251,7 @@ function Get-JVAggregatedData {
if ($IdPreference -eq 'contentid') {
$aggregatedDataObject.$field = $sourceData.ContentId
} else {
$aggregatedDataObject.$field = $sourcedata.Id
$aggregatedDataObject.$field = $sourceData.Id
}
} else {
$aggregatedDataObject.$field = $sourceData.$field
Expand Down
6 changes: 3 additions & 3 deletions src/Javinizer/Public/Get-JVData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Get-JVData {
[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')]
Expand All @@ -68,7 +68,7 @@ function Get-JVData {
[PSObject]$Settings,

[Parameter(ParameterSetName = 'Url')]
[Array]$Url
[PSObject]$Url
)

process {
Expand Down Expand Up @@ -223,7 +223,7 @@ function Get-JVData {

if ($DmmJa) {
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-Dmm" -ThrottleLimit $throttleLimit -ScriptBlock {
Start-ThreadJob -Name "jvdata-DmmJa" -ThrottleLimit $throttleLimit -ScriptBlock {
Import-Module $using:jvModulePath
if ($using:DmmJaUrl) {
$using:DmmJaUrl | Get-DmmData -ScrapeActress:$using:DmmScrapeActress
Expand Down
2 changes: 2 additions & 0 deletions src/Javinizer/jvSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -77,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"],
Expand Down

0 comments on commit 79bef59

Please sign in to comment.