Allow local DVDStyler ZIP install
This commit is contained in:
parent
8f34ee1f92
commit
3a02cfcae1
|
|
@ -5,6 +5,7 @@ param(
|
||||||
[switch]$UseScoop = $false,
|
[switch]$UseScoop = $false,
|
||||||
[switch]$SkipFFmpeg = $false,
|
[switch]$SkipFFmpeg = $false,
|
||||||
[string]$DvdStylerUrl = "",
|
[string]$DvdStylerUrl = "",
|
||||||
|
[string]$DvdStylerZip = "",
|
||||||
[switch]$SkipDvdStyler = $false
|
[switch]$SkipDvdStyler = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -81,65 +82,76 @@ function Ensure-DVDStylerTools {
|
||||||
$userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
$userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
$downloaded = $false
|
$downloaded = $false
|
||||||
$lastUrl = ""
|
$lastUrl = ""
|
||||||
foreach ($url in $dvdstylerUrls) {
|
if ($DvdStylerZip) {
|
||||||
$lastUrl = $url
|
if (Test-Path $DvdStylerZip) {
|
||||||
$downloadOk = $false
|
Copy-Item -Path $DvdStylerZip -Destination $dvdstylerZip -Force
|
||||||
if (Test-Path $dvdstylerZip) {
|
$downloaded = $true
|
||||||
Remove-Item -Force $dvdstylerZip
|
$lastUrl = $DvdStylerZip
|
||||||
|
} else {
|
||||||
|
Write-Host "[ERROR] Provided DVDStyler ZIP not found: $DvdStylerZip" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
try {
|
} else {
|
||||||
Invoke-WebRequest -Uri $url -OutFile $dvdstylerZip -UseBasicParsing -MaximumRedirection 10 -UserAgent $userAgent -Headers @{
|
foreach ($url in $dvdstylerUrls) {
|
||||||
"Referer" = $dvdstylerReferer
|
$lastUrl = $url
|
||||||
"Accept" = "application/zip"
|
|
||||||
}
|
|
||||||
$downloadOk = $true
|
|
||||||
} catch {
|
|
||||||
$downloadOk = $false
|
$downloadOk = $false
|
||||||
}
|
if (Test-Path $dvdstylerZip) {
|
||||||
|
Remove-Item -Force $dvdstylerZip
|
||||||
if (-not $downloadOk) {
|
}
|
||||||
try {
|
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
|
$downloadOk = $true
|
||||||
} catch {
|
} catch {
|
||||||
$downloadOk = $false
|
$downloadOk = $false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $downloadOk -and (Test-Command curl.exe)) {
|
if (-not $downloadOk) {
|
||||||
try {
|
try {
|
||||||
& curl.exe -L --retry 3 --user-agent $userAgent -o $dvdstylerZip $url | Out-Null
|
Start-BitsTransfer -Source $url -Destination $dvdstylerZip -ErrorAction Stop
|
||||||
if ($LASTEXITCODE -eq 0) {
|
|
||||||
$downloadOk = $true
|
$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 {
|
} 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) {
|
if (-not $downloaded) {
|
||||||
Write-Host "[ERROR] Failed to download DVDStyler ZIP (invalid archive)" -ForegroundColor Red
|
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
|
# Args
|
||||||
DVDSTYLER_URL=""
|
DVDSTYLER_URL=""
|
||||||
|
DVDSTYLER_ZIP=""
|
||||||
SKIP_DVD_TOOLS=""
|
SKIP_DVD_TOOLS=""
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
@ -41,13 +42,21 @@ while [ $# -gt 0 ]; do
|
||||||
DVDSTYLER_URL="$2"
|
DVDSTYLER_URL="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--dvdstyler-zip=*)
|
||||||
|
DVDSTYLER_ZIP="${1#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--dvdstyler-zip)
|
||||||
|
DVDSTYLER_ZIP="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--skip-dvd)
|
--skip-dvd)
|
||||||
SKIP_DVD_TOOLS=true
|
SKIP_DVD_TOOLS=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option: $1"
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -115,7 +124,9 @@ if [ "$IS_WINDOWS" = true ]; then
|
||||||
if [ "$SKIP_DVD_TOOLS" = true ]; then
|
if [ "$SKIP_DVD_TOOLS" = true ]; then
|
||||||
PS_ARGS+=("-SkipDvdStyler")
|
PS_ARGS+=("-SkipDvdStyler")
|
||||||
fi
|
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[@]}"
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" -DvdStylerUrl "$DVDSTYLER_URL" "${PS_ARGS[@]}"
|
||||||
else
|
else
|
||||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" "${PS_ARGS[@]}"
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$PROJECT_ROOT/scripts/install-deps-windows.ps1" "${PS_ARGS[@]}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user