Skip to content

Commit

Permalink
refactoring a bit at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
bullmoose20 committed Mar 21, 2024
1 parent 27def16 commit c8e60e6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
69 changes: 40 additions & 29 deletions PlexPosterMaker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@ param (
[switch]$Testing
)

$CurrentScriptVersion = "1.0.21"
$CurrentScriptVersion = "1.0.22"
$global:HeaderWritten = $false

$global:OSType = [System.Environment]::OSVersion.Platform
if ($env:POWERSHELL_DISTRIBUTION_CHANNEL -like 'PSDocker-Alpine*') {
$global:OSType = "DockerAlpine"
$ProgressPreference = 'SilentlyContinue'
$global:ScriptRoot = "./config"
}
Else {
$global:ScriptRoot = $PSScriptRoot
}
#################
# What you need #
#####################################################################################################################
Expand All @@ -24,6 +15,17 @@ Else {
# ImageMagick -> https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-27-Q16-HDRI-x64-dll.exe
# FanartTvAPI Module -> https://github.com/Celerium/FanartTV-PowerShellWrapper
#####################################################################################################################
function Set-OSTypeAndScriptRoot {
if ($env:POWERSHELL_DISTRIBUTION_CHANNEL -like 'PSDocker-Alpine*') {
$global:OSType = "DockerAlpine"
$ProgressPreference = 'SilentlyContinue'
$global:ScriptRoot = "./config"
}
Else {
$global:ScriptRoot = $PSScriptRoot
$global:OSType = [System.Environment]::OSVersion.Platform
}
}
function Write-Log {
[CmdletBinding()]
param(
Expand Down Expand Up @@ -1523,28 +1525,37 @@ function CheckJsonPaths {
}
}

# Get platform
if ($global:OSType -eq 'DockerAlpine') {
$Platform = 'Docker'
}
elseif ($global:OSType -eq 'Unix' -and $env:POWERSHELL_DISTRIBUTION_CHANNEL -notlike 'PSDocker-Alpine*') {
$Platform = 'Linux'
}
elseif ($global:OSType -eq 'Win32NT') {
$Platform = 'Windows'
}
Else {
$Platform = 'Unknown'
function Get-Platform {
if ($global:OSType -eq 'DockerAlpine') {
return 'Docker'
}
elseif ($global:OSType -eq 'Unix' -and $env:POWERSHELL_DISTRIBUTION_CHANNEL -notlike 'PSDocker-Alpine*') {
return 'Linux'
}
elseif ($global:OSType -eq 'Win32NT') {
return 'Windows'
}
else {
return 'Unknown'
}
}

# Get Latest Script Version
try {
$LatestScriptVersion = Invoke-RestMethod -Uri "https://github.com/fscorrupt/Plex-Poster-Maker/raw/main/Release.txt" -Method Get -ErrorAction Stop
}
catch {
Write-Log -Subtext "Could not query latest script version, Error: $_" -Path $global:ScriptRoot\Logs\Scriptlog.log -Type Error
function Get-LatestScriptVersion {
try {
return Invoke-RestMethod -Uri "https://github.com/fscorrupt/Plex-Poster-Maker/raw/main/Release.txt" -Method Get -ErrorAction Stop
}
catch {
Write-Log -Subtext "Could not query latest script version, Error: $_" -Path $global:ScriptRoot\Logs\Scriptlog.log -Type Error
return $null
}
}

##### START #####
# Set some global vars
Set-OSTypeAndScriptRoot
# Get platform
$Platform = Get-Platform
# Get Latest Script Version
$LatestScriptVersion = Get-LatestScriptVersion

$startTime = Get-Date
# Rotate logs before doing anything!
Expand Down
2 changes: 1 addition & 1 deletion Release.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.21
1.0.22

0 comments on commit c8e60e6

Please sign in to comment.