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] Scientific Word (On Proposals list) #93

Open AScott-WWF opened 2 days ago

AScott-WWF commented 2 days ago

N.B. Scientific Word (from https://www.sciword.co.uk) appears to be a paid product version of the now open source original code found here: https://github.com/ScientificWord/sciword However, the zip file linked on the GitHub repo above to: https://www.mackichan.com/techtalk/v60/SciWord.zip does not respond.

TBH, I feel slightly concerned if NeverGreen should host this (Unsure if my choice of $ReleaseURL is the correct URL?)

Anyhow here's my Script:

# Get-ScientificWord.ps1

# Define AppName
$AppName = "Scientific Word"

$ReleaseUrl = "https://www.sciword.co.uk/download.htm#step1"
$InstallInstructionsUrl = "https://www.sciword.co.uk/pdfs/v6.0Installation.pdf"

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

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = $($AppName); Ring = '6'; Type = 'exe'; Pattern = 'sw-\d+\.\d+\.\d+-windows-installer\.exe'}
    @{AppName = "$($AppName) Workplace"; Ring = '6'; Type = 'exe'; Pattern = 'swp-\d+\.\d+\.\d+-windows-installer\.exe'}
    @{AppName = "$($AppName) Notebook"; Ring = '6'; Type = 'exe'; Pattern = 'snb-\d+\.\d+\.\d+-windows-installer\.exe'}
    @{AppName = $($AppName); Ring = '5'; Type = 'exe'; Pattern = 'sciword\d+\.exe'; VersionPattern = 'Scientific Word (\d\.\d) \('}
    @{AppName = "$($AppName) Workplace"; Ring = '5'; Type = 'exe'; Pattern = 'swp-pro\d+\.exe'; VersionPattern = 'Scientific Workplace (\d\.\d) \('}
    @{AppName = "$($AppName) Notebook"; Ring = '5'; Type = 'exe'; Pattern = 'scinoteb\d+\.exe'; VersionPattern = 'Scientific Notebook (\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
    $URL = Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $AppVersion.Pattern
    if ($AppVersion.Ring -eq '6') {
        [version]$Version = Get-Version -String $URL
    } else {
        [version]$Version = Get-Version -Uri $ReleaseUrl -Pattern $AppVersion.VersionPattern
    }

    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Version $($Version) -Ring $($AppVersion.Ring) -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)"
    }
}

$ReleaseNotesUrl = "https://www.sciword.co.uk/v6-0.htm"
Write-Verbose "$($AppName) Release notes are available here: $($ReleaseNotesUrl)"
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"