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
77 stars 18 forks source link

[New App Request] Synaptics DisplayLink Graphics (On Proposals list) #81

Open AScott-WWF opened 4 months ago

AScott-WWF commented 4 months ago

Script:

# Get-SynapticsDisplayLinkGraphics.ps1

# Define AppName
$AppName = "Synaptics DisplayLink Graphics"

$ReleaseUrl = "https://www.synaptics.com/products/displaylink-graphics/downloads/windows"
$InstallInstructionsUrl = "https://support.displaylink.com/knowledgebase/articles/615714-how-to-install-displaylink-software"

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

# Main script to fetch and process links
$AppVersions = @(
        @{Type = 'exe'; Pattern = 'filetype=exe'; DownloadPattern = 'Accept'; VersionPattern = 'Release:\s(\d+\.\d+\s\D\d+)\s\|\s'; RNPattern = 'Release Notes'}
)

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

    # Obtain Uri of Download page
    $DLURL = (Resolve-Uri (Set-UriPrefix -Uri (Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $($AppVersion.Pattern)) -Prefix "https://www.synaptics.com")).Uri
    # Obtain Uri of file download
    $URL = Set-UriPrefix -Uri (Get-Link -Uri $DLURL -MatchProperty outerHTML -Pattern $($AppVersion.DownloadPattern)) -Prefix "https://www.synaptics.com"
    $Version = Get-Version -Uri $ReleaseUrl -Pattern $($AppVersion.VersionPattern)

    #Build each link with File Type specific versions
    $ReleaseNotesUrl = Set-UriPrefix -Uri (Get-Link -Uri $ReleaseUrl -MatchProperty OuterHTML -Pattern $($AppVersion.RNPattern)) -Prefix "https://www.synaptics.com"
    Write-Verbose "$($AppName) (Version: $($Version)) Release notes are available here: $($ReleaseNotesUrl)"

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

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

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

Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"