From 08048848ce18ddcf5a629b7882ee755eb23a788b Mon Sep 17 00:00:00 2001 From: brogers5 <6869577+brogers5@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:06:30 -0400 Subject: [PATCH] Add release notes URL fallback to canonical URL --- update.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/update.ps1 b/update.ps1 index 64493b0..c1f8112 100644 --- a/update.ps1 +++ b/update.ps1 @@ -1,8 +1,16 @@ Import-Module au +$userAgent = "Update checker of Chocolatey Community Package 'xsplit-vcam'" + function global:au_BeforeUpdate ($Package) { if ([string]::IsNullOrWhiteSpace($Latest.ReleaseNotes)) { - Write-Warning 'release_notes_url is not available - consider requerying the API later!' + Write-Warning 'release_notes_url is not available - falling back on redirect from canonical URL' + + $canonicalUri = 'https://xspl.it/vcam/relnotes' + $response = Invoke-WebRequest -Uri $canonicalUri -UserAgent $userAgent -MaximumRedirection 0 -SkipHttpErrorCheck -UseBasicParsing -ErrorAction SilentlyContinue + $redirectedUri = $response.Headers['Location'] + + $Latest.ReleaseNotes = $redirectedUri } #Archive this version for future development, since the vendor does not guarantee perpetual availability @@ -32,7 +40,6 @@ function global:au_SearchReplace { function global:au_GetLatest { # Use MSI package, as the copy packaged in EXE package differs slightly and supports less installer properties $uri = 'https://www.xsplit.com/api/service/download?page_size=10&application_id=3&active=1&release=0&platform=windows&installer_type=msi' - $userAgent = "Update checker of Chocolatey Community Package 'xsplit-vcam'" $response = Invoke-RestMethod -Uri $uri -UserAgent $userAgent -UseBasicParsing $releaseData = $response.data[0]