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
72 stars 16 forks source link

Add FileZilla Client support #51

Closed JonathanPitre closed 10 months ago

JonathanPitre commented 1 year ago

I will submit a PR soon for this.

Deyda commented 1 year ago

perfect.i have other features on the agenda right now.

DanGough commented 1 year ago

This is already in Evergreen though and working?

I note you get a 403 trying to download the resulting URL via Invoke-WebRequest, but this is resolved by setting the user agent to Chrome when trying to download it:

-UserAgent ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36’

Deyda commented 1 year ago

Nice thx bro...i will try this directly

DanGough commented 1 year ago

I never did implement a download function into Nevergreen like Evergreen has, since having a decent download function that works for 100% of URLs is useful enough to be split off into its own module.

I have some code that uses multiple user agent strings plus different methods of inspecting headers to work out the modified date and filename. But it doesn’t handle 100% of URLs I can throw at it right now. Once it can, I will turn it into a module!

JonathanPitre commented 1 year ago
$userAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome

$Apps = @(
    @{Name = 'FileZilla'; Architecture = 'x64'; Type = 'Exe'; Pattern = 'FileZilla_(?:\d+\.)+(?:\d+)_win64\-setup\.exe' }
    @{Name = 'FileZilla'; Architecture = 'x64'; Type = 'Zip'; Pattern = 'FileZilla_(?:\d+\.)+(?:\d+)_win64\.zip' }
    @{Name = 'FileZilla'; Architecture = 'x86'; Type = 'Exe'; Pattern = 'FileZilla_(?:\d+\.)+(?:\d+)_win32\-setup\.exe' }
    @{Name = 'FileZilla'; Architecture = 'x86'; Type = 'Zip'; Pattern = 'FileZilla_(?:\d+\.)+(?:\d+)_win32\.zip' }
)

foreach ($App in $Apps)
{
    try
    {
        $URL = Get-Link -Uri 'https://filezilla-project.org/download.php?show_all=1' -MatchProperty href -Pattern $App.Pattern -UserAgent $userAgent

        $Version = Get-Version -String $URL

        if ($URL -and $Version)
        {
            New-NevergreenApp -Name $App.Name -Version $Version -Uri $URL -Architecture $App.Architecture -Type $App.Type
        }
        else
        {
            Write-Warning -Message "Unable to retrieve details for $($App.Name)"
        }
    }
    catch
    {
        Write-Error "$($MyInvocation.MyCommand): $($_.Exception.Message)"
    }
}
DanGough commented 10 months ago

Closing this, as I'm perfectly happy using the Evergreen URLs as they work with my own download routine, which I will soon be releasing as a separate module.