Skip to content

Commit

Permalink
Add release notes URL fallback to canonical URL
Browse files Browse the repository at this point in the history
  • Loading branch information
brogers5 committed Jul 12, 2023
1 parent 9635289 commit 0804884
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions update.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 0804884

Please # to comment.