forked from uup-dump/contrib
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
|
||||
/*
|
||||
Copyright 2019 whatever127
|
||||
// Copyright (C) 2023 UUP dump authors. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
/*
|
||||
* Changing anything in this file is a really painful experience.
|
||||
* Please don't do this to yourself.
|
||||
*/
|
||||
|
||||
//Create aria2 download package with conversion script
|
||||
@ -39,9 +30,10 @@ function createUupConvertPackage(
|
||||
$downloadapp = <<<TEXT
|
||||
|
||||
:DOWNLOAD_APPS
|
||||
echo Retrieving aria2 script for Apps...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
||||
echo Retrieving aria2 script for Microsoft Store Apps...
|
||||
"%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
|
||||
echo.
|
||||
|
||||
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
||||
if NOT [%DETECTED_ERROR%] == [] (
|
||||
@ -52,16 +44,17 @@ if NOT [%DETECTED_ERROR%] == [] (
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
echo Attempting to download Apps files...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||
echo Downloading Microsoft Store Apps...
|
||||
"%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
|
||||
echo.
|
||||
|
||||
TEXT;
|
||||
}
|
||||
|
||||
$cmdScript = <<<SCRIPT
|
||||
@echo off
|
||||
rem Generated on $time
|
||||
:: Generated on $time
|
||||
|
||||
:: Proxy configuration
|
||||
:: If you need to configure a proxy to be able to connect to the internet,
|
||||
@ -114,13 +107,20 @@ SETLOCAL DISABLEDELAYEDEXPANSION
|
||||
goto :EOF
|
||||
|
||||
:START_PROCESS
|
||||
title {$archiveName} download
|
||||
|
||||
set "aria2=files\\aria2c.exe"
|
||||
set "a7z=files\\7zr.exe"
|
||||
set "uupConv=files\\uup-converter-wimlib.7z"
|
||||
set "aria2Script=files\\aria2_script.%random%.txt"
|
||||
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.
|
||||
|
||||
if NOT EXIST ConvertConfig.ini goto :NO_FILE_ERROR
|
||||
@ -132,8 +132,8 @@ echo Extracting UUP converter...
|
||||
echo.
|
||||
$downloadapp
|
||||
:DOWNLOAD_UUPS
|
||||
echo Retrieving aria2 script...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||
echo Retrieving aria2 script for the UUP set...
|
||||
"%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
|
||||
echo.
|
||||
|
||||
@ -146,8 +146,8 @@ if NOT [%DETECTED_ERROR%] == [] (
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
echo Attempting to download files...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||
echo Downloading the UUP set...
|
||||
"%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 EXIST convert-UUP.cmd goto :START_CONVERT
|
||||
@ -163,6 +163,12 @@ echo We couldn't find one of needed files for this script.
|
||||
pause
|
||||
goto :EOF
|
||||
|
||||
:DOWNLOAD_CONVERTER_ERROR
|
||||
echo.
|
||||
echo An error has occurred while downloading the UUP converter.
|
||||
pause
|
||||
goto :EOF
|
||||
|
||||
:DOWNLOAD_ERROR
|
||||
echo.
|
||||
echo We have encountered an error while downloading files.
|
||||
@ -215,15 +221,15 @@ destDir="UUPs"
|
||||
tempScript="aria2_script.\$RANDOM.txt"
|
||||
|
||||
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
|
||||
echo "We have encountered an error while downloading files."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Retrieving aria2 script..."
|
||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||
echo "Retrieving aria2 script for the UUP set..."
|
||||
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
|
||||
echo "Failed to retrieve aria2 script"
|
||||
exit 1
|
||||
@ -237,8 +243,8 @@ if [ ! -z \$detectedError ]; then
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Attempting to download files..."
|
||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j5 -c -R -d"\$destDir" -i"\$tempScript"
|
||||
echo "Downloading the UUP set..."
|
||||
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
|
||||
echo "We have encountered an error while downloading files."
|
||||
exit 1
|
||||
@ -334,7 +340,8 @@ CONFIG;
|
||||
$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/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();
|
||||
|
||||
if($virtualEditions) {
|
||||
@ -359,20 +366,20 @@ function createAria2Package($url, $archiveName, $app = null) {
|
||||
$time = gmdate("Y-m-d H:i:s T", time());
|
||||
|
||||
$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;
|
||||
|
||||
$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;
|
||||
|
||||
if(strpos($archiveName, "_app")) {
|
||||
$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;
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -381,9 +388,10 @@ TEXT;
|
||||
$downloadapp = <<<TEXT
|
||||
|
||||
:DOWNLOAD_APPS
|
||||
echo Retrieving aria2 script for Apps...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$app"
|
||||
echo Retrieving aria2 script for Microsoft Store Apps...
|
||||
"%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
|
||||
echo.
|
||||
|
||||
for /F "tokens=2 delims=:" %%i in ('findstr #UUPDUMP_ERROR: "%aria2Script%"') do set DETECTED_ERROR=%%i
|
||||
if NOT [%DETECTED_ERROR%] == [] (
|
||||
@ -394,16 +402,17 @@ if NOT [%DETECTED_ERROR%] == [] (
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
echo Attempting to download Apps files...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -x16 -s16 -j25 -c -R -d"%destDir%" -i"%aria2Script%"
|
||||
echo Downloading Microsoft Store Apps...
|
||||
"%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
|
||||
echo.
|
||||
|
||||
TEXT;
|
||||
}
|
||||
|
||||
$cmdScript = <<<SCRIPT
|
||||
@echo off
|
||||
rem Generated on $time
|
||||
:: Generated on $time
|
||||
|
||||
:: Proxy configuration
|
||||
:: 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
|
||||
|
||||
title {$archiveName} download
|
||||
|
||||
set "aria2=files\\aria2c.exe"
|
||||
set "aria2Script=files\\aria2_script.%random%.txt"
|
||||
set "destDir=UUPs"
|
||||
|
||||
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.
|
||||
$downloadapp
|
||||
:DOWNLOAD_UUPS
|
||||
echo Retrieving aria2 script...
|
||||
"%aria2%" --no-conf --log-level=info --log="aria2_download.log" -o"%aria2Script%" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||
echo Retrieving aria2 script for the UUP set...
|
||||
"%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
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
echo Attempting to download files...
|
||||
echo Downloading the UUP set...
|
||||
$ariacmd
|
||||
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS & exit /b 1
|
||||
|
||||
@ -489,8 +500,8 @@ which aria2c &>/dev/null || {
|
||||
destDir="UUPs"
|
||||
tempScript="aria2_script.\$RANDOM.txt"
|
||||
|
||||
echo "Retrieving aria2 script..."
|
||||
aria2c --no-conf --log-level=info --log="aria2_download.log" -o"\$tempScript" --allow-overwrite=true --auto-file-renaming=false "$url"
|
||||
echo "Retrieving aria2 script for the UUP set..."
|
||||
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
|
||||
echo "Failed to retrieve aria2 script"
|
||||
exit 1
|
||||
@ -504,7 +515,7 @@ if [ ! -z \$detectedError ]; then
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Attempting to download files..."
|
||||
echo "Downloading the UUP set..."
|
||||
$ariabash
|
||||
if [ $? != 0 ]; then
|
||||
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_macos.sh', $shellScript);
|
||||
$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();
|
||||
} else {
|
||||
echo 'Failed to create archive.';
|
||||
|
Loading…
Reference in New Issue
Block a user