Skip to content

Commit

Permalink
Functionality updates and bugfixes for release 1.2.0 (#18)
Browse files Browse the repository at this point in the history
* Fix incorrect nfo actress entry due to casing

* Add Javinizer update check

* Remove verbose message on video success

* Update actress image download functionality

* Add new function to multisort

* Update for release 1.2.0
  • Loading branch information
jvlflame authored Mar 14, 2020
1 parent 096ec20 commit 4101c93
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 53 deletions.
9 changes: 9 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ 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/).

## [1.2.0]
### Added
- Functionality to download actress images that are pulled from r18-thumbs.csv
- Functionality to check for Javinizer module updates on startup
- Setting `check-updates=<True/False>`

### Fixed
- Issue where actresses scraped from JAVLibrary found in the r18-thumbs.csv file but not matching the correct casing (upper/lowercase) would erroneously be replaced with the last entry in r18-thumbs.csv

## [1.1.15] 03-08-2020
### Fixed
- Hotfix for 1.1.13 - Actresses failing to write to metadata properly when falling back to secondary or greater priority
Expand Down
2 changes: 1 addition & 1 deletion src/Javinizer/Javinizer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Javinizer.psm1'

# Version number of this module.
ModuleVersion = '1.1.15'
ModuleVersion = '1.2.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
32 changes: 17 additions & 15 deletions src/Javinizer/Private/Get-MetadataNfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ function Get-MetadataNfo {
$description = (($DataObject.Description -replace '&', '&amp;') -replace '<', '(') -replace , '>', ')'
$series = (($DataObject.Series -replace '&', '&amp;') -replace '<', '(') -replace , '>', ')'
if ($Settings.Metadata.'first-last-name-order' -eq 'True') {
$csvFullName = $R18ThumbCsv.FullName
$csvFullNameAlias = $R18ThumbCsv.Alias
$csvFullName = $R18ThumbCsv.FullName.ToLower()
$csvFullNameAlias = $R18ThumbCsv.Alias.ToLower()
} else {
$csvFullName = $R18ThumbCsv.FullNameReversed
$csvFullNameAlias = $R18ThumbCsv.Alias
$csvFullName = $R18ThumbCsv.FullNameReversed.ToLower()
$csvFullNameAlias = $R18ThumbCsv.Alias.ToLower()
}
}

