diff --git a/src/Depressurizer.Core/Helpers/DepressurizerPremium.cs b/src/Depressurizer.Core/Helpers/DepressurizerPremium.cs index 25608b26..f617e287 100644 --- a/src/Depressurizer.Core/Helpers/DepressurizerPremium.cs +++ b/src/Depressurizer.Core/Helpers/DepressurizerPremium.cs @@ -38,29 +38,12 @@ class DepressurizerPremiumResponse public int hltbMain { get; set; } } - #region Properties - - private static Logger Logger => Logger.Instance; - - #endregion - - public static AppType load(DatabaseEntry entry, string steamWebApi, string languageCode) + public static void load(DatabaseEntry entry, string steamWebApi, string languageCode) { - string url = string.Format("{0}/{1}?key={2}&language={3}", Settings.Instance.PremiumServer, entry.AppId, steamWebApi, languageCode); - - try - { - return load(entry, new Uri(url)); - } - catch (Exception e) - { - Logger.Error("Could not load Premium API ({0}) due to: {1}", url, e.ToString()); - } - - return AppType.Unknown; + load(entry, new Uri(string.Format("{0}/{1}?key={2}&language={3}", Settings.Instance.PremiumServer, entry.AppId, steamWebApi, languageCode))); } - public static AppType load(DatabaseEntry entry, Uri uri) + public static void load(DatabaseEntry entry, Uri uri) { HttpClient client = new HttpClient(); using (Stream s = client.GetStreamAsync(uri).Result) @@ -70,7 +53,7 @@ public static AppType load(DatabaseEntry entry, Uri uri) DepressurizerPremiumResponse response = new JsonSerializer().Deserialize(reader); if (!Enum.TryParse(response.appType, true, out AppType type) || type == AppType.Unknown) { - return AppType.Unknown; + return; } entry.Name = response.name; @@ -137,8 +120,6 @@ public static AppType load(DatabaseEntry entry, Uri uri) entry.LastStoreScrape = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); } - - return entry.AppType; } } } diff --git a/src/Depressurizer.Core/Models/DatabaseEntry.cs b/src/Depressurizer.Core/Models/DatabaseEntry.cs index df794616..463742ee 100644 --- a/src/Depressurizer.Core/Models/DatabaseEntry.cs +++ b/src/Depressurizer.Core/Models/DatabaseEntry.cs @@ -455,17 +455,21 @@ public void ScrapeStore(string steamWebApi, StoreLanguage storeLanguage) /// public void ScrapeStore(string steamWebApi, string languageCode) { - AppType result = AppType.Unknown; if (!string.IsNullOrWhiteSpace(Settings.Instance.PremiumServer)) { - result = DepressurizerPremium.load(this, steamWebApi, languageCode); + try + { + DepressurizerPremium.load(this, steamWebApi, languageCode); + return; + } + catch (Exception e) + { + Logger.Error("Could not load Premium API ({0}) due to: {1}. Failing over to Steam Store", AppId, e); + } } - if (result == AppType.Unknown) - { - result = ScrapeStoreHelper(languageCode); - SetTypeFromStoreScrape(result); - } + AppType result = ScrapeStoreHelper(languageCode); + SetTypeFromStoreScrape(result); } #endregion