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] Office Timeline (On Proposals list) #92

Open AScott-WWF opened 4 months ago

AScott-WWF commented 4 months ago

Script:

# Get-OfficeTimeline.ps1

# Define AppName
$AppName = "Office Timeline"

$ReleaseUrl = "https://www.officetimeline.com/office-timeline/updates"
$InstallInstructionsUrl = "https://support.officetimeline.com/hc/en-us/articles/115011042327-How-to-install-Office-Timeline"

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

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = $($AppName); Type = 'exe'; Pattern = '\.exe'; VersionPattern = 'Version: <!-- -->(\d+\.\d+\.\d+)'}
    @{AppName = $($AppName); Type = 'zip'; Pattern = '\.zip'; VersionPattern = 'Version: <!-- -->(\d+\.\d+\.\d+)'}
)

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

    #Build each link with File Type specific versions
    if ($AppVersion.Type -eq 'exe') {
        $URL = Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $AppVersion.Pattern
        $EXEUrl = $URL # Required for manipulation to create zip URL
        Write-Verbose "URL :: $($URL)"    
    } else {
        # URL for Zip is published on System requirements page: https://support.officetimeline.com/hc/en-us/articles/201950763-System-requirements-for-Office-Timeline-Add-in,
        # This is the same path at .exe, with a slightly different name, for this to work, it requires the Url for the exe to be determined first
        $URL = "$($EXEUrl -replace '.exe','PreExtracted.zip')"
    }

    [version]$Version = Get-Version -Uri $ReleaseUrl -Pattern $($AppVersion.VersionPattern)

    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Version $($Version) -Uri $($URL) -Architecture 'x64' -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.officetimeline.com/office-timeline/updates"
Write-Verbose "$($AppName) Release notes are available here: $($ReleaseNotesUrl)"
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"