diff --git a/source/Playnite/Metadata/MetadataDownloader.cs b/source/Playnite/Metadata/MetadataDownloader.cs index 311bc4848..f4f9c3a40 100644 --- a/source/Playnite/Metadata/MetadataDownloader.cs +++ b/source/Playnite/Metadata/MetadataDownloader.cs @@ -65,7 +65,16 @@ private GameMetadata ProcessDownload(Game game, ref GameMetadata data) { if (data == null) { - data = GetMetadataDownloader(game.PluginId)?.GetMetadata(game); + var downloader = GetMetadataDownloader(game.PluginId); + try + { + data = downloader?.GetMetadata(game); + } + catch (Exception e) when (!PlayniteEnvironment.ThrowAllErrors) + { + logger.Error(e, $"Failed to download metadat from plugin downloader."); + data = null; + } } return data; diff --git a/source/Plugins/GogLibrary/GOGMetadataProvider.cs b/source/Plugins/GogLibrary/GOGMetadataProvider.cs index 48af59060..d3147e5ce 100644 --- a/source/Plugins/GogLibrary/GOGMetadataProvider.cs +++ b/source/Plugins/GogLibrary/GOGMetadataProvider.cs @@ -109,17 +109,16 @@ internal GogGameMetadata UpdateGameWithMetadata(Game game) if (metadata.StoreDetails != null) { - game.Genres = new ComparableList(metadata.StoreDetails.genres.Select(a => a.name)); - game.Developers = new ComparableList() { metadata.StoreDetails.developer.name }; - game.Publishers = new ComparableList() { metadata.StoreDetails.publisher.name }; - game.CommunityScore = metadata.StoreDetails.rating != 0 ? metadata.StoreDetails.rating * 2 : (int?)null; + game.Genres = new ComparableList(metadata.StoreDetails.genres?.Select(a => a.name)); + game.Tags = new ComparableList(metadata.StoreDetails.tags?.Select(a => a.name)); + game.Developers = new ComparableList(metadata.StoreDetails.developers.Select(a => a.name)); + game.Publishers = new ComparableList() { metadata.StoreDetails.publisher }; var cultInfo = new CultureInfo("en-US", false).TextInfo; - game.Tags = new ComparableList(metadata.StoreDetails.features?.Select(a => cultInfo.ToTitleCase(a.title))); - if (game.ReleaseDate == null && metadata.StoreDetails.releaseDate != null) + if (game.ReleaseDate == null && metadata.StoreDetails.globalReleaseDate != null) { - game.ReleaseDate = DateTimeOffset.FromUnixTimeSeconds(metadata.StoreDetails.releaseDate.Value).DateTime; + game.ReleaseDate = metadata.StoreDetails.globalReleaseDate; } } diff --git a/source/Plugins/GogLibrary/Models/StorePageResult.cs b/source/Plugins/GogLibrary/Models/StorePageResult.cs index 21a08402f..7afaafc87 100644 --- a/source/Plugins/GogLibrary/Models/StorePageResult.cs +++ b/source/Plugins/GogLibrary/Models/StorePageResult.cs @@ -10,12 +10,6 @@ public class StorePageResult { public class ProductDetails { - public class Feature - { - public string title; - public string slug; - } - public class SluggedName { public string name; @@ -23,14 +17,13 @@ public class SluggedName } public List genres; - public List features; - public SluggedName publisher; - public SluggedName developer; - public int? releaseDate; - public int id; - public int rating; + public List tags; + public string publisher; + public List developers; + public DateTime? globalReleaseDate; + public string id; } - public ProductDetails gameProductData; + public ProductDetails cardProduct; } } diff --git a/source/Plugins/GogLibrary/Services/GogApiClient.cs b/source/Plugins/GogLibrary/Services/GogApiClient.cs index 6c291780c..47a9ae90f 100644 --- a/source/Plugins/GogLibrary/Services/GogApiClient.cs +++ b/source/Plugins/GogLibrary/Services/GogApiClient.cs @@ -40,24 +40,37 @@ public StorePageResult.ProductDetails GetGameStoreData(string gameUrl) } } + var dataStarted = false; + var stringData = string.Empty; foreach (var line in data) { var trimmed = line.TrimStart(); - if (line.TrimStart().StartsWith("var gogData")) + if (line.TrimStart().StartsWith("window.productcardData")) { - var stringData = trimmed.Substring(14).TrimEnd(';'); - var desData = JsonConvert.DeserializeObject(stringData); + dataStarted = true; + stringData = trimmed.Substring(25).TrimEnd(';'); + continue; + } - if (desData.gameProductData == null) + if (line.TrimStart().StartsWith("window.activeFeatures")) + { + var desData = JsonConvert.DeserializeObject(stringData); + if (desData.cardProduct == null) { return null; } - return desData.gameProductData; + return desData.cardProduct; } - } - throw new Exception("Failed to get store data from page, no data found. " + gameUrl); + if (dataStarted) + { + stringData += trimmed; + } + } + + logger.Warn("Failed to get store data from page, no data found. " + gameUrl); + return null; } public ProductApiDetail GetGameDetails(string id)