From f8cdb56b47e8e1861f487763a2333e5075fa914b Mon Sep 17 00:00:00 2001 From: jvlflame Date: Sun, 9 Aug 2020 15:19:49 -0700 Subject: [PATCH] Remove old files --- .../Private/Display-ConfirmMessage.ps1 | 27 --- src/Javinizer/Private/Format-Color.ps1 | 33 --- src/Javinizer/Private/Get-FindDataObject.ps1 | 228 ------------------ src/Javinizer/Private/Get-Log.ps1 | 52 ---- .../Private/Get-MetadataPriority.ps1 | 17 -- src/Javinizer/Private/Import-IniSettings.ps1 | 94 -------- src/Javinizer/Private/Test-UrlMatch.ps1 | 28 --- src/Javinizer/Private/Write-JLog.ps1 | 31 --- src/Javinizer/Private/Write-Log.ps1 | 63 ----- 9 files changed, 573 deletions(-) delete mode 100644 src/Javinizer/Private/Display-ConfirmMessage.ps1 delete mode 100644 src/Javinizer/Private/Format-Color.ps1 delete mode 100644 src/Javinizer/Private/Get-FindDataObject.ps1 delete mode 100644 src/Javinizer/Private/Get-Log.ps1 delete mode 100644 src/Javinizer/Private/Get-MetadataPriority.ps1 delete mode 100644 src/Javinizer/Private/Import-IniSettings.ps1 delete mode 100644 src/Javinizer/Private/Test-UrlMatch.ps1 delete mode 100644 src/Javinizer/Private/Write-JLog.ps1 delete mode 100644 src/Javinizer/Private/Write-Log.ps1 diff --git a/src/Javinizer/Private/Display-ConfirmMessage.ps1 b/src/Javinizer/Private/Display-ConfirmMessage.ps1 deleted file mode 100644 index 57f22f77..00000000 --- a/src/Javinizer/Private/Display-ConfirmMessage.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -function Display-ConfirmMessage { - [CmdletBinding()] - param( - [string]$Message, - [string]$Default - ) - - process { - $Default = $Default.ToUpper() - Write-Host "$Message" - $selection = Read-Host "[Y] Yes [N] No (Default is ""$Default"")" - do { - if ($selection -eq '' -or $null -eq $selection) { - $selection = $Default - } elseif ($selection -eq 'y' -or $selection -eq 'yes') { - $selection = 'y' - } elseif ($selection -eq 'n' -or $selection -eq 'no') { - $selection = 'n' - } else { - Write-Warning "Your selection [$selection] is invalid." - $selection = Read-Host "[Y] Yes [N] No (Default is ""$Default"")" - } - } until ($selection -eq 'y' -or $selection -eq 'n') - - Write-Output $selection - } -} diff --git a/src/Javinizer/Private/Format-Color.ps1 b/src/Javinizer/Private/Format-Color.ps1 deleted file mode 100644 index 5541346e..00000000 --- a/src/Javinizer/Private/Format-Color.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -function Format-Color([hashtable] $Colors = @{ }, [switch] $SimpleMatch) { - - $lines = ($input | Out-String) -replace "`r", "" -split "`n" - foreach ($line in $lines) { - $color = '' - foreach ($pattern in $Colors.Keys) { - if (!$SimpleMatch -and $line -match $pattern) { - $color = $Colors[$pattern] - if ($color) { - $seg1 = ($line -split $pattern)[0] - $seg2 = ($line -split $pattern)[1] - Write-Host $seg1 -NoNewLine - Write-Host $pattern -ForegroundColor $color -NoNewline - Write-Host $seg2 - } - } - - elseif ($SimpleMatch -and $line -like $pattern) { - $color = $Colors[$pattern] - if ($color) { - $seg1 = ($line -split $pattern)[0] - $seg2 = ($line -split $pattern)[1] - Write-Host $seg1 -NoNewLine - Write-Host $pattern -ForegroundColor $color -NoNewline - Write-Host $seg2 - } - } - } - if (!$color) { - Write-Host $line - } - } -} diff --git a/src/Javinizer/Private/Get-FindDataObject.ps1 b/src/Javinizer/Private/Get-FindDataObject.ps1 deleted file mode 100644 index be6b555f..00000000 --- a/src/Javinizer/Private/Get-FindDataObject.ps1 +++ /dev/null @@ -1,228 +0,0 @@ -function Get-FindDataObject { - [CmdletBinding()] - param( - [string]$Find, - [object]$Settings, - [switch]$Aggregated, - [switch]$Dmm, - [switch]$Javlibrary, - [switch]$JavlibraryZh, - [switch]$JavlibraryJa, - [switch]$Javbus, - [switch]$JavbusJa, - [switch]$Jav321, - [switch]$R18, - [switch]$R18Zh - ) - - begin { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function started" - $urlList = @() - - if (-not ($PSBoundParameters.ContainsKey('r18')) -and ` - (-not ($PSBoundParameters.ContainsKey('dmm')) -and ` - (-not ($PSBoundParameters.ContainsKey('javlibrary')) -and ` - (-not ($PSBoundParameters.ContainsKey('javlibraryzh')) -and ` - (-not ($PSBoundParameters.ContainsKey('javlibraryja')) -and ` - (-not ($PSBoundParameters.ContainsKey('r18zh')) -and ` - (-not ($PSBoundParameters.ContainsKey('javbus')) -and ` - (-not ($PSBoundParameters.ContainsKey('javbusja')) -and ` - (-not ($PSBoundParameters.ContainsKey('jav321'))))))))))) { - if ($settings.Main.'scrape-r18' -eq 'true') { - $R18 = $true - } - if ($settings.Main.'scrape-dmm' -eq 'true') { - $Dmm = $true - } - if ($settings.Main.'scrape-javlibrary' -eq 'true') { - $Javlibrary = $true - } - if ($settings.Main.'scrape-javlibraryzh' -eq 'true') { - $JavlibraryZh = $true - } - if ($settings.Main.'scrape-javlibraryja' -eq 'true') { - $JavlibraryJa = $true - } - if ($settings.Main.'scrape-r18zh' -eq 'true') { - $R18Zh = $true - } - if ($settings.Main.'scrape-javbus' -eq 'true') { - $Javbus = $true - } - if ($settings.Main.'scrape-javbusja' -eq 'true') { - $javbusJa = $true - } - - if ($settings.Main.'scrape-jav321' -eq 'true') { - $jav321 = $true - } - } - } - - process { - if (Test-Path -Path $Find) { - $getItem = Get-Item $Find - } - - if ($Find -match 'http:\/\/' -or $Find -match 'https:\/\/') { - $urlList = Convert-CommaDelimitedString -String $Find - $urlLocation = Test-UrlLocation -Url $urlList - if ($Aggregated.IsPresent) { - $aggregatedDataObject = Get-AggregatedDataObject -UrlLocation $urlLocation -Settings $Settings -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $aggregatedDataObject - } else { - if ($urlLocation.Result -eq 'r18') { - $r18Data = Get-R18DataObject -Url $Find -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($urlLocation.Result -eq 'r18zh') { - $r18Data = Get-R18DataObject -Url $Find -Zh -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($urlLocation.Result -eq 'dmm') { - $dmmData = Get-DmmDataObject -Url $Find -ErrorAction 'SilentlyContinue' - Write-Output $dmmData - } - - if ($urlLocation.Result -eq 'javlibrary') { - $javlibraryData = Get-JavlibraryDataObject -Url $Find -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($urlLocation.Result -eq 'javlibraryzh') { - $javlibraryData = Get-JavLibraryDataObject -Url $Find -Zh -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($urlLocation.Result -eq 'javlibraryja') { - $javlibraryData = Get-JavLibraryDataObject -Url $Find -Ja -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($urlLocation.Result -eq 'javbus') { - $javbusData = Get-JavbusDataObject -Url $Find -ErrorAction 'SilentlyContinue' - Write-Output $javbusData - } - - if ($urlLocation.Result -eq 'javbusja') { - $javbusData = Get-JavbusDataObject -Url $Find -Ja -ErrorAction 'SilentlyContinue' - Write-Output $javbusData - } - - if ($urlLocation.Result -eq 'jav321') { - $jav321Data = Get-Jav321DataObject -Url $Find -ErrorAction 'SilentlyContinue' - Write-Output $jav321Data - } - } - } elseif ($null -ne $getItem) { - if (Test-Path -Path $getItem -PathType Leaf) { - $fileDetails = Convert-JavTitle -Path $Find -Recurse:$Recurse -Settings $Settings - if ($Aggregated.IsPresent) { - $aggregatedDataObject = Get-AggregatedDataObject -FileDetails $fileDetails -Settings $ettings -R18:$R18 -Dmm:$Dmm -Javlibrary:$Javlibrary -JavlibraryJa:$JavlibraryJa -JavlibraryZh:$JavlibraryZh -Javbus:$Javbus -JavbusJa:$JavbusJa -Jav321:$Jav321 -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $aggregatedDataObject - } else { - if ($r18) { - $r18Data = Get-R18DataObject -Name $fileDetails.Id -AltName $fileDetails.ContentId -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($r18zh) { - $r18Data = Get-R18DataObject -Name $fileDetails.Id -AltName $fileDetails.ContentId -Zh -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($dmm) { - $dmmData = Get-DmmDataObject -Name $fileDetails.Id -AltName $fileDetails.ContentId -ErrorAction 'SilentlyContinue' - Write-Output $dmmData - } - - if ($javlibrary) { - $javlibraryData = Get-JavlibraryDataObject -Name $fileDetails.Id -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javlibraryzh) { - $javlibraryData = Get-JavlibraryDataObject -Name $fileDetails.Id -ScriptRoot $ScriptRoot -Zh -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javlibraryja) { - $javlibraryData = Get-JavlibraryDataObject -Name $fileDetails.Id -ScriptRoot $ScriptRoot -Ja -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javbus) { - $javbusData = Get-JavbusDataObject -Name $fileDetails.Id -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javbusja) { - $javbusData = Get-JavbusDataObject -Name $fileDetails.Id -Ja -ErrorAction 'SilentlyContinue' - Write-Output $javbusData - } - - if ($jav321) { - $jav321Data = Get-Jav321DataObject -name $fileDetails.Id -ErrorAction 'SilentlyContinue' - Write-Output $jav321Data - } - } - } - } else { - if ($Aggregated.IsPresent) { - $aggregatedDataObject = Get-AggregatedDataObject -Id $Find -Settings $Settings -R18:$R18 -Dmm:$Dmm -Javlibrary:$Javlibrary -Javbus:$Javbus -JavbusJa:$JavbusJa -Jav321:$Jav321 -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $aggregatedDataObject - } else { - if ($r18) { - $r18Data = Get-R18DataObject -Name $Find -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($r18zh) { - $r18Data = Get-R18DataObject -Name $Find -Zh -ErrorAction 'SilentlyContinue' - Write-Output $r18Data - } - - if ($dmm) { - $dmmData = Get-DmmDataObject -Name $Find -ErrorAction 'SilentlyContinue' - Write-Output $dmmData - } - - if ($javlibrary) { - $javlibraryData = Get-JavlibraryDataObject -Name $Find -ScriptRoot $ScriptRoot -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javlibraryzh) { - $javlibraryData = Get-JavlibraryDataObject -Name $Find -ScriptRoot $ScriptRoot -Zh -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javlibraryja) { - $javlibraryData = Get-JavlibraryDataObject -Name $Find -ScriptRoot $ScriptRoot -Ja -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javbus) { - $javbusData = Get-JavbusDataObject -Name $Find -ErrorAction 'SilentlyContinue' - Write-Output $javlibraryData - } - - if ($javbusja) { - $javbusData = Get-JavbusDataObject -Name $Find -Ja -ErrorAction 'SilentlyContinue' - Write-Output $javbusData - } - - if ($jav321) { - $jav321Data = Get-Jav321DataObject -Name $Find -ErrorAction 'SilentlyContinue' - Write-Output $jav321Data - } - } - } - } - - end { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function ended" - } -} diff --git a/src/Javinizer/Private/Get-Log.ps1 b/src/Javinizer/Private/Get-Log.ps1 deleted file mode 100644 index fcefa2b1..00000000 --- a/src/Javinizer/Private/Get-Log.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -function Get-Log { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Path, - [string]$LogLevel, - [string]$LogView, - [string]$Order, - [int]$Entries - ) - - process { - - $logColorHash = @{ - #'INFO' = 'Green'; - 'ERROR' = 'Red'; - 'WARN' = 'Yellow' - } - - # Replace backslash with double backslash to conform with accepted JSON format - $log = Get-Content -Path $javinizerLogPath | ForEach-Object { $_ -replace '\\', '\\' } | ConvertFrom-Json - - if ($LogView -eq 'Object') { - Write-Output $log - } - - else { - # Set object filter to the desired loglevel - if ($PSBoundParameters.ContainsKey('LogLevel')) { - if ($Order -eq 'Asc') { - $log = $log | Where-Object { $_.level -eq "$LogLevel" } | Select-Object -First $Entries - } else { - $log = $log | Where-Object { $_.level -eq "$LogLevel" } | Sort-Object timestamp -Descending | Select-Object -First $Entries - } - } else { - if ($Order -eq 'Asc') { - $log = $log | Sort-Object timestamp | Select-Object -First $Entries - } else { - $log = $log | Sort-Object timestamp -Descending | Select-Object -First $Entries - } - } - - if ($LogView -eq 'Table') { - $log | Format-Table -AutoSize | Format-Color $logColorHash - } elseif ($LogView -eq 'Grid') { - $log | Out-GridView - } else { - $log | Format-Color $logColorHash - } - } - } -} diff --git a/src/Javinizer/Private/Get-MetadataPriority.ps1 b/src/Javinizer/Private/Get-MetadataPriority.ps1 deleted file mode 100644 index 6b7510eb..00000000 --- a/src/Javinizer/Private/Get-MetadataPriority.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -function Get-MetadataPriority { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true, Position = 0)] - [object]$Settings, - [ValidateSet('id', 'title', 'releasedate', 'releaseyear', 'runtime', 'description', 'director', 'maker', 'label', 'series', 'rating', 'ratingcount', 'actress', 'trailerurl', 'actressthumburl', 'genre', 'coverurl', 'screenshoturl', 'alternatetitle')] - [string]$Type - ) - - process { - $priority = $Settings.Metadata."$Type-priority" - $priorityArray = $priority -split ',' - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Priority type loaded: [$Type]; Priority setting: [$priorityArray]" - Write-Output $priorityArray - } - -} diff --git a/src/Javinizer/Private/Import-IniSettings.ps1 b/src/Javinizer/Private/Import-IniSettings.ps1 deleted file mode 100644 index de05d36a..00000000 --- a/src/Javinizer/Private/Import-IniSettings.ps1 +++ /dev/null @@ -1,94 +0,0 @@ -# This is a borrowed function; Thanks to [GITHUB: beruic] and [STACKOVERFLOW: David Brabant] - -function Import-IniSettings { - <# - .SYNOPSIS - Read an ini file. - - .DESCRIPTION - Reads an ini file into a hash table of sections with keys and values. - - .PARAMETER Path - The path to the INI file. - - .PARAMETER anonymous - The section name to use for the anonymous section (keys that come before any section declaration). - - .PARAMETER comments - Enables saving of comments to a comment section in the resulting hash table. - The comments for each section will be stored in a section that has the same name as the section of its origin, but has the comment suffix appended. - Comments will be keyed with the comment key prefix and a sequence number for the comment. The sequence number is reset for every section. - - .PARAMETER commentsSectionsSuffix - The suffix for comment sections. The default value is an underscore ('_'). - .PARAMETER commentsKeyPrefix - The prefix for comment keys. The default value is 'Comment'. - - .EXAMPLE - Import-IniSettings /path/to/my/inifile.ini - - .NOTES - The resulting hash table has the form [sectionName->sectionContent], where sectionName is a string and sectionContent is a hash table of the form [key->value] where both are strings. - This function is largely copied from https://stackoverflow.com/a/43697842/1031534. An improved version has since been pulished at https://gist.github.com/beruic/1be71ae570646bca40734280ea357e3c. - #> - - param( - [parameter(Mandatory = $true, Position = 0)] - [string] $Path, - [string] $anonymous = 'NoSection', - [switch] $comments, - [string] $commentsSectionsSuffix = '_', - [string] $commentsKeyPrefix = 'Comment' - ) - - process { - try { - $ini = @{ } - switch -regex -file ($Path) { - "^\[(.+)\]$" { - # Section - $section = $matches[1] - $ini[$section] = @{ } - $CommentCount = 0 - if ($comments) { - $commentsSection = $section + $commentsSectionsSuffix - $ini[$commentsSection] = @{ } - } - continue - } - - "^(;.*)$" { - # Comment - if ($comments) { - if (!($section)) { - $section = $anonymous - $ini[$section] = @{ } - } - $value = $matches[1] - $CommentCount = $CommentCount + 1 - $name = $commentsKeyPrefix + $CommentCount - $commentsSection = $section + $commentsSectionsSuffix - $ini[$commentsSection][$name] = $value - } - continue - } - - "^(.+?)\s*=\s*(.*)$" { - # Key - if (!($section)) { - $section = $anonymous - $ini[$section] = @{ } - } - $name, $value = $matches[1..2] - $ini[$section][$name] = $value - continue - } - } - - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Settings file at [$Path] loaded" - Write-Output $ini - } catch { - throw "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Settings file at [$Path)] NOT loaded; Check that the path is correct and that the file exists" - } - } -} diff --git a/src/Javinizer/Private/Test-UrlMatch.ps1 b/src/Javinizer/Private/Test-UrlMatch.ps1 deleted file mode 100644 index 51188068..00000000 --- a/src/Javinizer/Private/Test-UrlMatch.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -function Test-UrlMatch { - param ( - [string]$Url, - [switch]$JavLibrary, - [switch]$R18 - ) - - begin { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function started" - } - - process { - Write-Debug "Url is: [$Url]" - if ($JavLibrary.IsPresent) { - if ($Url -match 'http:\/\/www\.javlibrary\.com\/(.*)\/\?v=(.*)') { - $match = $Url - } - } elseif ($R18.IsPresent) { - $match = $Url - } - - Write-Output $match - } - - end { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function ended" - } -} diff --git a/src/Javinizer/Private/Write-JLog.ps1 b/src/Javinizer/Private/Write-JLog.ps1 deleted file mode 100644 index d94a3aa6..00000000 --- a/src/Javinizer/Private/Write-JLog.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -function Write-JLog { - [CmdletBinding()] - param ( - [Parameter()] - [string]$Message, - - [Parameter()] - [ValidateSet('Debug', 'Info', 'Warning', 'Error')] - [string]$Level - ) - - if ($Level -eq 'Debug') { - Write-Debug -Message $Message - Write-Log -Level $Level -Message $Message | Wait-Logging - } - - if ($Level -eq 'Info') { - Write-Host $Message - Write-Log -Level $Level -Message $Message | Wait-Logging - } - - if ($Level -eq 'Warning') { - Write-Warning -Message $Message - Write-Log -Level $Level -Message $Message | Wait-Logging - } - - if ($Level -eq 'Error') { - Write-Log -Level $Level -Message $Message | Wait-Logging - throw $_ - } -} diff --git a/src/Javinizer/Private/Write-Log.ps1 b/src/Javinizer/Private/Write-Log.ps1 deleted file mode 100644 index 977d2b23..00000000 --- a/src/Javinizer/Private/Write-Log.ps1 +++ /dev/null @@ -1,63 +0,0 @@ -<# Borrowed from http://draith.azurewebsites.net/?p=337 - .SYNOPSIS - Simple function to write to a log file - - .DESCRIPTION - This function will write to a log file, pre-pending the date/time, level of detail, and supplied information - - .PARAMETER text - This is the main text to log - - .PARAMETER Level - INFO,WARN,ERROR,DEBUG - - .PARAMETER Log - Name of the log file to send the data to. - - .PARAMETER UseMutex - A description of the UseMutex parameter. - - .EXAMPLE - write-log -text "This is the main problem." -level ERROR -log c:\test.log - - .NOTES - Created by Donnie Taylor. - Version 1.0 Date 4/5/2016 -#> -function Write-Log { - param - ( - [Parameter(Mandatory = $true, - Position = 0)] - [ValidateNotNull()] - [string]$Text, - [Parameter(Mandatory = $true, - Position = 1)] - [ValidateSet('INFO', 'WARN', 'ERROR', 'DEBUG')] - [string]$Level, - [Parameter(Mandatory = $true, - Position = 2)] - [system.io.fileinfo]$Log, - [string]$OriginalFile, - [string]$DestinationFile - ) - - $timestamp = Get-TimeStamp - # Escape characters to be compatible with JSON - $Text = [Regex]::Replace($Text, "\\u(?[a-zA-Z0-9]{4})", { param($m) ([char]([int]::Parse($m.Groups['Value'].Value, [System.Globalization.NumberStyles]::HexNumber))).ToString() } ) - - $logJSON = [ordered]@{ - 'timestamp' = $timestamp - 'level' = $level - 'message' = $Text - 'originalfile' = $OriginalFile - 'destinationfile' = $DestinationFile - } | ConvertTo-Json -Compress | ForEach-Object { [System.Text.RegularExpressions.Regex]::Unescape($_) } - - # $line = "{`"timestamp`": `"$timestamp`", `"level`": `"$level`", `"originalfile`": `"$OriginalFile`", `"destinationfile`": `"$DestinationFile`", `"message`": `"$Text`"}" - - $LogMutex = New-Object System.Threading.Mutex($false, "LogMutex") - $LogMutex.WaitOne() | Out-Null - $logJSON | Out-File -FilePath $log -Append - $LogMutex.ReleaseMutex() | Out-Null -}