Closed JonathanPitre closed 10 months ago
perfect.i have other features on the agenda right now.
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’
Nice thx bro...i will try this directly
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!
$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)"
}
}
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.
I will submit a PR soon for this.