2525#include < storefront/epic.h>
2626#include < storefront/achievements.h>
2727
28+ #include < json/json.hpp>
29+
2830#include " EOS/eos_auth.h"
2931
3032#ifdef __SK_SUBSYSTEM__
@@ -1660,17 +1662,13 @@ SK::EOS::AppName (void)
16601662
16611663 if (config.platform .equivalent_steam_app == -1 )
16621664 {
1663- std::wstring search_string =
1664- SK_Network_MakeEscapeSequencedURL (SK_Platform_RemoveTrademarkSymbols (SK_UTF8ToWideChar (szDisplayName)));
1665-
16661665 std::wstring url =
16671666 SK_FormatStringW (
1668- LR"( https://www.pcgamingwiki .com/w/index.php?search=%ws )" , search_string. c_str ()
1667+ LR"( https://gamesdb.gog .com/platforms/epic/external_releases/%hs )" , szEpicApp
16691668 );
16701669
1671- if (! search_string.empty ())
16721670 SK_Network_EnqueueDownload (
1673- sk_download_request_s (L" pcgw_entry.html " , url.data (),
1671+ sk_download_request_s (L" api.php " , url.data (),
16741672 []( const std::vector <uint8_t >&& data,
16751673 const std::wstring_view file )
16761674 {
@@ -1679,17 +1677,47 @@ SK::EOS::AppName (void)
16791677
16801678 std::ignore = file;
16811679
1682- auto steamdb_appid =
1683- StrStrIA ((const char *)data.data (), " https://steamdb.info/app/" );
1680+ static SK_LazyGlobal <nlohmann::json> json;
16841681
1685- if (steamdb_appid != nullptr )
1686- {
1687- if (1 != sscanf (steamdb_appid, " https://steamdb.info/app/%d/" , &config.platform .equivalent_steam_app ))
1682+ int32_t appid = 0 ;
1683+
1684+ try {
1685+ json.get () = std::move
1686+ ( nlohmann::json::parse
1687+ ( data.cbegin (),
1688+ data.cend (),
1689+ nullptr ,
1690+ true ) );
1691+
1692+ const auto & game_ =
1693+ json.get ()[" game" ];
1694+
1695+ for (const auto & release : game_ [" releases" ])
16881696 {
1689- config.platform .equivalent_steam_app = 0 ;
1697+ if (release.count (" platform_id" ))
1698+ {
1699+ if (release [" platform_id" ].get <std::string>() == " steam" )
1700+ {
1701+ if (release.count (" external_id" ))
1702+ {
1703+ if (1 == sscanf (release [" external_id" ].get <std::string> ().c_str (), " %d" , &appid))
1704+ {
1705+ config.platform .equivalent_steam_app = appid;
1706+ break ;
1707+ }
1708+ }
1709+ }
1710+ }
16901711 }
16911712 }
16921713
1714+ catch (const std::exception& e)
1715+ {
1716+ SK_LOGi0 (L" JSON Parse Failure: %hs" , e.what ());
1717+ }
1718+
1719+ config.utility .save_async ();
1720+
16931721 return true ;
16941722 } ),
16951723 true
0 commit comments