-
Notifications
You must be signed in to change notification settings - Fork 0
/
updater.bat
160 lines (147 loc) · 4.82 KB
/
updater.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
:: version 2.2.1
@echo off
title YTDL-Helper Updater
set gver=SOME
set lver=NONE
cd %~dp0
echo %* | findstr /I "ytdl-dwd"
if %errorlevel% == 0 goto :ytdl-dwd
echo %* | findstr /I "ytdl-upd"
if %errorlevel% == 0 goto :ytdl-upd
echo %* | findstr /I "ffmpeg-dwd"
if %errorlevel% == 0 goto :ffmpeg-dwd
:: ==================================================Obtain==================================================
curl --output releases.tmp -L https://api.github.com/repos/yuri010/youtube-dl-helper/releases
call :gver
call :gvercleanup
call :lver
goto :main
:: ==================================================Checks==================================================
:gver
for /F "tokens=2 delims= " %%a IN ('findstr /I "tag_name" releases.tmp') DO (
set gver=%%a
exit /b
)
:gvercleanup
for /F "tokens=1 delims=," %%b IN ("%gver%") DO (
set gver=%%b
exit /b
)
:lver
for /F "tokens=3 delims= " %%c IN ('findstr /I "version" ytdl-helper.bat') DO (
set lver=%%c
exit /b
)
:main
del releases.tmp
if exist "ytdl-helper.bat" (
if "%lver%" LSS %gver% (
cls
echo An update is available, would you like to install it? [Y/N]
choice /c YN /N
if /I "%errorlevel%" EQU "2" exit
if /I "%errorlevel%" EQU "1" goto :update
)
if /I "%lver%" GTR %gver% (
cls
echo Hey! Github isn't Up-to-Date!
echo.
echo Press any key to exit...
pause > nul
exit
)
if /I "%lver%" == %gver% (
cls
echo YTDL-Helper is Up-to-Date.
echo.
echo Press any key to exit...
pause > nul
exit
)
) else (
cls
echo The YTDL-Helper is not installed! It will be installed automatically.
timeout /t 3 /nobreak > nul
goto :update
)
:: ==================================================Update==================================================
:update
cls
echo Attempting to obtain the latest YTDL-Helper...
echo.
echo Log: ====================================================================================================
echo.
curl -0 -L https://raw.githubusercontent.com/Yuri010/Youtube-DL-Helper/main/ytdl-helper.bat -o ytdl-helper-new.bat
curl -0 -L https://raw.githubusercontent.com/Yuri010/Youtube-DL-Helper/main/updater.bat -o updater-new.bat
echo.
echo =========================================================================================================
echo Updating to version %gver% over %lver%...
move ytdl-helper-new.bat ytdl-helper.bat
timeout 1 > nul
start "" "cmd /c move updater-new.bat updater.bat"
exit
:: ==================================================FFMPEG==================================================
:ffmpeg-dwd
echo Attempting to obtain the latest FFmpeg release from https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
echo.
echo Log: ====================================================================================================
echo.
curl --output ffmpeg.zip -L https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip > nul
echo.
echo =========================================================================================================
tar -xf ffmpeg.zip
timeout /t 1 /nobreak > nul
del ffmpeg.zip
cls
echo FFMpeg Update Done.
echo Restarting YTDL-Helper...
timeout /t 2 /nobreak > nul
start "" "%~dp0/ytdl-helper.bat"
exit
:: ==================================================YTDL==================================================
:ytdl-info
curl --output releases.tmp -L https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
more releases.tmp | findstr /I "yt-dlp_min.exe" | findstr "browser_download_url" > link.tmp
for /F "tokens=2 delims= " %%l IN ('more link.tmp') do (set link=%%l)
call :gver
call :gvercleanup
del link.tmp
del releases.tmp
exit/b
:ytdl-dwd
cls
call :ytdl-info
cls
echo Attempting to obtain the latest Youtube-DL...
echo.
echo Log: ====================================================================================================
echo.
curl -0 -L %link% -o youtube-dl.exe
echo.
echo =========================================================================================================
timeout /t 1 /nobreak > nul
cls
echo Youtube-DL Update Done.
echo Restarting YTDL-Helper...
timeout /t 2 /nobreak > nul
start "" "%~dp0/ytdl-helper.bat"
exit
:ytdl-upd
cls
call :ytdl-info
for /f "tokens=* delims=" %%a IN ('youtube-dl --version') do (set lver="%%a")
if /I "%lver%" == %gver% (
cls
echo YTDL-Helper is Up-to-Date.
echo.
echo Press any key to exit...
pause > nul
exit
)
if "%lver%" LSS %gver% (
cls
echo An update is available, would you like to install it? [Y/N]
choice /c YN /N
if /I "%errorlevel%" EQU "2" exit
if /I "%errorlevel%" EQU "1" goto :ytdl-dwd
)