@@ -38,23 +38,28 @@ setlocal enabledelayedexpansion
3838:Update
3939 cls
4040 echo Downloading information...
41- curl --silent -o batch_update.txt https://gist.githubusercontent.com/Adam-Kay/ec5da0ff40e8eb14beee2242161f5191/raw
42- for /f " tokens=1,2,3 delims=|" %%A in (batch_update.txt) do (
43- set UpdateVersion = %%A
44- set UpdateAPIURL = %%B
45- set UpdateBrowserURL = %%C
46- )
47-
48- rem Test if any of them are blank
49- for %%a in (UpdateVersion, UpdateAPIURL, UpdateBrowserURL) do if not defined %%a goto AutoUpdateError
50-
41+ set " updateFileName = batch_update.json"
42+ curl --silent -L -H " Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
43+ rem curl --silent -o batch_update.txt https://gist.githubusercontent.com/Adam-Kay/ec5da0ff40e8eb14beee2242161f5191/raw
44+
45+ > %TEMP% \batch_update.tmp findstr " tag_name" %updateFileName%
46+ < %TEMP% \batch_update.tmp set /p " ver_entry = "
47+ set " ver = %ver_entry:~15 ,-2 % "
48+ set " UpdateVersion = %ver:~1 % "
49+
50+ set regex_command = powershell -Command " $x = Get-Content %updateFileName% -Raw; $k = $x | Select-String -Pattern '(?s)url(((?^^^!url).)*?)batch\.encoder'; $g = $k.Matches.Value | Select-String -Pattern '^" " [^^^^" " " ]+?^ " " " ,'; $g.Matches.Value"
51+
52+ FOR /F " tokens=*" %%g IN ('%regex_command% ') do (SET API_link_entry=%%g )
53+ set " UpdateAPIURL = %API_link_entry:~1 ,-2 % "
5154
55+ for %%a in (ver_entry, API_link_entry, UpdateVersion, UpdateAPIURL) do if not defined %%a goto AutoUpdateError
56+
5257 echo Version found^^! ^ (%UpdateVersion% ^ )
5358 echo Proceeding with force update in 5 seconds, press CTRL+C or close window to cancel.
5459 echo .
5560 timeout /nobreak /t 5 > nul
5661 echo Downloading files...
57- curl --silent -L -H " Accept: application/octet-stream" -o " batch encoder %UpdateVersion% .bat" %UpdateAPIURL%
62+ curl --silent -L -H " Accept: application/octet-stream" -o " batch encoder v %UpdateVersion% .bat" %UpdateAPIURL%
5863 echo .
5964 echo Download complete. The program will now clean up and restart.
6065 pause
@@ -63,13 +68,18 @@ setlocal enabledelayedexpansion
6368 del " %BEFile% "
6469 )
6570 )
66- del " batch_update.txt "
67- (goto) 2 > nul & " batch encoder %UpdateVersion% .bat" --updated-from " %~f0 "
71+ del " %updateFileName% "
72+ (goto) 2 > nul & " batch encoder v %UpdateVersion% .bat" --updated-from " %~f0 "
6873
6974:AutoUpdateError
7075 del " %updateFileName% "
7176 echo .
72- echo There was a problem with the auto-updater. Exiting...
77+ echo .
78+ echo *******************************************************
79+ echo There was a problem with the auto-updater. You can download the latest version of the program at:
80+ echo https://github.com/Adam-Kay/Batch-Encoder/releases
81+ echo .
82+ echo Exiting...
7383 echo .
7484 pause
7585 exit
0 commit comments