Skip to content

Commit eeca4ea

Browse files
authored
Fixed some errors and improved the code
1 parent d446b28 commit eeca4ea

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

GSE_Generator.bat

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,13 @@ pause>NUL|echo Press any key to exit . . .
9898
exit
9999

100100

101-
102101
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
103102
:: ::
104103
:: FUNCTIONS ::
105104
:: ::
106105
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
107106
:function_banner
108107
cls
109-
rem chcp 850>NUL
110108
echo.
111109
echo  
112110
echo  
@@ -118,6 +116,7 @@ echo.
118116
goto :EOF
119117

120118
:function_search_imput
119+
set Search=
121120
:: ImputTextBox / for multiline bypass characters like: ,;)=
122121
for /f "tokens=1-9 delims=[]" %%1 in ('^
123122
powershell -Command^
@@ -174,17 +173,19 @@ for /f "tokens=1-9 delims=[]" %%1 in ('^
174173
if "%Search%"=="TEXTBOX_IS_EMPTY" call :function_banner&call :function_search_imput
175174
if "%Search%"=="PRESSED_X_TO_EXIT" exit
176175

176+
177177
:SEARCH_GAME
178178
echo.
179179
echo [ ] Searching game . . .
180-
chcp 65001>NUL
180+
rem chcp 65001>NUL
181+
set GameAppID=&set GameName=
181182
set "Search=%Search:&=%"
182-
set "Search=%Search: = %"
183183
set "Search=%Search:'=%"
184+
set "Search=%Search: = %"
184185
for /f "tokens=*" %%a in ('powershell -Command "'%Search%'.ToLower()"') do set "game=%%a"
185186
set "steamgame=%game: =+%"
186187

187-
set GameAppID=&set GameName=
188+
188189
Tools\CURL\curl.exe -s --config Tools/CURL/config/safari15_5.config --header @Tools/CURL/config/safari15_5.header --url "https://www.google.com/search?q=%steamgame%+steamdb" -o google.html
189190
powershell -Command "(gc -LiteralPath '%HOME%google.html') -replace '<div><span jscontroller', \"`r`n^<GAME^>^<\" -replace 'href=""', '><' -replace '"""" data-', 'game><data' -replace \"'\", '' -replace '\\', '' -replace '\|', '' -replace '\?', '' -replace '\*', '' -replace '""', '' -replace '&apos;', '' -replace '&amp;', '' -replace '&#39;', '' | Out-File -LiteralPath '%HOME%google.html' -NoNewline -encoding Default">NUL
190191
for /f "tokens=1-9 delims=<>" %%1 in (google.html) do (
@@ -215,6 +216,8 @@ set "GameName=%GameName:<=%"
215216
set "GameName=%GameName:>=%"
216217
set "GameName=%GameName:/=%"
217218
set "GameName=%GameName::=%"
219+
set "GameName=%GameName: = %"
220+
echo %GameName% (%GameAppID%)
218221

219222
:SHOW_IMAGE
220223
Tools\CURL\curl.exe -s "https://cdn.akamai.steamstatic.com/steam/apps/%GameAppID%/header.jpg" -o "%GameAppID%.jpg"
@@ -317,7 +320,7 @@ if "%searchAnswer%"=="6" goto :ONLINE
317320
if "%searchAnswer%"=="7" (
318321
if exist "configs.app.ini" del "configs.app.ini">NUL
319322
if not "%total%"=="0" echo [app::dlcs]>configs.app.ini&>>configs.app.ini echo unlock_all=0
320-
for /f "tokens=* skip=1" %%a in (Database\%GameAppID%.ini) do echo "%%a" | powershell -Command "$input.substring(1) -replace '.{2}$' -replace ' = ', '='">>configs.app.ini
323+
powershell -Command "(gc -LiteralPath '%HOME%Database\%GameAppID%.ini') -replace ' = ', '=' | Select-Object -Skip 1">>configs.app.ini
321324
if exist "%GameAppID%.json" del "%GameAppID%.json">NUL
322325
if exist "configs.app.ini" move "configs.app.ini" "%GameName%\steam_settings\configs.app.ini">NUL
323326
echo [x] Done!
@@ -515,21 +518,11 @@ echo [ ] Searching achievements . . .
515518
for /f "tokens=*" %%a in ('mshta.exe "%HOME%Tools\GSE_achievements_language.hta" "%GameName%\steam_settings\supported_languages.txt"') do set AchievementsLanguage=%%a
516519
:: get achievements from steam
517520
Tools\CURL\curl.exe -s -H "Accept-Language: %AchievementsLanguage%" -XGET "https://steamcommunity.com/stats/%GameAppID%/achievements/">steamachievements.html
518-
rem powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html') -replace '&apos;', \"'\" -replace '&amp;', '&' -replace '&quot;', 'lee.aspas' -replace ' ', '' -replace '<div class=\"achieveImgHolder\">', \"`r`n^<ACHIEVEMENT^>\" | Out-File -LiteralPath '%HOME%steamachievements.html' -NoNewline -encoding Default">NUL
519-
rem powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html') -replace '<img src=.+/%GameAppID%/', '<' -replace '"" width=.+ class=\"achievePercent\">', '><' | Out-File -LiteralPath '%HOME%steamachievements.html' -encoding Default">NUL
520-
rem powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html') -replace '</div><div class=\"achieveTxt\"><h3>', '><' -replace '<h5></h5>.+achieveRow "">', '< >' -replace '</h3><h5>', '><' -replace '</h3>', '>' -replace '</h5>.+ class=\"achieveRow \"', '' -replace '</h5>.+</html>', '>' | Out-File -LiteralPath '%HOME%steamachievements.html' -encoding Default">NUL
521-
rem powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html' | Select-Object -Skip 1) | Out-File -LiteralPath '%HOME%steamachievements.html' -encoding Default">NUL
522521
powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html') -replace '&apos;', \"'\" -replace '&amp;', '&' -replace '&quot;', 'lee.aspas' -replace ' ', '' | Out-File -LiteralPath '%HOME%steamachievements.html' -NoNewline -encoding Default">NUL
523522
powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html') -replace 'images/apps/%GameAppID%/', \"`r`n^<ACHIEVEMENT^>^<\" -replace '(.jpg)(.*)(\"achievePercent\">)', '.jpg><' -replace '(</div>)(.*)(<h3>)', '><' -replace '</h3><h5>', '><' -replace '<</h5>.*', '< >' -replace '</h5>.*', '>' | Out-File -LiteralPath '%HOME%steamachievements.html' -encoding Default"
524523
powershell -Command "(gc -LiteralPath '%HOME%steamachievements.html' | Select-Object -Skip 1) | Out-File -LiteralPath '%HOME%steamachievements.html' -encoding Default">NUL
525-
526-
527524
:: get achievements from steamdb
528525
Tools\CURL\curl.exe -s --config Tools/CURL/config/safari15_5.config --header @Tools/CURL/config/safari15_5.header --url "https://steamdb.info/app/%GameAppID%/stats/" -o steamdbachievements.html
529-
rem powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '&apos;', \"'\" -replace '&amp;', '&' -replace '&quot;', 'lee.aspas' -replace '<tr id=""achievement-.+"">', \"`r`n^<ACHIEVEMENT^>\" | Out-File -LiteralPath '%HOME%steamdbachievements.html' -NoNewline -encoding Default">NUL
530-
rem powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '</td><td>', '><' -replace '<td>', '<' -replace '<p class=\"i\">', '><' -replace '</p>><<img src=\"/static/img/appicon.svg\" data-name=""', '><' -replace '<svg .+ Hidden.', ' ' | Out-File -LiteralPath '%HOME%steamdbachievements.html' -encoding Default">NUL
531-
rem powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '\" width=.+ data-name=\"', '><' -replace '"" width=.+ alt></td></tr>', '>' -replace '</tbody>.+</html>', '' | Out-File -LiteralPath '%HOME%steamdbachievements.html' -encoding Default">NUL
532-
rem powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html' | Select-Object -Skip 1) | Out-File -LiteralPath '%HOME%steamdbachievements.html' -encoding Default">NUL
533526
powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '&apos;', \"'\" -replace '&amp;', '&' -replace '&quot;', 'lee.aspas' -replace '<tr id=""achievement-.+"">', \"`r`n^<ACHIEVEMENT^>\" | Out-File -LiteralPath '%HOME%steamdbachievements.html' -NoNewline -encoding Default">NUL
534527
powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '<ACHIEVEMENT><td>', '<ACHIEVEMENT><' -replace '</td><td>', '><' -replace '<p class=\"i\">', '><' | Out-File -LiteralPath '%HOME%steamdbachievements.html' -encoding Default">NUL
535528
powershell -Command "(gc -LiteralPath '%HOME%steamdbachievements.html') -replace '.jpg\" width.* data-name=\"', '.jpg><' -replace '<<svg width.* data-name=""', '< ><' -replace '</p>><<.* data-name=""""', '><' -replace '.jpg"" width.*', '.jpg>' | Out-File -LiteralPath '%HOME%steamdbachievements.html' -encoding Default">NUL
@@ -549,6 +542,8 @@ set NEW_ACHIEVEMENT=
549542
set /a count=0
550543
for /f "tokens=1-9 delims=<>" %%1 in (steamdbachievements.html) do (
551544
if "%%1"=="ACHIEVEMENT" (
545+
set LANG_description=
546+
set LANG_displayName=
552547
if "!count!"=="0" (
553548
if exist "%GameName%\steam_settings\achievements.json" del "%GameName%\steam_settings\achievements.json">NUL
554549
powershell -Command "Add-Content '[' -LiteralPath '%HOME%%GameName%\steam_settings\achievements.json' -encoding UTF8"
@@ -579,6 +574,8 @@ for /f "tokens=1-9 delims=<>" %%1 in (steamdbachievements.html) do (
579574
set "LANG_Echoachdesc=!LANG_achdesc:&=lee.and!"
580575
)
581576
)
577+
if "!LANG_description!"=="" set LANG_description=!ENG_description!
578+
if "!LANG_displayName!"=="" set LANG_displayName=!ENG_displayName!
582579
set /a count+=1
583580
call :function_progress " [!count!/!total!] !globalstatistics! !ENG_EchoachName!"
584581
>>"%GameName%\steam_settings\achievements.json" (
@@ -590,9 +587,9 @@ for /f "tokens=1-9 delims=<>" %%1 in (steamdbachievements.html) do (
590587
echo "icongray": "images/!icongray!",
591588
echo "name": "!name!"
592589
)
593-
if not exist "%GameName%\steam_settings\images" mkdir "%GameName%\steam_settings\images"
594-
if not exist "%GameName%\steam_settings\images\!icon!" Tools\CURL\curl.exe -s "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/%GameAppID%/!icon!" -o "%GameName%\steam_settings\images\!icon!"
595-
if not exist "%GameName%\steam_settings\images\!icongray!" Tools\CURL\curl.exe -s "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/%GameAppID%/!icongray!" -o "%GameName%\steam_settings\images\!icongray!"
590+
if not exist "%GameName%\steam_settings\images" mkdir "%GameName%\steam_settings\images">NUL
591+
if not exist "%GameName%\steam_settings\images\!icon!" Tools\CURL\curl.exe -s "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/%GameAppID%/!icon!" -o "!icon!"&move "!icon!" "%GameName%\steam_settings\images\">NUL
592+
if not exist "%GameName%\steam_settings\images\!icongray!" Tools\CURL\curl.exe -s "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/%GameAppID%/!icongray!" -o "!icongray!"&move "!icongray!" "%GameName%\steam_settings\images\">NUL
596593
if "!count!"=="!total!" (echo }>>"%GameName%\steam_settings\achievements.json") else (echo },>>"%GameName%\steam_settings\achievements.json")
597594
)
598595
)
@@ -631,10 +628,10 @@ powershell -Command "[Console]::CursorTop=%PROGRESSBACKTOLINE%"
631628
goto :EOF
632629

633630
:function_script_toast
634-
chcp 65001>NUL
631+
rem chcp 65001>NUL
635632
for /f "tokens=*" %%a in ('powershell -Command "(gc -LiteralPath '%HOME%Tools\ACHIVEMENTS\achievements.json' | ConvertFrom-Json).%TOASTNAME%.earned"') do set "AchivementEarned=%%a"
636633
if "%AchivementEarned%"=="False" (
637-
chcp 1252>NUL
634+
rem chcp 1252>NUL
638635
for /f "tokens=*" %%a in ('powershell -Command "(gc -LiteralPath '%HOME%Tools\ACHIVEMENTS\achievements.json' | ConvertFrom-Json).%TOASTNAME%.displayName"') do set "AchivementName=%%a"
639636
for /f "tokens=*" %%a in ('powershell -Command "(gc -LiteralPath '%HOME%Tools\ACHIVEMENTS\achievements.json' | ConvertFrom-Json).%TOASTNAME%.description"') do set "AchivementDescription=%%a"
640637
for /f "tokens=*" %%a in ('powershell -Command "(gc -LiteralPath '%HOME%Tools\ACHIVEMENTS\achievements.json' | ConvertFrom-Json).%TOASTNAME%.icon"') do set "AchivementImage=%HOME%Tools\ACHIVEMENTS\%%a"
@@ -647,7 +644,7 @@ goto :EOF
647644
:function_test_achievements_file
648645
echo.
649646
echo [ ] Showing achievements . . .
650-
chcp 65001>NUL
647+
rem chcp 65001>NUL
651648
set /a total=0
652649
for /f "tokens=1-9 delims= : usebackq" %%a in ("%FileDir%achievements.json") do if "%%a"==""name"" (set /a total+=1)
653650
setlocal enabledelayedexpansion

0 commit comments

Comments
 (0)