Skip to content

Commit

Permalink
Merge pull request #64 from jvlflame/rewrite
Browse files Browse the repository at this point in the history
Rewrite
  • Loading branch information
jvlflame committed Sep 1, 2020
2 parents 52ab693 + a0bcc4e commit 450c04b
Show file tree
Hide file tree
Showing 67 changed files with 14,282 additions and 25,327 deletions.
2 changes: 1 addition & 1 deletion src/Javinizer.build.ps1
Expand Up @@ -173,7 +173,7 @@ Add-BuildTask FormattingCheck {

if ($scriptAnalyzerResults) {
$scriptAnalyzerResults | Format-Table
throw ' PSScriptAnalyzer code formatting check did not adhere to {0} standards' -f $scriptAnalyzerParams.Setting
throw ' PSScriptAnalyzer code formatting check did not adhere to {0} standards' -f $scriptAnalyzerParams.Setting
} else {
Write-Build Green ' ...Formatting Analyze Complete!'
}
Expand Down
27 changes: 22 additions & 5 deletions src/Javinizer/Javinizer.psd1
Expand Up @@ -13,7 +13,7 @@

# Version number of this module.

ModuleVersion = '1.7.3'
ModuleVersion = '2.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -70,7 +70,26 @@
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Javinizer')
FunctionsToExport = @(
'Javinizer',
'Get-DmmData',
'Get-DmmUrl',
'Get-Jav321Data',
'Get-Jav321Url',
'Get-JavBusData',
'Get-JavbusUrl',
'Get-JavlibraryData',
'Get-JavlibraryUrl',
'Get-JVAggregatedData',
'Get-JVData',
'Get-JVItem',
'Get-JVNfo',
'Get-R18Data',
'Get-R18Url',
'Set-JVEmbyThumbs',
'Set-JVMovie',
'Update-JVThumbs'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
Expand Down Expand Up @@ -111,7 +130,7 @@
ReleaseNotes = 'https://github.com/jvlflame/Javinizer/blob/master/.github/CHANGELOG.md'

# Prerelease string of this module
# Prerelease = ''
Prerelease = 'alpha1'

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false
Expand All @@ -130,5 +149,3 @@
# DefaultCommandPrefix = ''

}


23 changes: 0 additions & 23 deletions src/Javinizer/Private/Convert-CommaDelimitedString.ps1

This file was deleted.

7 changes: 4 additions & 3 deletions src/Javinizer/Private/Convert-HTMLCharacter.ps1
@@ -1,7 +1,9 @@
function Convert-HTMLCharacter {
[CmdletBinding()]
param (
[string]$String
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
[AllowEmptyString()]
[String]$String
)

process {
Expand All @@ -17,8 +19,7 @@ function Convert-HTMLCharacter {
-replace '&#039', ''

$newString = $String.Trim()
# Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Begin String: [$String]; End string: [$newString]"
# Write-JVLog -Level Debug -Message "Begin String: [$String]; End string: [$newString]"
Write-Output $newString

}
}
75 changes: 75 additions & 0 deletions src/Javinizer/Private/Convert-JVString.ps1
@@ -0,0 +1,75 @@
function Convert-JVString {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[PSObject]$Data,

[Parameter(Mandatory = $true)]
[String]$FormatString,

[Parameter()]
[Int]$PartNumber,

[Parameter()]
[Int]$MaxTitleLength
)

process {
# These symbols need to be removed to create a valid Windows filesystem name
$invalidSymbols = @(
'\',
'/',
':',
'*',
'?',
'"',
'<',
'>',
'|',
"'"
)

if ($maxTitleLength) {
if ($Data.Title.Length -ge $MaxTitleLength) {
$shortTitle = $Data.Title.Substring(0, $MaxTitleLength)
$splitTitle = $shortTitle -split ' '
if ($splitTitle.Count -gt 1) {
# Remove the last word of the title just in case it is cut off
$title = ($splitTitle[0..($splitTitle.Length - 2)] -join ' ')
if ($title[-1] -match '\W') {
$Data.Title = ($title.Substring(0, $title.Length - 2)) + '...'
} else {
$Data.Title = $title + '...'
}
} else {
$Data.Title = $shortTitle + '...'
}
}
}

$convertedName = $FormatString `
-replace '<ID>', "$($Data.Id)" `
-replace '<TITLE>', "$($Data.Title)" `
-replace '<RELEASEDATE>', "$($Data.ReleaseDate)" `
-replace '<YEAR>', "$(($Data.ReleaseDate -split '-')[0])" `
-replace '<STUDIO>', "$($Data.Maker)" `
-replace '<RUNTIME>', "$($Data.Runtime)" `
-replace '<SET>', "$($Data.Series)" `
-replace '<LABEL>', "$($Data.Label)" `
-replace '<ORIGINALTITLE>', "$($Data.AlternateTitle)"

foreach ($symbol in $invalidSymbols) {
if ([regex]::Escape($symbol) -eq '/') {
$convertedName = $convertedName -replace [regex]::Escape($symbol), '-'
} else {
$convertedName = $convertedName -replace [regex]::Escape($symbol), ''
}
}

if ($PartNumber) {
$convertedName += "-pt$PartNumber"
}

Write-Output $convertedName
}
}

0 comments on commit 450c04b

Please sign in to comment.