Allow local DVDStyler ZIP install
This commit is contained in:
parent
1ef88069bc
commit
4ea3834d76
|
|
@ -5,6 +5,7 @@ param(
|
|||
[switch]$UseScoop = $false,
|
||||
[switch]$SkipFFmpeg = $false,
|
||||
[string]$DvdStylerUrl = "",
|
||||
[string]$DvdStylerZip = "",
|
||||
[switch]$SkipDvdStyler = $false
|
||||
)
|
||||
|
||||
|
|
@ -81,65 +82,76 @@ function Ensure-DVDStylerTools {
|
|||
$userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||
$downloaded = $false
|
||||
$lastUrl = ""
|
||||
foreach ($url in $dvdstylerUrls) {
|
||||
$lastUrl = $url
|
||||
$downloadOk = $false
|
||||
if (Test-Path $dvdstylerZip) {
|
||||
Remove-Item -Force $dvdstylerZip
|
||||
if ($DvdStylerZip) {
|
||||
if (Test-Path $DvdStylerZip) {
|
||||
Copy-Item -Path $DvdStylerZip -Destination $dvdstylerZip -Force
|
||||
$downloaded = $true
|
||||
$lastUrl = $DvdStylerZip
|
||||
} else {
|
||||
Write-Host "[ERROR] Provided DVDStyler ZIP not found: $DvdStylerZip" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $dvdstylerZip -UseBasicParsing -MaximumRedirection 10 -UserAgent $userAgent -Headers @{
|
||||
"Referer" = $dvdstylerReferer
|
||||
"Accept" = "application/zip"
|
||||
}
|
||||
$downloadOk = $true
|
||||
} catch {
|
||||
} else {
|
||||
foreach ($url in $dvdstylerUrls) {
|
||||
$lastUrl = $url
|
||||
$downloadOk = $false
|
||||
}
|
||||
|
||||
if (-not $downloadOk) {
|
||||
if (Test-Path $dvdstylerZip) {
|
||||
Remove-Item -Force $dvdstylerZip
|
||||
}
|
||||
try {
|
||||
Start-BitsTransfer -Source $url -Destination $dvdstylerZip -ErrorAction Stop
|
||||
Invoke-WebRequest -Uri $url -OutFile $dvdstylerZip -UseBasicParsing -MaximumRedirection 10 -UserAgent $userAgent -Headers @{
|
||||
"Referer" = $dvdstylerReferer
|
||||
"Accept" = "application/zip"
|
||||
}
|
||||
$downloadOk = $true
|
||||
} catch {
|
||||
$downloadOk = $false
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $downloadOk -and (Test-Command curl.exe)) {
|
||||
try {
|
||||
& curl.exe -L --retry 3 --user-agent $userAgent -o $dvdstylerZip $url | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
if (-not $downloadOk) {
|
||||
try {
|
||||
Start-BitsTransfer -Source $url -Destination $dvdstylerZip -ErrorAction Stop
|
||||
$downloadOk = $true
|
||||
} catch {
|
||||
$downloadOk = $false
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $downloadOk -and (Test-Command curl.exe)) {
|
||||
try {
|
||||
& curl.exe -L --retry 3 --user-agent $userAgent -o $dvdstylerZip $url | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$downloadOk = $true
|
||||
}
|
||||
} catch {
|
||||
$downloadOk = $false
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $downloadOk -or -not (Test-Path $dvdstylerZip)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
$fs = [System.IO.File]::OpenRead($dvdstylerZip)
|
||||
try {
|
||||
$fileSize = (Get-Item $dvdstylerZip).Length
|
||||
if ($fileSize -lt 102400) {
|
||||
continue
|
||||
}
|
||||
$sig = New-Object byte[] 2
|
||||
$null = $fs.Read($sig, 0, 2)
|
||||
if ($sig[0] -eq 0x50 -and $sig[1] -eq 0x4B) {
|
||||
$downloaded = $true
|
||||
break
|
||||
}
|
||||
} finally {
|
||||
$fs.Close()
|
||||
}
|
||||
} catch {
|
||||
$downloadOk = $false
|
||||
# Try next URL
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $downloadOk -or -not (Test-Path $dvdstylerZip)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
$fs = [System.IO.File]::OpenRead($dvdstylerZip)
|
||||
try {
|
||||
$fileSize = (Get-Item $dvdstylerZip).Length
|
||||
if ($fileSize -lt 102400) {
|
||||
continue
|
||||
}
|
||||
$sig = New-Object byte[] 2
|
||||
$null = $fs.Read($sig, 0, 2)
|
||||
if ($sig[0] -eq 0x50 -and $sig[1] -eq 0x4B) {
|
||||
$downloaded = $true
|
||||
break
|
||||
}
|
||||
} finally {
|
||||
$fs.Close()
|
||||
}
|
||||
} catch {
|
||||
# Try next URL
|
||||
}
|
||||
}
|
||||
if (-not $downloaded) {
|
||||
Write-Host "[ERROR] Failed to download DVDStyler ZIP (invalid archive)" -ForegroundColor Red
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|||
|
||||
# Args
|
||||
DVDSTYLER_URL=""
|
||||
DVDSTYLER_ZIP=""
|
||||
SKIP_DVD_TOOLS=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
|
|
@ -41,13 +42,21 @@ while [ $# -gt 0 ]; do
|
|||
DVDSTYLER_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dvdstyler-zip=*)
|
||||
DVDSTYLER_ZIP="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--dvdstyler-zip)
|
||||
DVDSTYLER_ZIP="$2"
|
||||
shift 2
|
||||
;;
|
||||
--skip-dvd)
|
||||
SKIP_DVD_TOOLS=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--dvdstyler-url URL] [--skip-dvd]"
|
||||
echo "Usage: $0 [--dvdstyler-url URL] [--dvdstyler-zip PATH] [--skip-dvd]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -115,7 +124,9 @@ if [ "$IS_WINDOWS" = true ]; then
|
|||
if [ "$SKIP_DVD_TOOLS" = true ]; then
|
||||
PS_ARGS+=("-SkipDvdStyler")
|
||||
fi
|
||||
if [ -n "$DVDSTYLER_URL" ]; then
|
||||
if [ -n "$DVDSTYLER_ZIP" ]; then
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" -DvdStylerZip "$DVDSTYLER_ZIP" "${PS_ARGS[@]}"
|
||||
elif [ -n "$DVDSTYLER_URL" ]; then
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" -DvdStylerUrl "$DVDSTYLER_URL" "${PS_ARGS[@]}"
|
||||
else
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" "${PS_ARGS[@]}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user