From 8cba940c1d171b8cf08b10669f7cfabf035bb070 Mon Sep 17 00:00:00 2001 From: lussaczheng Date: Fri, 20 Sep 2019 21:16:57 +0800 Subject: [PATCH] Add: Improve the record of log --- Deploy.bat | 118 ++++++++++------------------- res/scripts/CurrentVersion | 2 +- res/scripts/Log.bat | 148 +++++++++++++++++++++++++++++++++++++ res/sources_youget.txt | 47 ------------ 4 files changed, 188 insertions(+), 127 deletions(-) create mode 100644 res/scripts/Log.bat delete mode 100644 res/sources_youget.txt diff --git a/Deploy.bat b/Deploy.bat index 4078e94..9c8180b 100644 --- a/Deploy.bat +++ b/Deploy.bat @@ -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.1.3 -:: Last updated: 2019-09-07 +:: Version: 1.2.0 +:: Last updated: 2019-09-20 :: >>> Get updated from: https://github.com/LussacZheng/video-downloader-deploy <<< :: >>> EDIT AT YOUR OWN RISK. <<< @echo off setlocal EnableDelayedExpansion -set "version=1.1.3" -set "lastUpdated=2019-09-07" +set "version=1.2.0" +set "lastUpdated=2019-09-20" :: Remote resources url of 'sources.txt', 'wget.exe', '7za.exe' set "_RemoteRes_=https://raw.githubusercontent.com/LussacZheng/video-downloader-deploy/master/res" @@ -25,7 +25,7 @@ call res\scripts\SystemTypeSelector.bat :: Start of Deployment title %str_title% -- By Lussac -:: py=python, yg=you-get, yd=youtube-dl, an=annie, ff=ffmpeg +:: py=python, yg=you-get, yd=youtube-dl, an=annie, ff=ffmpeg, pip=pip set "root=%cd%" set "pyBin=%root%\usr\python-embed" set "ygBin=%root%\usr\you-get" @@ -35,7 +35,7 @@ set "ffBin=%root%\usr\ffmpeg\bin" :: If already deployed, show more info in Option3. set "opt3_info=" -if NOT exist res\init.log goto MENU +if NOT exist res\deploy.log goto MENU cd res && call :Get_DeployMode if "%DeployMode%"=="portable" set "opt3_info=(you-get,youtube-dl,annie)" if "%DeployMode%"=="quickstart" set "opt3_info=(you-get)" @@ -110,17 +110,7 @@ if NOT exist "%pyBin%" call :Setup_Python if NOT exist "%ygBin%" call :Setup_YouGet if NOT exist "%ydBin%" call :Setup_YoutubeDL if NOT exist "%anBin%\annie.exe" call :Setup_Annie - -:initlog-portable -cd .. -call :InitLog_Common -call :InitLog_Common_yg -call :InitLog_Common_yd -call :InitLog_Common_an -call :InitLog_Common2 - -cd .. && call :Create_Download-bat 1 -call :_ReturnToMenu_ +cd .. && goto InitLog rem ================= OPTION 12 ================= @@ -133,15 +123,7 @@ cd res && call :Common cd download if NOT exist "%pyBin%" call :Setup_Python if NOT exist "%ygBin%" call :Setup_YouGet - -:initlog-quickstart -cd .. -call :InitLog_Common -call :InitLog_Common_yg -call :InitLog_Common2 - -cd .. && call :Create_Download-bat 1 -call :_ReturnToMenu_ +cd .. && goto InitLog rem ================= OPTION 13 ================= @@ -182,19 +164,15 @@ pip3 install --upgrade you-get %pip_option% pip3 install --upgrade youtube-dl %pip_option% echo You-Get %str_already-deploy% echo Youtube-dl %str_already-deploy% +del /Q get-pip.py >NUL 2>NUL +cd "%root%\res" && goto InitLog -:initlog-withpip -cd "%root%\res" -call :InitLog_Common -echo pip -V:>> init.log -pip -V >> init.log -for /f "delims=" %%i in ('dir /b "%pyBin%\Lib\site-packages\you_get*.dist-info"') do ( set "log_ygV=%%i" ) -echo you-get: %log_ygV:.dist-info=%>> init.log -echo youtube-dl --version:>> init.log -youtube-dl --version >> init.log -call :InitLog_Common_an -call :InitLog_Common2 +rem ================= OPTION 11-13 InitLog ================= + + +:InitLog +call scripts\Log.bat Init %DeployMode% cd .. && call :Create_Download-bat 1 call :_ReturnToMenu_ @@ -219,6 +197,8 @@ echo %str_unzipping% %ffZip% ... 7za x %ffZip% > NUL set "ffDir=%ffZip:~0,-4%" move %ffDir% "%root%\usr\ffmpeg" > NUL +:initlog-ffmpeg +cd .. && call scripts\Log.bat Init ffmpeg :ffmpeg-deploy-ok echo. & echo FFmpeg %str_already-deploy% @@ -232,6 +212,7 @@ rem ================= OPTION 3 ================= call :AskForInit cd res && call :Common_wget && call :Common_7za call :Get_DeployMode +set "whetherToLog=false" echo %str_checking-update%... if "%DeployMode%"=="portable" goto Upgrade-portable if "%DeployMode%"=="quickstart" goto Upgrade-quickstart @@ -256,8 +237,9 @@ if "%_isYgLatestVersion%"=="1" if "%_isYdLatestVersion%"=="1" if "%_isAnLatestVe echo you-get %str_is-latestVersion%: v%ygCurrentVersion% echo youtube-dl %str_is-latestVersion%: %ydCurrentVersion% echo annie %str_is-latestVersion%: v%anCurrentVersion% - goto upgrade_done + goto upgrade_done ) +set "whetherToLog=true" if "%_isYgLatestVersion%"=="0" call :Upgrade_YouGet if "%_isYdLatestVersion%"=="0" call :Upgrade_YoutubeDL if "%_isAnLatestVersion%"=="0" call :Upgrade_Annie @@ -268,7 +250,10 @@ goto upgrade_done call scripts\CheckUpdate.bat youget if "%_isYgLatestVersion%"=="1" ( echo you-get %str_is-latestVersion%: v%ygCurrentVersion% -) else call :Upgrade_YouGet +) else ( + set "whetherToLog=true" + call :Upgrade_YouGet +) goto upgrade_done @@ -276,7 +261,10 @@ goto upgrade_done call scripts\CheckUpdate.bat annie if "%_isAnLatestVersion%"=="1" ( echo annie %str_is-latestVersion%: v%anCurrentVersion% -) else call :Upgrade_Annie +) else ( + set "whetherToLog=true" + call :Upgrade_Annie +) :: Re-create a pip3.cmd in case of the whole folder had been moved. set "PATH=%root%\res\command;%pyBin%;%pyBin%\Scripts;%PATH%" @@ -291,10 +279,11 @@ echo pip3 install --upgrade youtube-dl %pip_option%> upgrade_youtube-dl.bat :: So write the command into a bat and then call it. call upgrade_you-get.bat && call upgrade_youtube-dl.bat echo You-Get %str_already-upgraded% && echo Youtube-dl %str_already-upgraded% -goto upgrade_done +cd .. && goto upgrade_done :upgrade_done +if "%whetherToLog%"=="true" call scripts\Log.bat Upgrade %DeployMode% echo. & echo. & echo %str_upgrade-ok% call :_ReturnToMenu_ @@ -422,36 +411,6 @@ echo Annie %str_already-deploy% goto :eof -:InitLog_Common -echo initialized: true> init.log -echo deployMode: %DeployMode%>> init.log -for /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') do ( set "LDT=%%a" ) -set "formatedDateTime=%LDT:~0,4%-%LDT:~4,2%-%LDT:~6,2% %LDT:~8,2%:%LDT:~10,2%:%LDT:~12,2%" -echo time: %formatedDateTime%>> init.log -::echo time: %date:~0,10% %time:~0,8%>> init.log -echo pyZip: %pyZip%>> init.log -echo pyBin: "%pyBin%">> init.log -goto :eof - - -:InitLog_Common_yg -echo ygZip: %ygZip%>> init.log -echo ygBin: "%ygBin%">> init.log -goto :eof -:InitLog_Common_yd -echo ydZip: %ydZip%>> init.log -echo ydBin: "%ydBin%">> init.log -goto :eof -:InitLog_Common_an -echo anZip: %anZip%>> init.log -echo anBin: "%anBin%">> init.log -goto :eof -:InitLog_Common2 -echo.>> init.log -echo errorlevel: !errorlevel!>> init.log -goto :eof - - :Create_Download-bat set isInInitDeploy=%~1 call res\scripts\GenerateDownloadBatch.bat %DeployMode% @@ -483,16 +442,17 @@ goto :eof :Get_DeployMode -:: Get %DeployMode% from res\init.log -if exist init.log ( - for /f "tokens=2 delims= " %%i in ('findstr /i "deployMode" init.log') do ( set "DeployMode=%%i" ) +:: Get %DeployMode% from res\deploy.log +if exist deploy.log ( + for /f "tokens=2 delims= " %%i in ('findstr /i "DeployMode" deploy.log') do ( set "DeployMode=%%i" ) ) else ( set "DeployMode=unknown" ) goto :eof :Upgrade_YouGet echo %str_upgrading% you-get... -del /Q download\you-get*.tar.gz >NUL 2>NUL +:: %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 -q --show-progress --progress=bar:force:noscroll --no-check-certificate -c %_RemoteRes_%/sources.txt call scripts\SourcesSelector.bat sources.txt youget %_Region_% %_SystemType_% download\to-be-downloaded.txt @@ -506,8 +466,8 @@ goto :eof :Upgrade_YoutubeDL echo %str_upgrading% youtube-dl... -del /Q download\youtube-dl*.tar.gz >NUL 2>NUL -:: %ydLatestVersion% was set in res\scripts\CheckUpdate.bat :CheckUpdate_youtubedl +:: %ydCurrentVersion% and %ydLatestVersion% were set in res\scripts\CheckUpdate.bat :CheckUpdate_youtubedl +del /Q download\youtube-dl-%ydCurrentVersion%.tar.gz >NUL 2>NUL set "ydLatestVersion_Url=https://github.com/ytdl-org/youtube-dl/releases/download/%ydLatestVersion%/youtube-dl-%ydLatestVersion%.tar.gz" echo %ydLatestVersion_Url%>> download\to-be-downloaded.txt wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate -nc %ydLatestVersion_Url% -P download @@ -520,8 +480,8 @@ goto :eof :Upgrade_Annie echo %str_upgrading% annie... -del /Q download\annie*.zip >NUL 2>NUL -:: %anLatestVersion% was set in res\scripts\CheckUpdate.bat :CheckUpdate_annie +:: %anCurrentVersion% and %anLatestVersion% were set in res\scripts\CheckUpdate.bat :CheckUpdate_annie +del /Q download\annie_%anCurrentVersion%_Windows*.zip >NUL 2>NUL set "anLatestVersion_Url=https://github.com/iawia002/annie/releases/download/%anLatestVersion%/annie_%anLatestVersion%_Windows_%_SystemType_%-bit.zip" echo %anLatestVersion_Url%>> download\to-be-downloaded.txt wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate -nc %anLatestVersion_Url% -P download diff --git a/res/scripts/CurrentVersion b/res/scripts/CurrentVersion index 9c1218c..867e524 100644 --- a/res/scripts/CurrentVersion +++ b/res/scripts/CurrentVersion @@ -1 +1 @@ -1.1.3 \ No newline at end of file +1.2.0 \ No newline at end of file diff --git a/res/scripts/Log.bat b/res/scripts/Log.bat new file mode 100644 index 0000000..1df0f80 --- /dev/null +++ b/res/scripts/Log.bat @@ -0,0 +1,148 @@ +@rem - Encoding:utf-8; Mode:Batch; Language:en; LineEndings:CRLF - +:: Used for "Deploy.bat" in :InitLog & :Setup_FFmpeg & :upgrade_done +:: Please make sure that: only call this batch when %cd% is "res\". +:: e.g. +:: call scripts\Log.bat Init portable +:: call scripts\Log.bat Upgrade withpip + +@echo off +setlocal EnableDelayedExpansion +set "log_File=deploy.log" +set "log_Type=%~1" +set "log_DeployMode=%~2" +call :Log_%log_Type%-%log_DeployMode% +goto :eof + + +rem ================= Log Modes ================= + + +:: py=python, yg=you-get, yd=youtube-dl, an=annie, ff=ffmpeg, pip=pip +:Log_Init-portable +call :Log_init +call :Log_py +call :Log_yg +call :Log_yd +call :Log_an +call :Log_common +goto :eof + + +:Log_Init-quickstart +call :Log_init +call :Log_py +call :Log_yg +call :Log_common +goto :eof + + +:Log_Init-withpip +call :Log_init +call :GetPackagesInfo +echo pipVer: %log_pipVer%>> %log_File% +echo ygVer: %log_ygVer%>> %log_File% +echo ydVer: %log_ydVer%>> %log_File% +call :Log_an +call :Log_common +goto :eof + + +:Log_Init-ffmpeg +call :Log_time +call :Log_ff +call :Log_common +goto :eof + + +:: %ygCurrentVersion%, %ydLatestVersion%, %anLatestVersion% were set in res\scripts\CheckUpdate.bat :CheckUpdate_* +:Log_Upgrade-portable +call :Log_time +echo ygVer: %ygLatestVersion%>> %log_File% +echo ydVer: %ydLatestVersion%>> %log_File% +echo anVer: %anLatestVersion%>> %log_File% +call :Log_common +goto :eof + + +:Log_Upgrade-quickstart +call :Log_time +echo ygVer: %ygLatestVersion%>> %log_File% +call :Log_common +goto :eof + + +:Log_Upgrade-withpip +call :Log_time +call :GetPackagesInfo +echo pipVer: %log_pipVer%>> %log_File% +echo ygVer: %log_ygVer%>> %log_File% +echo ydVer: %log_ydVer%>> %log_File% +echo anVer: %anLatestVersion%>> %log_File% +call :Log_common +goto :eof + + +rem ================= FUNCTIONS ================= + + +:GetDateTime +for /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') do ( set "LDT=%%a" ) +set "formatedDateTime=%LDT:~0,4%-%LDT:~4,2%-%LDT:~6,2% %LDT:~8,2%:%LDT:~10,2%:%LDT:~12,2%" +goto :eof + +:GetPackagesInfo +for /f "tokens=2 delims= " %%i in ('pip -V') do ( set "log_pipVer=%%i" ) +for /f "tokens=2 delims=-" %%i in ('dir /b "%pyBin%\Lib\site-packages\you_get*.dist-info"') do ( set "log_ygVer=%%i" ) +set "log_ygVer=%log_ygVer:.dist=%" +for /f "delims=" %%i in ('youtube-dl --version') do ( set "log_ydVer=%%i" ) +goto :eof + +:Log_init +echo Initialized: true> %log_File% +echo DeployMode: %log_DeployMode%>> %log_File% +echo.>> %log_File% +call :Log_time +goto :eof + +:Log_time +echo ----- %log_Type% ----->> %log_File% +echo.>> %log_File% +call :GetDateTime +echo time: %formatedDateTime%>> %log_File% +:: echo time: %date:~0,10% %time:~0,8%>> %log_File% +echo.>> %log_File% +goto :eof + +:Log_common +echo.>> %log_File% +echo errorlevel: !errorlevel!>> %log_File% +echo.>> %log_File% +goto :eof + +:Log_py +echo pyZip: %pyZip%>> %log_File% +echo pyBin: "%pyBin%">> %log_File% +goto :eof + +:Log_yg +echo ygZip: %ygZip%>> %log_File% +echo ygBin: "%ygBin%">> %log_File% +goto :eof + +:Log_yd +echo ydZip: %ydZip%>> %log_File% +echo ydBin: "%ydBin%">> %log_File% +goto :eof + +:Log_an +echo anZip: %anZip%>> %log_File% +echo anBin: "%anBin%">> %log_File% +goto :eof + +:Log_ff +echo ffZip: %ffZip%>> %log_File% +echo anBin: "%ffBin%">> %log_File% +goto :eof + + +rem ================= End of File ================= \ No newline at end of file diff --git a/res/sources_youget.txt b/res/sources_youget.txt deleted file mode 100644 index f5eb2b2..0000000 --- a/res/sources_youget.txt +++ /dev/null @@ -1,47 +0,0 @@ -## Sources List of "video-downloader-deploy" -## https://github.com/LussacZheng/video-downloader-deploy/blob/master/res/sources_youget.txt -## For Upgrade of You-Get. -## Last updated: 2019-08-25 -## (This file is NOT required since v1.1.0 and will not be updated. It will be REMOVED after several versions.) - - - -EXAMPLE -## Title or Info -# Content that already downloaded or existing. -Content to be downlaoded. -$ Another (optional) source of the same content above. But the script will ignore this line. Exchange the URLs at your own risk. -Mirrors{ - [origin] - URL of the content from original source. NO '@', called "switch on". - [%region1%] - @ URL of the content from mirror source in %region1%. - $ "@ URL", that content will not to be downlaoded by this URL, called "switch off". - [%region2%] - @ For a same content in { }, only one URL is switched on at one time. -} - - - -## wget.exe , v1.20.3 , win32 -# https://eternallybored.org/misc/wget/1.20.3/32/wget.exe -#$ https://raw.githubusercontent.com/LussacZheng/video-downloader-deploy/master/res/wget.exe - -## 7za.exe , v19.00 , win32 -https://raw.githubusercontent.com/LussacZheng/video-downloader-deploy/master/res/7za.exe - -## Release log -## https://pypi.org/project/you-get/#history -## Last released: 2019-08-02 - -## you-get.tar.gz , v0.4.1328 -Mirrors{ - [origin] - https://files.pythonhosted.org/packages/fd/a5/c896dccb53f44f54c5c8bcfbc7b8d953289064bcfbf17cccb68136fde3bf/you-get-0.4.1328.tar.gz - $ https://github.com/soimort/you-get/releases/download/v0.4.1328/you-get-0.4.1328.tar.gz - [cn] - @ https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/fd/a5/c896dccb53f44f54c5c8bcfbc7b8d953289064bcfbf17cccb68136fde3bf/you-get-0.4.1328.tar.gz - $ https://mirrors.aliyun.com/pypi/packages/fd/a5/c896dccb53f44f54c5c8bcfbc7b8d953289064bcfbf17cccb68136fde3bf/you-get-0.4.1328.tar.gz - [test] - @ http://mirrors.163.com/pypi/packages/fd/a5/c896dccb53f44f54c5c8bcfbc7b8d953289064bcfbf17cccb68136fde3bf/you-get-0.4.1328.tar.gz -} \ No newline at end of file