Skip to content

Commit eabd618

Browse files
committed
Fixed several issues and moved update script to repository
1 parent 4cac59e commit eabd618

File tree

5 files changed

+222
-15
lines changed

5 files changed

+222
-15
lines changed

src/Javinizer/Javinizer.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# Version number of this module.
1515

16-
ModuleVersion = '2.5.11'
16+
ModuleVersion = '2.5.12'
1717

1818
# Supported PSEditions
1919
# CompatiblePSEditions = @('Core')

src/Javinizer/Misc/Invoke-Update.ps1

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
Write-Progress -Status "Updating Javinizer" -Activity "Fetching Javinizer settings files..." -PercentComplete 25
2+
$modulePath = (Get-InstalledModule Javinizer).InstalledLocation
3+
$origSettings = Get-Content -Path (Join-Path -Path $modulePath -ChildPath 'jvSettings.json') | ConvertFrom-Json -Depth 32
4+
5+
try {
6+
if (Test-Path -Path $origSettings.'location.thumbcsv') {
7+
$origThumbsPath = (Get-Item -Path $origSettings.'location.thumbcsv').FullName
8+
} else {
9+
$origThumbsPath = Join-Path -Path $modulePath -ChildPath 'jvThumbs.csv'
10+
}
11+
12+
$origThumbs = Import-Csv -Path $origThumbsPath -Encoding utf8 -ErrorAction Continue
13+
} catch {
14+
Write-Error "Error occurred when retrieving thumb csv [$origThumbsPath]: $PSItem" -ErrorAction Stop
15+
}
16+
17+
try {
18+
if (Test-Path -Path $origSettings.'location.genrecsv') {
19+
$origGenresPath = (Get-Item -Path $origSettings.'location.genrecsv').FullName
20+
} else {
21+
$origGenresPath = Join-Path -Path $modulePath -ChildPath 'jvGenres.csv'
22+
}
23+
24+
$origGenres = Import-Csv -Path $origGenresPath -Encoding utf8 -ErrorAction Continue
25+
} catch {
26+
Write-Error "Error occurred when retrieving genre csv [$origGenresPath]: $PSItem" -ErrorAction Stop
27+
}
28+
29+
try {
30+
if (Test-Path -Path $origSettings.'location.uncensorcsv') {
31+
$origUncensorPath = (Get-Item -Path $origSettings.'location.uncensorcsv').FullName
32+
} else {
33+
$origUncensorPath = Join-Path -Path $modulePath -ChildPath 'jvUncensor.csv'
34+
}
35+
36+
$origUncensor = Import-Csv -Path $origUncensorPath -Encoding utf8 -ErrorAction Continue
37+
} catch {
38+
Write-Error "Error occurred when retrieving uncensor csv [$origUncensorPath]: $PSItem" -ErrorAction Stop
39+
}
40+
41+
try {
42+
if (Test-Path -Path $origSettings.'location.historycsv') {
43+
$origHistoryPath = (Get-Item -Path $origSettings.'location.historycsv').FullName
44+
} else {
45+
$origHistoryPath = Join-Path -Path $modulePath -ChildPath 'jvHistory.csv'
46+
}
47+
48+
$origHistory = Import-Csv -Path $origHistoryPath -Encoding utf8 -ErrorAction Continue
49+
} catch {
50+
Write-Error "Error occurred when retrieving history csv [$origHistoryPath]: $PSItem" -ErrorAction Stop
51+
}
52+
53+
try {
54+
if (Test-Path -Path $origSettings.'location.tagcsv') {
55+
$origTagsPath = (Get-Item -Path $origSettings.'location.tagcsv').FullName
56+
} else {
57+
$origTagsPath = Join-Path -Path $modulePath -ChildPath 'jvTags.csv'
58+
}
59+
60+
$origTags = Import-Csv -Path $origTagsPath -Encoding utf8 -ErrorAction Continue
61+
} catch {
62+
Write-Error "Error occurred when retrieving tag csv [$origTagsPath]: $PSItem" -ErrorAction Stop
63+
}
64+
65+
try {
66+
Write-Progress -Status "Updating Javinizer" -Activity "Updating Javinizer module via PowerShell Gallery..." -PercentComplete 50
67+
Update-Module -Name 'Javinizer' -Force -Confirm:$false
68+
} catch {
69+
Write-Error "Error occurred when updating the Javinizer module: $PSItem" -ErrorAction Stop
70+
}
71+
72+
$newModulePath = (Get-InstalledModule -Name 'Javinizer').InstalledLocation
73+
74+
# Update jvSettings
75+
$supportedScrapers = Get-Help Get-JVData -Parameter * | Select-Object -ExpandProperty aliases | Where-Object { $_.StartsWith("scraper.movie") } | ForEach-Object { $_.Replace("scraper.movie.", "") }
76+
$newSettingsPath = Join-Path -Path $newModulePath -ChildPath 'jvSettings.json'
77+
$newSettings = Get-JVSettings -Path $newSettingsPath
78+
$newSettings.PSObject.Properties | ForEach-Object {
79+
$property = $_
80+
if ($origSettings.PSObject.Properties.Name -contains $_.Name) {
81+
$newSettings."$($_.Name)" = ($origSettings.PSObject.Properties | Where-Object { $_.Name -eq $property.Name })[0].Value
82+
if ($_.Name.StartsWith("sort.metadata.priority")) {
83+
$elementIndex = $_.Value.IndexOf(($_.Value | Where-Object { $_ -eq "r18" }))
84+
if ($elementIndex -ge 0) {
85+
$_.Value[$elementIndex] = "r18dev"
86+
}
87+
$newSettings."$($_.Name)" = $_.Value | Where-Object { $_ -in $supportedScrapers }
88+
}
89+
}
90+
}
91+
92+
try {
93+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating settings to $newSettingsPath..." -PercentComplete 65
94+
$newSettings | ConvertTo-Json -Depth 32 | Out-File -FilePath $newSettingsPath -Force -ErrorAction Continue
95+
} catch {
96+
Write-Error "Error occurred when updating the existing settings file at path [$newSettingsPath]: $PSItem" -ErrorAction Continue
97+
$tempFile = New-TemporaryFile
98+
$newSettings | ConvertTo-Json -Depth 32 | Out-File -FilePath $tempFile
99+
Write-Warning "Writing updated settings file to temp location: $(Join-Path -Path $env:TEMP -ChildPath $tempFile)"
100+
}
101+
102+
# Update jvThumbs
103+
try {
104+
$newThumbsPath = Join-Path -Path $newModulePath -ChildPath 'jvThumbs.csv'
105+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating thumbs to $newThumbsPath..." -PercentComplete 70
106+
Write-Host "Migrating $origThumbsPath => $newThumbsPath"
107+
Copy-Item -Path $origThumbsPath -Destination $newThumbsPath -Force
108+
<# $newThumbs = Import-Csv -Path $newThumbsPath -Encoding utf8
109+
if ($null -ne $origThumbs) {
110+
$thumbsDifference = (Compare-Object -ReferenceObject $origThumbs -DifferenceObject $newThumbs -ErrorAction SilentlyContinue).InputObject
111+
if ($thumbsDifference) {
112+
$thumbsDifference | Export-Csv -Path $newThumbsPath -Append -Encoding utf8 -ErrorAction SilentlyContinue
113+
Write-Host "Migrating $origThumbsPath => $newThumbsPath"
114+
} else {
115+
Write-Host "Migrating $origThumbsPath => $newThumbsPath (no changes)"
116+
}
117+
} #>
118+
} catch {
119+
Write-Warning "Error [$origThumbsPath]: $PSItem"
120+
}
121+
122+
# Update jvGenres
123+
try {
124+
$newGenresPath = Join-Path -Path $newModulePath -ChildPath 'jvGenres.csv'
125+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating genres to $newGenresPath..." -PercentComplete 75
126+
Write-Host "Migrating $origGenresPath => $newGenresPath"
127+
Copy-Item -Path $origGenresPath -Destination $newGenresPath -Force
128+
<# $newGenres = Import-Csv -Path $newGenresPath -Encoding utf8
129+
if ($null -ne $origGenres) {
130+
$genresDifference = (Compare-Object -ReferenceObject $origGenres -DifferenceObject $newGenres -ErrorAction SilentlyContinue).InputObject
131+
if ($genresDifference) {
132+
$genresDifference | Export-Csv -Path $newGenresPath -Append -Encoding utf8 -ErrorAction SilentlyContinue
133+
} else {
134+
Write-Host "Migrating $origGenresPath => $newGenresPath (no changes)"
135+
}
136+
} #>
137+
} catch {
138+
Write-Warning "Error [$origGenresPath]: $PSItem"
139+
}
140+
141+
# Update jvUncensor
142+
try {
143+
$newUncensorPath = Join-Path -Path $newModulePath -ChildPath 'jvUncensor.csv'
144+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating uncensors to $newUncensorPath..." -PercentComplete 80
145+
$newUncensor = Import-Csv -Path $newUncensorPath -Encoding utf8
146+
if ($null -ne $origUncensor) {
147+
$uncensorDifference = (Compare-Object -ReferenceObject $origUncensor -DifferenceObject $newUncensor -ErrorAction SilentlyContinue).InputObject
148+
if ($uncensorDifference) {
149+
$uncensorDifference | Export-Csv -Path $newUncensorPath -Append -Encoding utf8 -ErrorAction SilentlyContinue
150+
Write-Host "Migrating $origUncensorPath => $newUncensorPath"
151+
} else {
152+
Write-Host "Migrating $origUncensorPath => $newUncensorPath (no changes)"
153+
}
154+
}
155+
} catch {
156+
Write-Warning "Error [$origUncensorPath]: $PSItem"
157+
}
158+
159+
# Update jvHistory
160+
try {
161+
$newHistoryPath = Join-Path -Path $newModulePath -ChildPath 'jvHistory.csv'
162+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating history to $newHistoryPath..." -PercentComplete 85
163+
Write-Host "Migrating $origHistoryPath => $newHistoryPath"
164+
Copy-Item -Path $origHistoryPath -Destination $newHistoryPath -Force
165+
<# $newHistory = Import-Csv -Path $newHistoryPath -Encoding utf8
166+
if ($null -ne $origHistory) {
167+
$historyDifference = (Compare-Object -ReferenceObject $origHistory -DifferenceObject $newHistory -ErrorAction SilentlyContinue).InputObject
168+
if ($historyDifference) {
169+
$historyDifference | Export-Csv -Path $newHistoryPath -Append -Encoding utf8 -ErrorAction SilentlyContinue
170+
} else {
171+
Write-Host "Migrating $origHistoryPath => $newHistoryPath (no changes)"
172+
}
173+
} #>
174+
} catch {
175+
Write-Warning "Error [$origHistoryPath]: $PSItem"
176+
}
177+
178+
# Update jvTags
179+
try {
180+
$newTagsPath = Join-Path -Path $newModulePath -ChildPath 'jvTags.csv'
181+
Write-Progress -Status "Updating Javinizer" -Activity "Migrating tags to $newTagsPath..." -PercentComplete 90
182+
Write-Host "Migrating $origTagsPath => $newTagsPath"
183+
Copy-Item -Path $origTagsPath -Destination $newTagsPath -Force
184+
<# $newTags = Import-Csv -Path $newTagsPath -Encoding utf8
185+
if ($null -ne $origTags) {
186+
$tagsDifference = (Compare-Object -ReferenceObject $origTags -DifferenceObject $newTags -ErrorAction SilentlyContinue).InputObject
187+
if ($tagsDifference) {
188+
$tagsDifference | Export-Csv -Path $newTagsPath -Append -Encoding utf8 -ErrorAction SilentlyContinue
189+
} else {
190+
Write-Host "Migrating $origTagsPath => $newTagsPath (no changes)"
191+
}
192+
} #>
193+
} catch {
194+
Write-Warning "Error [$origTagsPath]: $PSItem"
195+
}
196+
197+
Write-Host "Javinizer update completed! Restart your shell to continue." -ForegroundColor Green

