DanGough / Nevergreen

This module is an alternative to Evergreen, and allows you to find the latest version and download URL for various Windows apps. Evergreen uses API queries to obtain its data whereas this module is more focussed on web scraping. This is more prone to breaking when websites are changed, hence the name.
The Unlicense
71 stars 16 forks source link

[New App Request] Allround Automations PL/SQL Developer (On Proposals list) #91

Open AScott-WWF opened 2 days ago

AScott-WWF commented 2 days ago

N.B. This is a paid product, so this will download the 'free-trial' which I believe becomes a full product with a valid licence key.

Script:

# Get-AllroundAutomationsPLSQLDeveloper.ps1

# Define AppName
$AppName = "Allround Automations PL/SQL Developer"

$ReleaseUrl = "https://www.allroundautomations.com/products/pl-sql-developer/free-trial/"

Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n"

# Fetch the HTML content from the specified URL
$htmlContent = (Invoke-WebRequest -Uri $ReleaseUrl -UseBasicParsing).Content

# Define the RegEx pattern to match the URLs within the option value attributes
$regexPattern = '<option value="(https://www\.allroundautomations\.com/files/trial/[^"]+\.msi)">'

# Find all matches in the HTML content
$releases = [regex]::Matches($htmlContent, $regexPattern)

# Extract the URLs and match them to the appropriate architecture
$x64url = $releases | ForEach-Object { $_.Groups[1].Value } | Where-Object { $_ -match 'x64' }
$x86url = $releases | ForEach-Object { $_.Groups[1].Value } | Where-Object { $_ -match 'x32' }

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = "$($AppName) Trial"; Architecture = 'x64'; Type = 'msi'; Pattern = $($x64url); VersionPattern = '>Version (\d+\.\d+\.\d+)</span>'}
    @{AppName = "$($AppName) Trial"; Architecture = 'x86'; Type = 'msi'; Pattern = $($x86url); VersionPattern = '>Version (\d+\.\d+\.\d+)</span>'}
)

foreach ($AppVersion in $AppVersions) {
    $SearchCount = 1 # This may need increasing as future versions are released

    #Build each link with File Type specific versions
    $URL = $($AppVersion.Pattern)
    [version]$Version = Get-Version -Uri $ReleaseUrl -Pattern $AppVersion.VersionPattern

    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Version $($Version) -Uri $($URL) -Architecture $($AppVersion.Architecture) -Type $($AppVersion.Type)
            break
        }

        $SearchCount--
    } until ($SearchCount -eq 0)

    if ($SearchCount -eq 0) {
        Write-Warning "Could not find release for $($AppName) $($AppVersion.Type)"
    }
}

$ReleaseNotesUrl = "https://www.allroundautomations.com/products/pl-sql-developer/release-notes/"
Write-Verbose "$($AppName) Release notes are available here: $($ReleaseNotesUrl)"