Skip to content

Commit

Permalink
Fix: Origin game import may fail on specific games #133
Browse files Browse the repository at this point in the history
  • Loading branch information
JosefNemec committed Oct 8, 2017
1 parent 38462e3 commit c4c68d1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions source/Playnite/Providers/Origin/OriginLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public System.Collections.Specialized.NameValueCollection ParseOriginManifest(st

public GameLocalDataResponse GetLocalManifest(string id, string packageName = null, bool useDataCache = false)
{
logger.Debug($"Gettings game manifest {id}");
var package = packageName;

if (string.IsNullOrEmpty(package))
Expand Down Expand Up @@ -154,7 +155,7 @@ public List<IGame> GetInstalledGames(bool useDataCache = false)
{
// Get game id by fixing file via adding : before integer part of the name
// for example OFB-EAST52017 converts to OFB-EAST:52017
var match = Regex.Match(gameId, @"(.*?)(\d+)");
var match = Regex.Match(gameId, @"^(.*?)(\d+)$");
if (!match.Success)
{
logger.Warn("Failed to get game id from file " + package);
Expand All @@ -170,8 +171,18 @@ public List<IGame> GetInstalledGames(bool useDataCache = false)
ProviderId = gameId
};

GameLocalDataResponse localData = GetLocalManifest(gameId, package, useDataCache);

GameLocalDataResponse localData = null;

try
{
localData = GetLocalManifest(gameId, package, useDataCache);
}
catch (Exception e) when (!PlayniteEnvironment.ThrowAllErrors)
{
logger.Error(e, $"Failed to get Origin manifest for a {gameId}, {package}");
continue;
}

if (localData.offerType != "Base Game" && localData.offerType != "DEMO")
{
continue;
Expand Down

0 comments on commit c4c68d1

Please sign in to comment.