Skip to content

Commit

Permalink
Add: Improve the procedure of upgrading you-get; Reset AdvancedSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
LussacZheng committed Dec 7, 2019
1 parent d9237f7 commit 7cb6780
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
27 changes: 23 additions & 4 deletions Deploy.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@rem - Encoding:utf-8; Mode:Batch; Language:zh-CN,en; LineEndings:CRLF -
:: Video Downloaders (You-Get, Youtube-dl, Annie) One-Click Deployment Batch (Windows)
:: Author: Lussac (https://blog.lussac.net)
:: Version: 1.3.4
:: Last updated: 2019-10-29
:: Version: 1.4.0
:: Last updated: 2019-12-07
:: >>> Get updated from: https://github.com/LussacZheng/video-downloader-deploy <<<
:: >>> EDIT AT YOUR OWN RISK. <<<
@echo off
setlocal EnableDelayedExpansion
set "version=1.3.4"
set "lastUpdated=2019-10-29"
set "version=1.4.0"
set "lastUpdated=2019-12-07"
:: Remote resources url of 'sources.txt', 'wget.exe', '7za.exe', 'scripts/CurrentVersion'
set "_RemoteRes_=https://raw.githubusercontent.com/LussacZheng/video-downloader-deploy/master/res"

Expand Down Expand Up @@ -352,12 +352,15 @@ echo. & echo [3] %str_opt6_opt3%
echo. & echo [4] %str_opt6_opt4%
echo. & echo [5] %str_opt6_opt5%
echo. & echo [6] %str_opt6_opt6%
if NOT "%DeployMode%"=="withpip" ( echo. & echo [7] %str_opt6_opt7% )
echo. & echo [99] %str_opt6_opt99%
echo. & echo.
echo ====================================================
set opt6_choice=-1
set /p opt6_choice= %str_please-choose%
echo.
if "%opt6_choice%"=="0" goto MENU
if "%opt6_choice%"=="99" goto setting_Reset
if "%opt6_choice%"=="1" goto setting_Language
if "%opt6_choice%"=="11" ( call res\scripts\Config.bat Language en && goto _PleaseRerun_ )
if "%opt6_choice%"=="12" ( call res\scripts\Config.bat Language zh && goto _PleaseRerun_ )
Expand All @@ -369,10 +372,22 @@ if "%opt6_choice%"=="4" goto setting_FFmpeg
if "%opt6_choice%"=="5" goto setting_Wget
if "%opt6_choice%"=="50" goto setting_Wget2
if "%opt6_choice%"=="6" goto setting_NetTest
if "%opt6_choice%"=="7" goto setting_UpgradeOnlyViaGitHub
echo. & echo %str_please-input-valid-num%
goto _ReturnToSetting_


:setting_Reset
set opt6_opt99_choice=0
echo %str_reset-settings_1%
set /p opt6_opt99_choice= %str_reset-settings_2%
echo.
if /i "%opt6_opt99_choice%"=="Y" (
del /Q res\deploy.settings >NUL 2>NUL
echo %str_reset-settings_3%
) else echo %str_reset-settings_4%
goto _ReturnToSetting_

:setting_Language
echo %str_please-select-language%
goto _ReturnToSetting_
Expand Down Expand Up @@ -411,6 +426,10 @@ goto _ReturnToSetting_
call res\scripts\Config.bat NetTest
goto _ReturnToSetting_

:setting_UpgradeOnlyViaGitHub
call res\scripts\Config.bat UpgradeOnlyViaGitHub
goto _ReturnToSetting_


rem ================= FUNCTIONS =================

Expand Down
15 changes: 15 additions & 0 deletions res/scripts/Config.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if NOT exist %cfg_File% (
echo ProxyHint: disable>> %cfg_File%
echo FFmpeg: enable>> %cfg_File%
echo NetTest: enable>> %cfg_File%
echo UpgradeOnlyViaGitHub: disable>> %cfg_File%
)
copy %cfg_File% %cfg_File%.bak > NUL
type NUL > %cfg_File%
Expand Down Expand Up @@ -109,4 +110,18 @@ if "%cfg_State%"=="enable" (
goto :eof


:Config_UpgradeOnlyViaGitHub
for /f "delims=" %%i in (%cfg_File%.bak) do (
set "cfg_Temp=%%i"
set "cfg_Content=!cfg_Temp!"
if "!cfg_Temp!"=="UpgradeOnlyViaGitHub: disable" ( set "cfg_Content=UpgradeOnlyViaGitHub: enable" && set "cfg_State=enable" )
if "!cfg_Temp!"=="UpgradeOnlyViaGitHub: enable" ( set "cfg_Content=UpgradeOnlyViaGitHub: disable" && set "cfg_State=disable" )
echo !cfg_Content!>>%cfg_File%
)
if "%cfg_State%"=="enable" (
echo %str_upgradeOnlyViaGitHub-enabled%
) else echo %str_upgradeOnlyViaGitHub-disabled%
goto :eof


rem ================= End of File =================
2 changes: 1 addition & 1 deletion res/scripts/CurrentVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.4
1.4.0
24 changes: 20 additions & 4 deletions res/scripts/DoDeploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,26 @@ goto :eof
echo %str_upgrading% you-get...
:: %ygCurrentVersion% was set in res\scripts\CheckUpdate.bat :CheckUpdate_youget
del /Q download\you-get-%ygCurrentVersion%.tar.gz >NUL 2>NUL
del /Q sources.txt >NUL 2>NUL
wget %_WgetOptions_% %_RemoteRes_%/sources.txt
call scripts\SourcesSelector.bat sources.txt youget %_Region_% %_SystemType_% download\to-be-downloaded.txt
wget %_WgetOptions_% -i download\to-be-downloaded.txt -P download
if exist deploy.settings (
for /f "tokens=2 delims= " %%i in ('findstr /i "UpgradeOnlyViaGitHub" deploy.settings') do ( set "state_upgradeOnlyViaGitHub=%%i" )
) else ( set "state_upgradeOnlyViaGitHub=disable" )
setlocal EnableDelayedExpansion
if "%state_upgradeOnlyViaGitHub%"=="enable" (
set "ygLatestVersion_Url=https://github.com/soimort/you-get/releases/download/v%ygLatestVersion%/you-get-%ygLatestVersion%.tar.gz"
echo !ygLatestVersion_Url!>> download\to-be-downloaded.txt
wget %_WgetOptions_% !ygLatestVersion_Url! -P download
) else (
del /Q sources.txt >NUL 2>NUL
wget %_WgetOptions_% %_RemoteRes_%/sources.txt
call scripts\SourcesSelector.bat sources.txt youget %_Region_% %_SystemType_% download\to-be-downloaded.txt
wget %_WgetOptions_% -i download\to-be-downloaded.txt -P download
REM If the file fails to download because of mirror index not syncing timelier, set %_Region_% as "origin" to fetch from original source.
if NOT exist download\you-get-%ygLatestVersion%.tar.gz (
call scripts\SourcesSelector.bat sources.txt youget origin %_SystemType_% download\to-be-downloaded.txt
wget %_WgetOptions_% -i download\to-be-downloaded.txt -P download
)
)
endlocal
rd /S /Q "%ygBin%" >NUL 2>NUL
cd download && call :Setup_youget
cd .. && echo You-Get %str_already-upgrade%
Expand Down
8 changes: 8 additions & 0 deletions res/scripts/lang_en.bat
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ set "str_opt6_opt3=(Display/Hide) the examples of proxy options"
set "str_opt6_opt4=(Disable/Enable) FFmpeg"
set "str_opt6_opt5=Set options for 'wget'"
set "str_opt6_opt6=(Disable/Enable) Network connection test while upgrading"
set "str_opt6_opt7=Upgrade you-get via ^(PyPI.org/GitHub_Releases^)"
set "str_opt6_opt99=Why can't I toggle certain settings above?"
set "str_please-select-language=[11] English ; [12] Simplified Chinese"
set "str_language-set-to=Language has been set to:"
set "str_please-select-region=[21] Origin website (origin) ; [22] CN mirror (cn)"
Expand All @@ -83,6 +85,12 @@ set "str_please-edit-wget-opt_3=To reset the default "wget.opt", please enter: 5
set "str_reset-wget-opt-ok=The "wget.opt" has been reset."
set "str_netTest-enabled=Network connection test while upgrading: enabled ^(DEFAULT^)"
set "str_netTest-disabled=Network connection test while upgrading: disabled"
set "str_upgradeOnlyViaGitHub-enabled=Upgrade you-get via: GitHub_Releases"
set "str_upgradeOnlyViaGitHub-disabled=Upgrade you-get via: PyPI.org ^(DEFAULT^)"
set "str_reset-settings_1=After updating this batch, if the new settings cannot be toggled, you need to delete "res\deploy.settings"."
set "str_reset-settings_2=But this will reset all the above settings(EXCEPT [5]) to default. Enter Y to continue:"
set "str_reset-settings_3=The "res\deploy.settings" is deleted, please try changing the settings again."
set "str_reset-settings_4=Invalid input. Cancelled."
:: END OF TRANSLATION
:: Select mirror for sources.txt
set "_Region_=origin"
10 changes: 9 additions & 1 deletion res/scripts/lang_zh.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set "str_downloading=
set "str_unzipping=正在解压"
set "str_upgrading=正在更新"
set "str_updating=正在更新"
set "str_checking-connection=正在检查网络连接 (如果长时间无响应,请确认网络是否正常)"
set "str_checking-connection=正在检查网络连接 (如果长时间无响应,请确认网络是否正常,或前往高级设置关闭"网络连接测试")"
set "str_checking-update=正在检查更新"
set "str_already-deploy=已配置。"
set "str_already-upgrade=已更新。"
Expand All @@ -64,6 +64,8 @@ set "str_opt6_opt3=(
set "str_opt6_opt4=(禁用/启用) FFmpeg"
set "str_opt6_opt5=为 'wget' 设置参数"
set "str_opt6_opt6=(禁用/启用) 更新时的网络连接测试"
set "str_opt6_opt7=通过 ^(PyPI.org/GitHub_Releases^) 更新 you-get"
set "str_opt6_opt99=为什么我无法切换以上的某项设置?"
set "str_please-select-language=[11] English ; [12] 简体中文"
set "str_language-set-to=语言已设置为:"
set "str_please-select-region=[21] 官方源 (origin) ; [22] 国内镜像源 (cn)"
Expand All @@ -83,6 +85,12 @@ set "str_please-edit-wget-opt_3=
set "str_reset-wget-opt-ok=已重新生成 "wget.opt""
set "str_netTest-enabled=更新时的网络连接测试:启用 ^(默认^)"
set "str_netTest-disabled=更新时的网络连接测试:禁用"
set "str_upgradeOnlyViaGitHub-enabled=更新 you-get 的方式:通过 GitHub_Releases"
set "str_upgradeOnlyViaGitHub-disabled=更新 you-get 的方式:通过 PyPI.org ^(默认^)"
set "str_reset-settings_1=更新脚本后,若新增的设置无法切换,则需要删除 "res\deploy.settings""
set "str_reset-settings_2=但这会导致以上所有的设置([5]除外)恢复至默认,输入Y以继续:"
set "str_reset-settings_3=已删除 "res\deploy.settings" ,请尝试重新更改设置。"
set "str_reset-settings_4=输入无效,已取消。"
:: END OF TRANSLATION
:: Select mirror for sources.txt
set "_Region_=cn"

0 comments on commit 7cb6780

Please sign in to comment.