Skip to content

Commit

Permalink
Fix DownloadFFmpeg script
Browse files Browse the repository at this point in the history
- Add UseBasicParsing flag to avoid IE dependency
- Add support for Win32
  • Loading branch information
Rafiuth committed Nov 1, 2021
1 parent 235f957 commit ee16f6f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions SpotifyOggDumper/Data/DownloadFFmpeg.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
if (![Environment]::Is64BitOperatingSystem) {
Write-Host "This script only supports 64-bit OS."
pause
return
if ([Environment]::Is64BitOperatingSystem) {
$repoUrl = "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest"
$platform = "win64"
} else {
$repoUrl = "https://api.github.com/repos/sudo-nautilus/FFmpeg-Builds-Win32/releases/latest"
$platform = "win32"
}

$release = Invoke-WebRequest "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest" | ConvertFrom-Json
$release = Invoke-WebRequest $repoUrl -UseBasicParsing | ConvertFrom-Json

foreach ($asset in $release.assets) {
if ($asset.name -cmatch 'ffmpeg-n.+win64-gpl-shared') {
if ($asset.name -cmatch "ffmpeg-n.+$platform-gpl-shared") {
Write-Host "Downloading $($asset.name)..."

# Invoke-WebRequest is too slow, had to use WebClient manually.
# https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download
# Invoke-WebRequest is too slow - https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download
(New-Object Net.WebClient).DownloadFile($asset.browser_download_url, $asset.name)

# Remove previous installation
Remove-Item -Path "./ffmpeg/" -Recurse -Force
if (Test-Path "./ffmpeg/") {
Remove-Item -Path "./ffmpeg/" -Recurse -Force
}
New-Item -ItemType Directory -Path "./ffmpeg/" -Force

# Extract bin/ folder to ffmpeg/
Expand All @@ -35,5 +37,5 @@ foreach ($asset in $release.assets) {
}
}

Write-Host "Could not find any matching ffmpeg builds from BtbN"
Write-Host "Could not find any matching ffmpeg builds, please open an issue or check https://ffmpeg.org/download.html"
pause

0 comments on commit ee16f6f

Please sign in to comment.