diff --git a/apps/PlayniteWebPlugin/src/Models/Game.cs b/apps/PlayniteWebPlugin/src/Models/Game.cs index c6723703..425331ab 100755 --- a/apps/PlayniteWebPlugin/src/Models/Game.cs +++ b/apps/PlayniteWebPlugin/src/Models/Game.cs @@ -3,7 +3,6 @@ using Playnite.SDK.Models; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; @@ -22,6 +21,7 @@ public class Game : IIdentifiable private readonly IEnumerable defaultPlatforms; private readonly GameSource defaultSource; private readonly ILogger logger = LogManager.GetLogger(); + private readonly IEnumerable playniteGames; [DontSerialize] public IEnumerable Releases => releases; @@ -41,7 +41,15 @@ public Game(IEnumerable playniteGames, IEnumerable { ".*Xbox.*" }; nintendoPlatformNames = new List { ".*Nintendo.*", ".*Switch.*", ".*Wii.*", ".*Game ?Cube.*" }; - releases = playniteGames.GroupBy(game => game.Source).SelectMany(GetReleases).ToList(); + + var gameBySource = playniteGames.GroupBy(game => game.Source); + if (gameBySource.Any(grouped => grouped.Key == null)) + { + logger.Warn($"Game {playniteGames.First().Name} has no source. These will be published with the source Emulator."); + } + + releases = gameBySource + .SelectMany(GetReleases).ToList(); using (MD5 md5 = MD5.Create()) { @@ -62,10 +70,8 @@ private IEnumerable GetReleases(IGrouping g.Roms.Any(r => r.Path.EndsWith("m3u"))) ?? groupedBySource.First(); } - catch(Exception error) - { - logger.Error(error, $"Failed to get game from source for game named ${this.Name}"); - } + catch + { } if (game == null) { @@ -84,7 +90,8 @@ private IEnumerable GetReleases(IGrouping IsMatchingPlatform(groupedBySource.Key, p)).Where(p => !publishedPlatforms.Any(pp => p.Id == pp.Id)).OrderBy(p => p, platformSorter).First(); } - catch { + catch + { } if (platform == null) { diff --git a/apps/PlayniteWebPlugin/src/PlayniteWeb.cs b/apps/PlayniteWebPlugin/src/PlayniteWeb.cs index 803993ac..21920e41 100755 --- a/apps/PlayniteWebPlugin/src/PlayniteWeb.cs +++ b/apps/PlayniteWebPlugin/src/PlayniteWeb.cs @@ -197,7 +197,14 @@ private IEnumerable SyncLibrary() var batchMessage = new BatchMessage(); - var games = PlayniteApi.Database.Games.GroupBy(game => game.Name).Select(groupedByName => new Models.Game(groupedByName, pcPlatforms, emulatorSource)).Where(g => !g.Id.Equals(Guid.Empty)).ToList(); + var groupedGames = PlayniteApi.Database.Games.GroupBy(game => game.Name); + var invalidGames = groupedGames.Where(groupedByName => groupedByName.Key == null).ToList(); + if (invalidGames.Any()) + { + logger.Warn($"Found {invalidGames.Count} games with no name. These games will not be published."); + } + + var games = groupedGames.Where(groupedByName => groupedByName.Key != null).Select(groupedByName => new Models.Game(groupedByName, pcPlatforms, emulatorSource)).Where(g => !g.Id.Equals(Guid.Empty)).ToList(); games.ForEach(game => { batchMessage.Messages.Add(new Message() { Topic = topicManager.GetPublishTopic(PublishTopics.Game(game.Id)), Payload = serializer.Serialize(game) });