From f09c49e9d7df97943be67e5b63133e850758e70e Mon Sep 17 00:00:00 2001 From: Klaus Dandl <76051010+Utesgui@users.noreply.github.com> Date: Fri, 17 May 2024 12:27:36 +0000 Subject: [PATCH] chore: Refactor Update-OpenMedia.4KVideoDownloader.ps1 script --- Scripts/Packages/Update-OpenMedia.4KVideoDownloader.ps1 | 9 +++++++-- Scripts/common.ps1 | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Scripts/Packages/Update-OpenMedia.4KVideoDownloader.ps1 b/Scripts/Packages/Update-OpenMedia.4KVideoDownloader.ps1 index 8f2c13e..783aa48 100644 --- a/Scripts/Packages/Update-OpenMedia.4KVideoDownloader.ps1 +++ b/Scripts/Packages/Update-OpenMedia.4KVideoDownloader.ps1 @@ -1,7 +1,12 @@ . .\Scripts\common.ps1 -$versionPattern = "videodownloader_(\d+\.\d+\.\d+\.\d+)_windows_(x86|x64)" -$URLFilter = "videodownloader_windows_(x32|x64)_installer" +$versionParts = $wingetPackage.Split('.') +$PackageName = $versionParts[1] + +$ProductName = ($PackageName -replace '4K', '').Trim().ToLower() + +$versionPattern = "$($ProductName)_(\d+\.\d+\.\d+\.\d+)_windows_(x86|x64)" +$URLFilter = "$($ProductName)_windows_(x32|x64)_installer" # Download the webpage $website = Invoke-WebRequest -Uri $WebsiteURL diff --git a/Scripts/common.ps1 b/Scripts/common.ps1 index 2363944..9da2845 100644 --- a/Scripts/common.ps1 +++ b/Scripts/common.ps1 @@ -219,7 +219,7 @@ function Update-WingetPackage { [Parameter(Mandatory = $false)] [string] $WingetPackage = ${Env:PackageName}, [Parameter(Mandatory = $false)][ValidateSet("Komac", "WinGetCreate")] [string] $With = "Komac", [Parameter(Mandatory = $false)] [string] $resolves = (${Env:resolves} -match '^\d+$' ? ${Env:resolves} : ""), - [Parameter(Mandatory = $false)] [switch] $Submit = $false, + [Parameter(Mandatory = $false)] [bool] $Submit = $false, [Parameter(Mandatory = $false)] [string] $latestVersion, [Parameter(Mandatory = $false)] [string] $latestVersionURL )