Greatly improve the download experience
This commit is contained in:
parent
6f7fae6a76
commit
9fe54f6a5f
103
get.php
103
get.php
@ -1,18 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
// Copyright (C) 2023 UUP dump authors. All rights reserved.
|
||||||
Copyright 2019 whatever127
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
/*
|
||||||
you may not use this file except in compliance with the License.
|
* Changing anything in this file is a really painful experience.
|
||||||
You may obtain a copy of the License at
|
* Please don't do this to yourself.
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Create aria2 download package with conversion script
|
//Create aria2 download package with conversion script
|
||||||
@ -39,9 +30,10 @@ function createUupConvertPackage(
|
|||||||
$downloadapp = <<<TEXT
|
$downloadapp = <<<TEXT
|
||||||
|
|
||||||
:DOWNLOAD_APPS
|
:DOWNLOAD_APPS
|
||||||
echo Retrieving aria2 script for Apps...
|
echo Retrieving aria2 script for Microsoft Store Apps...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
||||||
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
||||||
|
echo.
|
||||||
|
|
||||||
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
||||||
if NOT [%DETECTED_ERROR%] == [] (
|
if NOT [%DETECTED_ERROR%] == [] (
|
||||||
@ -52,16 +44,17 @@ if NOT [%DETECTED_ERROR%] == [] (
|
|||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Attempting to download Apps files...
|
echo Downloading Microsoft Store Apps...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||||
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_APPS
|
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_APPS
|
||||||
|
echo.
|
||||||
|
|
||||||
TEXT;
|
TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmdScript = <<<SCRIPT
|
$cmdScript = <<<SCRIPT
|
||||||
@echo off
|
@echo off
|
||||||
rem Generated on $time
|
:: Generated on $time
|
||||||
|
|
||||||
:: Proxy configuration
|
:: Proxy configuration
|
||||||
:: If you need to configure a proxy to be able to connect to the internet,
|
:: If you need to configure a proxy to be able to connect to the internet,
|
||||||
@ -114,13 +107,20 @@ SETLOCAL DISABLEDELAYEDEXPANSION
|
|||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
:START_PROCESS
|
:START_PROCESS
|
||||||
|
title {$archiveName} download
|
||||||
|
|
||||||
set "aria2=files\\aria2c.exe"
|
set "aria2=files\\aria2c.exe"
|
||||||
set "a7z=files\\7zr.exe"
|
set "a7z=files\\7zr.exe"
|
||||||
set "uupConv=files\\uup-converter-wimlib.7z"
|
set "uupConv=files\\uup-converter-wimlib.7z"
|
||||||
set "aria2Script=files\\aria2_script.%random%.txt"
|
set "aria2Script=files\\aria2_script.%random%.txt"
|
||||||
set "destDir=UUPs"
|
set "destDir=UUPs"
|
||||||
|
|
||||||
powershell -NoProfile -ExecutionPolicy Unrestricted .\\files\\depends_win.ps1 || (pause & exit /b 1)
|
powershell -NoProfile -ExecutionPolicy Unrestricted .\\files\\get_aria2.ps1 || (pause & exit /b 1)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo Downloading the UUP converter...
|
||||||
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j2 -c -R -d"files" -i"files\\converter_windows"
|
||||||
|
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_CONVERTER_ERROR & exit /b 1
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
if NOT EXIST ConvertConfig.ini goto :NO_FILE_ERROR
|
if NOT EXIST ConvertConfig.ini goto :NO_FILE_ERROR
|
||||||
@ -132,8 +132,8 @@ echo Extracting UUP converter...
|
|||||||
echo.
|
echo.
|
||||||
$downloadapp
|
$downloadapp
|
||||||
:DOWNLOAD_UUPS
|
:DOWNLOAD_UUPS
|
||||||
echo Retrieving aria2 script...
|
echo Retrieving aria2 script for the UUP set...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||||
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ if NOT [%DETECTED_ERROR%] == [] (
|
|||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Attempting to download files...
|
echo Downloading the UUP set...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"%destDir%" -i"%aria2Script%"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||||
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS & exit /b 1
|
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS & exit /b 1
|
||||||
|
|
||||||
if EXIST convert-UUP.cmd goto :START_CONVERT
|
if EXIST convert-UUP.cmd goto :START_CONVERT
|
||||||
@ -163,6 +163,12 @@ echo We couldn't find one of needed files for this script.
|
|||||||
pause
|
pause
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
:DOWNLOAD_CONVERTER_ERROR
|
||||||
|
echo.
|
||||||
|
echo An error has occurred while downloading the UUP converter.
|
||||||
|
pause
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
:DOWNLOAD_ERROR
|
:DOWNLOAD_ERROR
|
||||||
echo.
|
echo.
|
||||||
echo We have encountered an error while downloading files.
|
echo We have encountered an error while downloading files.
|
||||||
@ -215,15 +221,15 @@ destDir="UUPs"
|
|||||||
tempScript="aria2_script.\$RANDOM.txt"
|
tempScript="aria2_script.\$RANDOM.txt"
|
||||||
|
|
||||||
echo "Downloading converters..."
|
echo "Downloading converters..."
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 --allow-overwrite=true --auto-file-renaming=false -d"files" -i"files/converter_multi"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j2 --allow-overwrite=true --auto-file-renaming=false -d"files" -i"files/converter_multi"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "We have encountered an error while downloading files."
|
echo "We have encountered an error while downloading files."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Retrieving aria2 script..."
|
echo "Retrieving aria2 script for the UUP set..."
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Failed to retrieve aria2 script"
|
echo "Failed to retrieve aria2 script"
|
||||||
exit 1
|
exit 1
|
||||||
@ -237,8 +243,8 @@ if [ ! -z \$detectedError ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Attempting to download files..."
|
echo "Downloading the UUP set..."
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"\$destDir" -i"\$tempScript"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"\$destDir" -i"\$tempScript"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "We have encountered an error while downloading files."
|
echo "We have encountered an error while downloading files."
|
||||||
exit 1
|
exit 1
|
||||||
@ -334,7 +340,8 @@ CONFIG;
|
|||||||
$zip->addFromString('files/convert_config_macos', $convertConfigLinux);
|
$zip->addFromString('files/convert_config_macos', $convertConfigLinux);
|
||||||
$zip->addFile($currDir.'/misc/autodl_files/readme.unix.md', 'readme.unix.md');
|
$zip->addFile($currDir.'/misc/autodl_files/readme.unix.md', 'readme.unix.md');
|
||||||
$zip->addFile($currDir.'/misc/autodl_files/converter_multi', 'files/converter_multi');
|
$zip->addFile($currDir.'/misc/autodl_files/converter_multi', 'files/converter_multi');
|
||||||
$zip->addFile($currDir.'/misc/autodl_files/depends_win.ps1', 'files/depends_win.ps1');
|
$zip->addFile($currDir.'/misc/autodl_files/converter_windows', 'files/converter_windows');
|
||||||
|
$zip->addFile($currDir.'/misc/autodl_files/get_aria2.ps1', 'files/get_aria2.ps1');
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
if($virtualEditions) {
|
if($virtualEditions) {
|
||||||
@ -359,20 +366,20 @@ function createAria2Package($url, $archiveName, $app = null) {
|
|||||||
$time = gmdate("Y-m-d H:i:s T", time());
|
$time = gmdate("Y-m-d H:i:s T", time());
|
||||||
|
|
||||||
$ariacmd = <<<TEXT
|
$ariacmd = <<<TEXT
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"%destDir%" -i"%aria2Script%"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||||
TEXT;
|
TEXT;
|
||||||
|
|
||||||
$ariabash = <<<TEXT
|
$ariabash = <<<TEXT
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"\$destDir" -i"\$tempScript"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"\$destDir" -i"\$tempScript"
|
||||||
TEXT;
|
TEXT;
|
||||||
|
|
||||||
if(strpos($archiveName, "_app")) {
|
if(strpos($archiveName, "_app")) {
|
||||||
$ariacmd = <<<TEXT
|
$ariacmd = <<<TEXT
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||||
TEXT;
|
TEXT;
|
||||||
|
|
||||||
$ariabash = <<<TEXT
|
$ariabash = <<<TEXT
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"\$destDir" -i"\$tempScript"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"\$destDir" -i"\$tempScript"
|
||||||
TEXT;
|
TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,9 +388,10 @@ TEXT;
|
|||||||
$downloadapp = <<<TEXT
|
$downloadapp = <<<TEXT
|
||||||
|
|
||||||
:DOWNLOAD_APPS
|
:DOWNLOAD_APPS
|
||||||
echo Retrieving aria2 script for Apps...
|
echo Retrieving aria2 script for Microsoft Store Apps...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
||||||
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
||||||
|
echo.
|
||||||
|
|
||||||
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
||||||
if NOT [%DETECTED_ERROR%] == [] (
|
if NOT [%DETECTED_ERROR%] == [] (
|
||||||
@ -394,16 +402,17 @@ if NOT [%DETECTED_ERROR%] == [] (
|
|||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Attempting to download Apps files...
|
echo Downloading Microsoft Store Apps...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||||
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_APPS
|
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_APPS
|
||||||
|
echo.
|
||||||
|
|
||||||
TEXT;
|
TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmdScript = <<<SCRIPT
|
$cmdScript = <<<SCRIPT
|
||||||
@echo off
|
@echo off
|
||||||
rem Generated on $time
|
:: Generated on $time
|
||||||
|
|
||||||
:: Proxy configuration
|
:: Proxy configuration
|
||||||
:: If you need to configure a proxy to be able to connect to the internet,
|
:: If you need to configure a proxy to be able to connect to the internet,
|
||||||
@ -421,17 +430,19 @@ set "all_proxy="
|
|||||||
|
|
||||||
:: End of proxy configuration
|
:: End of proxy configuration
|
||||||
|
|
||||||
|
title {$archiveName} download
|
||||||
|
|
||||||
set "aria2=files\\aria2c.exe"
|
set "aria2=files\\aria2c.exe"
|
||||||
set "aria2Script=files\\aria2_script.%random%.txt"
|
set "aria2Script=files\\aria2_script.%random%.txt"
|
||||||
set "destDir=UUPs"
|
set "destDir=UUPs"
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
powershell -NoProfile -ExecutionPolicy Unrestricted .\\files\\depends_win.ps1 -ForDownload || (pause & exit /b 1)
|
powershell -NoProfile -ExecutionPolicy Unrestricted .\\files\\get_aria2.ps1 || (pause & exit /b 1)
|
||||||
echo.
|
echo.
|
||||||
$downloadapp
|
$downloadapp
|
||||||
:DOWNLOAD_UUPS
|
:DOWNLOAD_UUPS
|
||||||
echo Retrieving aria2 script...
|
echo Retrieving aria2 script for the UUP set...
|
||||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
"%aria2%" --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||||
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
if %ERRORLEVEL% GTR 0 call :DOWNLOAD_ERROR & exit /b 1
|
||||||
|
|
||||||
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
||||||
@ -443,7 +454,7 @@ if NOT [%DETECTED_ERROR%] == [] (
|
|||||||
goto :EOF
|
goto :EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Attempting to download files...
|
echo Downloading the UUP set...
|
||||||
$ariacmd
|
$ariacmd
|
||||||
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS & exit /b 1
|
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS & exit /b 1
|
||||||
|
|
||||||
@ -489,8 +500,8 @@ which aria2c &>/dev/null || {
|
|||||||
destDir="UUPs"
|
destDir="UUPs"
|
||||||
tempScript="aria2_script.\$RANDOM.txt"
|
tempScript="aria2_script.\$RANDOM.txt"
|
||||||
|
|
||||||
echo "Retrieving aria2 script..."
|
echo "Retrieving aria2 script for the UUP set..."
|
||||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
aria2c --no-conf --console-log-level=warn --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Failed to retrieve aria2 script"
|
echo "Failed to retrieve aria2 script"
|
||||||
exit 1
|
exit 1
|
||||||
@ -504,7 +515,7 @@ if [ ! -z \$detectedError ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Attempting to download files..."
|
echo "Downloading the UUP set..."
|
||||||
$ariabash
|
$ariabash
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "We have encountered an error while downloading files."
|
echo "We have encountered an error while downloading files."
|
||||||
@ -526,7 +537,7 @@ SCRIPT;
|
|||||||
$zip->addFromString('uup_download_linux.sh', $shellScript);
|
$zip->addFromString('uup_download_linux.sh', $shellScript);
|
||||||
$zip->addFromString('uup_download_macos.sh', $shellScript);
|
$zip->addFromString('uup_download_macos.sh', $shellScript);
|
||||||
$zip->addFile($currDir.'/misc/autodl_files/readme.unix.md', 'readme.unix.md');
|
$zip->addFile($currDir.'/misc/autodl_files/readme.unix.md', 'readme.unix.md');
|
||||||
$zip->addFile($currDir.'/misc/autodl_files/depends_win.ps1', 'files/depends_win.ps1');
|
$zip->addFile($currDir.'/misc/autodl_files/get_aria2.ps1', 'files/get_aria2.ps1');
|
||||||
$zip->close();
|
$zip->close();
|
||||||
} else {
|
} else {
|
||||||
echo 'Failed to create archive.';
|
echo 'Failed to create archive.';
|
||||||
|
Loading…
Reference in New Issue
Block a user