Expand Down Expand Up @@ -140,18 +140,21 @@ function Get-MetadataNfo {

if (($DataObject.ActressThumbUrl -like '*nowprinting*') -or ($null -eq $DataObject.ActressThumbUrl)) {
if (($csvFullName -like $DataObject.Actress) -or ($csvFullNameAlias -like $DataObject.Actress)) {
$index = $csvFullname.IndexOf("$($DataObject.Actress)")
$index = $csvFullname.IndexOf("$($DataObject.Actress.ToLower())")
if ($index -eq -1) {
$index = $csvFullnameAlias.IndexOf("$($DataObject.Actress)")
$index = $csvFullnameAlias.IndexOf("$($DataObject.Actress.ToLower())")
}
if ($Settings.Metadata.'convert-alias-to-originalname' -eq 'True') {
if ($Settings.Metadata.'first-last-name-order' -eq 'True') {
$DataObject.Actress = $R18ThumbCsv.FullName[$index]
} else {
$DataObject.Actress = $R18ThumbCsv.FullNameReversed[$index]

if ($index -ne -1) {
if ($Settings.Metadata.'convert-alias-to-originalname' -eq 'True') {
if ($Settings.Metadata.'first-last-name-order' -eq 'True') {
$DataObject.Actress = $R18ThumbCsv.FullName[$index]
} else {
$DataObject.Actress = $R18ThumbCsv.FullNameReversed[$index]
}
}
$DataObject.ActressThumbUrl = $R18ThumbCsv.ThumbUrl[$index]
}
$DataObject.ActressThumbUrl = $R18ThumbCsv.ThumbUrl[$index]
} else {
$DataObject.ActressThumbUrl = ''
}
Expand Down Expand Up @@ -190,16 +193,15 @@ function Get-MetadataNfo {
}

$actressObject | Export-Csv -LiteralPath $r18CsvPath -Append -NoTypeInformation
Write-Verbose "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Actress [$($DataObject.Actress[$i])] written to [$r18CsvPath]"
}
}
}

if (($dataObject.ActressThumbUrl[$i] -like '*nowprinting*') -or ($DataObject.ActressThumbUrl[$i] -eq '')) {
if (($csvFullName -like $DataObject.Actress[$i]) -or ($csvFullNameAlias -like $DataObject.Actress[$i])) {
$index = $csvFullname.IndexOf("$($DataObject.Actress[$i])")
$index = $csvFullname.IndexOf("$($DataObject.Actress[$i].ToLower())")
if ($index -eq -1) {
$index = $csvFullnameAlias.IndexOf("$($DataObject.Actress[$i])")
$index = $csvFullnameAlias.IndexOf("$($DataObject.Actress[$i].ToLower())")
}
if ($Settings.Metadata.'convert-alias-to-originalname' -eq 'True') {
if ($Settings.Metadata.'first-last-name-order' -eq 'True') {
Expand Down
43 changes: 17 additions & 26 deletions src/Javinizer/Private/Set-JavMovie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,20 @@ function Set-JavMovie {
New-Item -ItemType Directory -Name $DataObject.FolderName -Path $fixedDestinationPath -Force:$Force -ErrorAction Stop | Out-Null
}

Get-MetadataNfo -DataObject $DataObject -Settings $Settings -R18ThumbCsv $r18ThumbCsv -ErrorAction 'SilentlyContinue' | Out-File -LiteralPath $fixednfoPath -Force:$Force -ErrorAction 'SilentlyContinue'
$nfoContents = Get-MetadataNfo -DataObject $DataObject -Settings $Settings -R18ThumbCsv $r18ThumbCsv -ErrorAction 'SilentlyContinue'
$nfoContents | Out-File -LiteralPath $fixednfoPath -Force:$Force -ErrorAction 'SilentlyContinue'
[xml]$nfoXML = Get-Content -LiteralPath $fixedNfoPath

if ($Settings.General.'rename-file' -eq 'True') {
Rename-Item -LiteralPath $Path -NewName $newFileName -PassThru -Force:$Force -ErrorAction Stop | Move-Item -Destination $folderPath -Force:$Force -ErrorAction 'Stop'
} else {
Move-Item -LiteralPath $Path -Destination $fixedFolderPath -Force:$Force -ErrorAction 'Stop'
}
} else {
Get-MetadataNfo -DataObject $DataObject -Settings $Settings -R18ThumbCsv $r18ThumbCsv -ErrorAction 'SilentlyContinue' | Out-File -LiteralPath $fixedNfoPath -Force:$Force -ErrorAction 'SilentlyContinue'
$nfoContents = Get-MetadataNfo -DataObject $DataObject -Settings $Settings -R18ThumbCsv $r18ThumbCsv -ErrorAction 'SilentlyContinue'
$nfoContents | Out-File -LiteralPath $fixedNfoPath -Force:$Force -ErrorAction 'SilentlyContinue'
[xml]$nfoXML = Get-Content -LiteralPath $fixedNfoPath

if ($Settings.General.'rename-file' -eq 'True') {
Rename-Item -LiteralPath $Path -NewName $newFileName -PassThru -Force:$Force -ErrorAction 'Stop' | Out-Null
}
Expand Down Expand Up @@ -148,34 +154,19 @@ function Set-JavMovie {
if ($Settings.Metadata.'download-actress-img' -eq 'True') {
if ($null -ne $DataObject.ActressThumbUrl) {
New-Item -ItemType Directory -Name $DataObject.ActorImgFolderName -Path $fixedFolderPath -Force:$Force -ErrorAction SilentlyContinue | Out-Null
if ($DataObject.ActressThumbUrl.Count -eq 1) {
if ($DataObject.ActressThumbUrl -match 'https:\/\/pics\.r18\.com\/mono\/actjpgs\/.*\.jpg') {
$first, $second = $DataObject.Actress -split ' '
if ($null -eq $second -or $second -eq '') {
$nfoActress = $nfoXml.movie.actor
foreach ($actress in $nfoActress) {
if ($actress.thumb -ne '') {
$firstName, $lastName = $actress.name -split ' '
if ($null -eq $lastName -or $lastName -eq '') {
$actressFileName = $first + '.jpg'
} else {
$actressFileName = $first + '_' + $second + '.jpg'
$actressFileName = $firstName + '_' + $lastName + '.jpg'
}
if ($Force.IsPresent) {
$webClient.DownloadFile($DataObject.ActressThumbUrl, (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
$webClient.DownloadFile($actress.thumb, (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
} elseif (-not (Test-Path -LiteralPath (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))) {
$webClient.DownloadFile($DataObject.ActressThumbUrl, (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
}
}
} else {
for ($i = 0; $i -lt $DataObject.ActressThumbUrl.Count; $i++) {
if ($DataObject.ActressThumbUrl[$i] -match 'https:\/\/pics\.r18\.com\/mono\/actjpgs\/.*\.jpg') {
$first, $second = $DataObject.Actress[$i] -split ' '
if ($null -eq $second -or $second -eq '') {
$actressFileName = $first + '.jpg'
} else {
$actressFileName = $first + '_' + $second + '.jpg'
}
if ($Force.IsPresent) {
$webClient.DownloadFile($DataObject.ActressThumbUrl[$i], (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
} elseif (-not (Test-Path -LiteralPath (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))) {
$webClient.DownloadFile($DataObject.ActressThumbUrl[$i], (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
}
$webClient.DownloadFile($actress.thumb, (Join-Path -Path $fixedActorPath -ChildPath $actressFileName))
}
}
}
Expand Down Expand Up @@ -204,7 +195,7 @@ function Set-JavMovie {
}

end {
Write-Verbose "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Success: [$($DataObject.OriginalFileName)]"
# Write-Verbose "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Success: [$($DataObject.OriginalFileName)]"
Write-Log -Log $logPath -Level INFO -Text "Success: [$($DataObject.OriginalFileName)]" -UseMutex
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function ended"
}
Expand Down
3 changes: 2 additions & 1 deletion src/Javinizer/Private/Start-MultiSort.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ function Start-MultiSort {
(Join-Path -Path $PSScriptRoot -ChildPath 'Test-RequiredMetadata.ps1'), `
(Join-Path -Path $PSScriptRoot -ChildPath 'Test-UrlLocation.ps1'), `
(Join-Path -Path $PSScriptRoot -ChildPath 'Test-UrlMatch.ps1'), `
(Join-Path -Path $PSScriptRoot -ChildPath 'Write-Log.ps1') | Wait-RSJob -ShowProgress | Receive-RSJob
(Join-Path -Path $PSScriptRoot -ChildPath 'Write-Log.ps1'), `
(Join-Path -Path $PSScriptRoot -ChildPath 'Update-Javinizer.ps1') | Wait-RSJob -ShowProgress | Receive-RSJob
}
27 changes: 27 additions & 0 deletions src/Javinizer/Private/Update-Javinizer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function Update-Javinizer {
$currentVer = (Get-InstalledModule -Name Javinizer).Version
$latestVer = (Find-Module -Name Javinizer).Version

if ($currentVer -ne $latestVer) {
Write-Host "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] There is a newer version of Javinizer available: [$currentVer --> $latestVer]"
}
}


<#
function Update-Javinizer {
param (
[string]$ScriptRoot,
[object]$Settings
)
$currentVer = (Get-InstalledModule -Name Javinizer).Version
$latestVer = (Find-Module -Name Javinizer).Version
Update-Module -Name Javinizer -AcceptLicense -Confirm:$false -Force
$modulePaths = (Get-Module -ListAvailable).Path | Where-Object { $_ -match 'Javinizer' }
$currentVerPath = (Get-Item ($modulePaths | Where-Object { $_ -match "$currentVer" })).DirectoryName
$latestVerPath = (Get-Item ($modulePaths | Where-Object { $_ -match "$latestVer" })).DirectoryName
}
#>
24 changes: 14 additions & 10 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,24 @@ function Javinizer {
throw "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Unable to load settings from path: $settingsPath"
}

if ($settings.Other.'check-updates' -eq 'True') {
Update-Javinizer
}

if (($settings.Other.'verbose-shell-output' -eq 'True') -or ($PSBoundParameters.ContainsKey('Verbose'))) { $VerbosePreference = 'Continue' } else { $VerbosePreference = 'SilentlyContinue' }
if ($settings.Other.'debug-shell-output' -eq 'True' -or ($DebugPreference -eq 'Continue')) { $DebugPreference = 'Continue' } elseif ($settings.Other.'debug-shell-output' -eq 'False') { $DebugPreference = 'SilentlyContinue' } else { $DebugPreference = 'SilentlyContinue' }
$ProgressPreference = 'SilentlyContinue'
Write-Host "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function started"
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Parameter set: [$($PSCmdlet.ParameterSetName)]"
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Bound parameters: [$($PSBoundParameters.Keys)]"
$settings.Main.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
$settings.General.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
$settings.Metadata.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
$settings.Locations.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
$settings.'Emby/Jellyfin'.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
$settings.Other.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Parameter set: [$($PSCmdlet.ParameterSetName)]"
#Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Bound parameters: [$($PSBoundParameters.Keys)]"
#$settings.Main.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#$settings.General.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#$settings.Metadata.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#$settings.Locations.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#$settings.'Emby/Jellyfin'.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'
#$settings.Other.GetEnumerator() | Sort-Object Key | Out-String | Write-Debug -ErrorAction 'SilentlyContinue'



if (-not ($PSBoundParameters.ContainsKey('r18')) -and `
(-not ($PSBoundParameters.ContainsKey('dmm')) -and `
Expand Down Expand Up @@ -446,5 +452,3 @@ function Javinizer {
Write-Host "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function ended"
}
}


1 change: 1 addition & 0 deletions src/Javinizer/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ server-url=192.168.0.1:8096
server-api-key=

[Other]
check-updates=True
verbose-shell-output=True
debug-shell-output=False

0 comments on commit 4101c93

Please sign in to comment.