Skip to content

Commit

Permalink
Added DMM Trailer (#90)
Browse files Browse the repository at this point in the history
* Added DMM Trailer

* Revised scraping method for DMM trailer

* Fix for en

* Add session to trailerurl

* Add session to trailerurl
  • Loading branch information
seeyabye committed Sep 21, 2020
1 parent 3ba9eae commit 918fe8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/Javinizer/Private/Scraper.Dmm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -389,25 +389,29 @@ function Get-DmmScreenshotUrl {
}
}

# ! Unable to get trailer url from HTTP from main DMM video page
<# function Get-DmmTrailerUrl {
function Get-DmmTrailerUrl {
param (
[Object]$Webrequest
)
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[Object]$Webrequest,

begin {
$trailerUrl = @()
}
[Parameter()]
[Object]$Session
)

process {
$trailerHtml = $Webrequest.Content -split '\n'
$trailerHtml = $trailerHtml | Select-String -Pattern 'https:\/\/cc3001\.dmm\.co\.jp\/litevideo\/freepv' -AllMatches
foreach ($trailer in $trailerHtml) {
$trailer = (($trailer -split '"')[1] -split '"')[0]
$trailerUrl += $trailer
$trailerUrl = @()
$iFrameUrl = 'https://www.dmm.co.jp' + ($Webrequest.Content | Select-String -Pattern "onclick.+sampleplay\('([^']+)'\)").Matches.Groups[1].Value
try {
$trailerPageUrl = ((Invoke-WebRequest -Uri $iFrameUrl -WebSession $session -Verbose:$false).Content | Select-String -Pattern 'src="([^"]+)"').Matches.Groups[1].Value -replace '/en', ''
$trailerUrl = ((Invoke-WebRequest -Uri $trailerPageUrl -Verbose:$false).Content | Select-String -Pattern '\\/\\/cc3001\.dmm\.co\.jp\\/litevideo\\/freepv[^"]+').Matches.Groups[0].Value -replace '\\', ''
if ($trailerUrl -match '^//') {
$trailerUrl = "https:$trailerUrl"
}
} catch {
return
}

Write-Output $trailerUrl
Write-Output "https:$trailerUrl"
}
} #>
}

1 change: 1 addition & 0 deletions src/Javinizer/Public/Get-DmmData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function Get-DmmData {
Genre = Get-DmmGenre -WebRequest $webRequest
CoverUrl = Get-DmmCoverUrl -WebRequest $webRequest
ScreenshotUrl = Get-DmmScreenshotUrl -WebRequest $webRequest
TrailerUrl = Get-DmmTrailerUrl -WebRequest $webRequest -Session:$session
}

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)"
Expand Down

0 comments on commit 918fe8d

Please sign in to comment.