src/Javinizer/Public/Javinizer.ps1

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ function Javinizer {
5757
.PARAMETER Nfo
5858
Specifies to output the nfo contents from -Find.
5959
60+
.PARAMETER R18Dev
61+
Specifies to search R18.dev when using -Find.
62+
6063
.PARAMETER Dmm
6164
Specifies to search Dmm when using -Find.
6265
@@ -180,7 +183,7 @@ function Javinizer {
180183
Sorts files from a path and specify an external settings file to use.
181184
182185
.EXAMPLE
183-
Javinizer -Find 'ABP-420' -R18 -Dmm
186+
Javinizer -Find 'ABP-420' -R18Dev -Dmm
184187
185188
Description
186189
-----------
@@ -194,7 +197,7 @@ function Javinizer {
194197
Find an array of urls metadata and aggregates them according to your settings file.
195198
196199
.EXAMPLE
197-
Javinizer -Find 'ABP-420' -R18 -Javlibrary -Dmm -Aggregated -Nfo
200+
Javinizer -Find 'ABP-420' -R18Dev -Javlibrary -Dmm -Aggregated -Nfo
198201
199202
Description
200203
-----------
@@ -333,6 +336,9 @@ function Javinizer {
333336
[Parameter(ParameterSetNAme = 'Info')]
334337
[Switch]$Nfo,
335338

339+
[Parameter(ParameterSetName = 'Info')]
340+
[Switch]$R18Dev,
341+
336342
[Parameter(ParameterSetName = 'Info')]
337343
[Switch]$Dmm,
338344

@@ -718,7 +724,7 @@ function Javinizer {
718724
$item.Url | Get-JavlibraryData -JavlibraryBaseUrl $Settings.'javlibrary.baseurl'
719725
}
720726

721-
if ($item.Source -match 'r18') {
727+
if ($item.Source -match 'r18dev') {
722728
$item.Url | Get-R18DevData -UncensorCsvPath:$uncensorCsvPath
723729
}
724730

@@ -748,7 +754,7 @@ function Javinizer {
748754
}
749755
} else {
750756
$data = Get-JVData -Id $Find -Javlibrary:$Javlibrary -JavlibraryJa:$JavlibraryJa -JavlibraryZh:$JavlibraryZh -Dmm:$Dmm `
751-
-DmmJa:$DmmJa -Javbus:$Javbus -JavbusJa:$JavbusJa -JavbusZh:$JavbusZh -Jav321Ja:$Jav321Ja -JavlibraryBaseUrl $Settings.'javlibrary.baseurl' `
757+
-DmmJa:$DmmJa -R18Dev:$R18Dev -Javbus:$Javbus -JavbusJa:$JavbusJa -JavbusZh:$JavbusZh -Jav321Ja:$Jav321Ja -JavlibraryBaseUrl $Settings.'javlibrary.baseurl' `
752758
-MgstageJa:$MgstageJa -Aventertainment:$Aventertainment -AventertainmentJa:$AventertainmentJa -Tokyohot:$Tokyohot -TokyohotJa:$TokyohotJa -TokyohotZh:$TokyohotZh -UncensorCsvPath $uncensorCsvPath -Strict:$Strict `
753759
-Javdb:$Javdb -JavdbZh:$JavdbZh -Session:$CfSession -JavdbSession:$Settings.'javdb.cookie.session' -AllResults:$AllResults
754760
}
@@ -980,7 +986,11 @@ function Javinizer {
980986
$DestinationPath = $Settings.'location.output'
981987
} catch {
982988
# Default destination path to the current directory if settings not specified
983-
$DestinationPath = (Get-Item -LiteralPath $Path).Directory
989+
if ((Get-Item $Path).PSIsContainer) {
990+
$DestinationPath = (Get-Item -LiteralPath $Path).FullName
991+
} else {
992+
$DestinationPath = (Get-Item -LiteralPath $Path).DirectoryName
993+
}
984994
}
985995
}
986996

src/Javinizer/Public/Update-JVModule.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ function Update-JVModule {
1414
[Switch]$GuiVersion,
1515

1616
[Parameter(ParameterSetName = 'Update')]
17-
[String]$UpdateUrl = 'https://gist.githubusercontent.com/jvlflame/0e8293198e59c286ccf1a438ea8a76e9/raw'
17+
[String]$UpdateUrl = 'https://raw.githubusercontent.com/jvlflame/Javinizer/master/src/Javinizer/Misc/Invoke-Update.ps1'
1818
)
1919

2020
process {
2121
switch ($PsCmdlet.ParameterSetName) {
2222
'Check' {
2323
if ($IsWeb) {
2424
$installedVersion = (Get-JVModuleInfo).Version
25-
$latestVersion = (Find-Module -Name 'Javinizer').Version
26-
if ($installedVersion -ne $latestVersion) {
25+
$latestVersion = ((Find-Module -Name 'Javinizer') | Select-Object -First 1).Version
26+
if ([System.Version]$installedVersion -lt [System.Version]$latestVersion) {
2727
Show-JVToast -Type Success -Message "There is a new version of Javinizer available $installedVersion => $latestVersion"
2828
} else {
2929
Show-JVToast -Type Info -Message "There are no updates for Javinizer available"
@@ -32,7 +32,7 @@ function Update-JVModule {
3232
$guiCheck = Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/jvlflame/Javinizer/master/src/Javinizer/Universal/Repository/javinizergui.ps1' -MaximumRetryCount 3
3333
$latestGuiVersion = ($guiCheck.Content | Select-String -Pattern "\`$cache\:guiVersion = '(.*)'").Matches.Groups[1].Value
3434

35-
if ($GuiVersion -ne $latestGuiVersion) {
35+
if ([System.Version]$GuiVersion -lt [System.Version]$latestGuiVersion) {
3636
Show-JVToast -Type Success -Message "There is a new version of Javinizer GUI available $GuiVersion => $latestGuiVersion"
3737
} else {
3838
Show-JVToast -Type Info -Message "There are no updates for Javinizer GUI available"
@@ -42,11 +42,11 @@ function Update-JVModule {
4242
# Set global variable to determine that check has already been completed in the current session
4343
$global:jvUpdateCheck = $true
4444
$installedVersion = (Get-JVModuleInfo).Version
45-
$latestVersion = (Find-Module -Name 'Javinizer').Version
45+
$latestVersion = ((Find-Module -Name 'Javinizer') | Select-Object -First 1).Version
4646
Write-Debug "Installed version: $installedVersion"
4747
Write-Debug "Latest version: $latestVersion"
4848

49-
if ($installedVersion -ne $latestVersion) {
49+
if ([System.Version]$installedVersion -lt [System.Version]$latestVersion) {
5050
Write-Warning "There is a newer version of Javinizer available! (Set 'admin.updates.check' to false to hide this message)"
5151
Write-Warning "You can update your module using 'Javinizer -UpdateModule'"
5252
Write-Warning "$installedVersion => $latestVersion"
@@ -62,9 +62,9 @@ function Update-JVModule {
6262
}
6363

6464
$installedVersion = (Get-JVModuleInfo).Version
65-
$latestVersion = (Find-Module -Name 'Javinizer').Version
65+
$latestVersion = ((Find-Module -Name 'Javinizer') | Select-Object -First 1).Version
6666

67-
if ($installedVersion -ne $latestVersion) {
67+
if ([System.Version]$installedVersion -lt [System.Version]$latestVersion) {
6868
Write-Warning "Starting update process, please make sure to close all related Javinizer settings files before continuing"
6969
Write-Warning "Updating from version [$installedVersion => $latestVersion]"
7070
Pause

src/Javinizer/Universal/Repository/javinizergui.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$cache:guiVersion = '2.5.11-1'
1+
$cache:guiVersion = '2.5.12-1'
22

33
# Define Javinizer module file paths
44
$cache:modulePath = (Get-InstalledModule -Name Javinizer).InstalledLocation

0 commit comments

Comments
 (0)