From 23b3197a52183140829cd2edffeaf1bc28a0d0d8 Mon Sep 17 00:00:00 2001 From: ComputerElite <71177995+ComputerElite@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:59:48 +0200 Subject: [PATCH] Fix obb downloads on bs --- Oculus Downgrader/Program.cs | 73 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/Oculus Downgrader/Program.cs b/Oculus Downgrader/Program.cs index 5dfad75..a5e9ba8 100644 --- a/Oculus Downgrader/Program.cs +++ b/Oculus Downgrader/Program.cs @@ -43,7 +43,7 @@ static void Main(string[] args) { Logger.SetLogFile(AppDomain.CurrentDomain.BaseDirectory + "Log.log"); SetupExceptionHandlers(); - DowngradeManager.updater = new Updater("1.11.48", "https://github.com/ComputerElite/Oculus-downgrader", "Oculus Downgrader", Assembly.GetExecutingAssembly().Location); + DowngradeManager.updater = new Updater("1.11.49", "https://github.com/ComputerElite/Oculus-downgrader", "Oculus Downgrader", Assembly.GetExecutingAssembly().Location); Logger.LogRaw("\n\n"); Logger.Log("Starting Oculus Downgrader version " + DowngradeManager.updater.version); if (args.Length == 1 && args[0] == "--update") @@ -1609,36 +1609,59 @@ public void StartDownload(OculusBinary binary, string appId, string appName, boo } } catch(Exception e) { - Logger.Log("Couldn't get obbs. Trying to get from OculusDB next: " + e.ToString(), LoggingType.Warning); - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("Couldn't get obbs from Oculus. Unknown error. Trying with OculusDB now"); - try - { - DBVersion version = JsonSerializer.Deserialize(new WebClient().DownloadString("https://oculusdb.rui2015.me/api/v1/id/" + binary.id)); - - - - if (version.obbList != null) + Logger.Log("Couldn't get obbs via fallback. Trying to get from OculusDB next: " + e.ToString(), LoggingType.Warning); + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Couldn't get obbs from Oculus. Unknown error. Trying with OculusDB now"); + try { - List obbs = new List(); - foreach (OBBBinary obbBinary in version.obbList) + DBVersion version = JsonSerializer.Deserialize( + new WebClient().DownloadString("https://oculusdb.rui2015.me/api/v1/id/" + + binary.id)); + if (version.obbList != null) { - obbs.Add(new Obb {filename = obbBinary.file_name, bytes = obbBinary.sizeNumerical, id = obbBinary.id}); + List obbs = new List(); + foreach (OBBBinary obbBinary in version.obbList) + { + obbs.Add(new Obb {filename = obbBinary.file_name, bytes = obbBinary.sizeNumerical, id = obbBinary.id}); + } + GameDownloader.DownloadObbFiles(baseDirectory + "obbs" + Path.DirectorySeparatorChar, DecryptToken(), obbs); + } + else + { + Logger.Log("OBB List has 0 entries. Checking fallback oculus"); + Console.WriteLine("No obbs on OculusDB, checking fallback on Oculus"); + try + { + Data b = GraphQLClient.GetMoreBinaryDetails(binary.id); + if (b.data.node != null) + { + if (b.data.node.obb_binary == null) + { + Logger.Log("No obbs to download according to fallback"); + Console.WriteLine("No obbs to download"); + } + else + { + + List obbs = new List{new Obb {bytes = b.data.node.obb_binary.sizeNumerical, filename = b.data.node.obb_binary.file_name, id = b.data.node.obb_binary.id}}; + GameDownloader.DownloadObbFiles(baseDirectory + "obbs" + Path.DirectorySeparatorChar, DecryptToken(), obbs); + } + } + } + catch (Exception e2) + { + Logger.Log("Fallback failed, we'll just assume there are no obbs to download: " + e2); + Console.Write("Failed to get obbs from OculusDB and Oculus. Assuming there are no obbs to download."); + } } - GameDownloader.DownloadObbFiles(baseDirectory + "obbs" + Path.DirectorySeparatorChar, DecryptToken(), obbs); } - else + catch (Exception ex) { - Logger.Log("OBB List has 0 entries. Downloading nothing"); - Console.WriteLine("No obbs to download"); + Logger.Log("Request to OculusDB failed too: " + ex); + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Request to OculusDB and Oculus failed. Could not check if obbs are needed."); } - } - catch (Exception ex) - { - Logger.Log("Request to OculusDB failed too: " + ex); - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("Request to OculusDB and Oculus failed. Could not check if obbs are needed."); - } + } }