Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New App Request] PDFsam (On Proposals list) #90

Open
AScott-WWF opened this issue Jul 2, 2024 · 0 comments
Open

[New App Request] PDFsam (On Proposals list) #90

AScott-WWF opened this issue Jul 2, 2024 · 0 comments

Comments

@AScott-WWF
Copy link

This will return results for PDFsam Basic, Enhanced or Visual in exe, msi or zip format
N.B. exe files do not resolve to a filename per se, but download from presented url will succeed provided an output filename is supplied, e.g:

(get-nevergreenApp -Name PDFsam | Where-Object {($_.Type -eq 'exe') -and ($_.Version -eq '7.0')}).Uri
https://downloadenhanced7.pdfsam.org/download.ashx?productcode=pdfsam$params=configld=4bf2c0be-8a73-4735-8bf6-b68bfe282ff6&uid=1007261&cmp=pdfsam_enhanced&ref=pdfsam.org/in-app&wid=6848

iwr ((get-nevergreenApp -Name PDFsam | Where-Object {($_.Type -eq 'exe') -and ($_.Version -eq '7.0')}).Uri) -OutFile .\Downloads\PDFsamenhanced7.exe

Script:

# Get-PDFsam.ps1

# Define AppName
$AppName = "PDFsam"

$ReleaseUrl = "https://pdfsam.org/downloads/"

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

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = "$($AppName) Basic"; Architecture = 'multi'; Type = 'exe'; Url = 'https://pdfsam.org/download-pdfsam-basic/'; Pattern = 'Windows downloader'; VersionPattern = 'Download PDFsam Basic v(\d+\.\d+\.\d+)'}
    @{AppName = "$($AppName) Basic"; Architecture = 'multi'; Type = 'msi'; Url = 'https://pdfsam.org/download-pdfsam-basic/'; Pattern = '\.msi'; VersionPattern = 'Download.PDFsam.Basic.v(\d+\.\d+\.\d+)'}
    @{AppName = "$($AppName) Basic"; Architecture = 'multi'; Type = 'zip'; Url = 'https://pdfsam.org/download-pdfsam-basic/'; Pattern = 'windows\.zip'; VersionPattern = 'Download.PDFsam.Basic.v(\d+\.\d+\.\d+)'}
    @{AppName = "$($AppName) Enhanced"; Architecture = 'multi'; Type = 'exe'; Url = 'https://pdfsam.org/download-pdfsam-enhanced/'; Pattern = 'Download PDFsam Enhanced'; VersionPattern = '>(\d+\.\d+)</div>'}
    @{AppName = "$($AppName) Visual"; Architecture = 'x64'; Type = 'msi'; Url = 'https://pdfsam.org/download-pdfsam-visual/'; Pattern = '_x64\.msi'; VersionPattern = '<h3> Download PDFsam Visual v(\d+\.\d+\.\d+)</h3>'}
    @{AppName = "$($AppName) Visual"; Architecture = 'x64'; Type = 'zip'; Url = 'https://pdfsam.org/download-pdfsam-visual/'; Pattern = '_x64\.zip'; VersionPattern = '<h3> Download PDFsam Visual v(\d+\.\d+\.\d+)</h3>'}
    @{AppName = "$($AppName) Visual"; Architecture = 'x86'; Type = 'msi'; Url = 'https://pdfsam.org/download-pdfsam-visual/'; Pattern = '_ia32\.msi'; VersionPattern = '<h3> Download PDFsam Visual v(\d+\.\d+\.\d+)</h3>'}
    @{AppName = "$($AppName) Visual"; Architecture = 'x86'; Type = 'zip'; Url = 'https://pdfsam.org/download-pdfsam-visual/'; Pattern = '_ia32\.zip'; VersionPattern = '<h3> Download PDFsam Visual v(\d+\.\d+\.\d+)</h3>'}
)

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 -ne 'exe')) {
        $URL = Get-Link -Uri $($AppVersion.Url) -MatchProperty href -Pattern $AppVersion.Pattern
        [version]$Version = Get-Version -String $URL
    } else {
        $URL = (Resolve-Uri -Uri (Get-Link -Uri $($AppVersion.Url) -MatchProperty OuterHTML -Pattern $AppVersion.Pattern)).Uri
        [version]$Version = Get-Version -Uri $($AppVersion.Url) -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)"
    }
}

$InstallInstructionsUrl = "https://pdfsam.org/silent-install/"
$ReleaseNotesUrl = "https://github.com/torakiki/pdfsam/releases"
Write-Verbose "$($AppName) Release notes are available here: $($ReleaseNotesUrl)"
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant