JosefNemec / PlayniteExtensions

Extensions for Playnite game launcher and manager.
MIT License
174 stars 41 forks source link

Amazon Games Library imports games without a name #383

Closed darklinkpower closed 6 months ago

darklinkpower commented 6 months ago

Describe the bug Amazon Games Library imports games without a name. This only affects new installs because older ones will have already imported the games with names correctly.

Some findings:

image


Considering this, these are the options:

To Reproduce

  1. Update your library on a fresh install
darklinkpower commented 6 months ago

Considering that this will affect a lot of people as seen on reddit, if there is no quick solution, as a temporary measure I may suggest using the sku cleaned up for the name.

public List<GameMetadata> GetLibraryGames()
{
    var games = new List<GameMetadata>();
    var client = new AmazonAccountClient(this);
    var entitlements = client.GetAccountEntitlements().GetAwaiter().GetResult();
    const string gameSuffix = "_game";
    const string gamePreffix = "CDG ";
    foreach (var item in entitlements)
    {
        if (item.product.productLine == "Twitch:FuelEntitlement")
        {
            continue;
        }

        var name = item.product.title;
        if (name.IsNullOrEmpty())
        {
            var newName = item.product.sku;
            if (newName.EndsWith(gameSuffix))
            {
                newName = newName.Remove(newName.LastIndexOf(gameSuffix));
            }

            if (newName.StartsWith(gamePreffix))
            {
                newName = newName.Substring(gamePreffix.Length -1);
            }

            name = newName.Replace("_", " ").ToTileCase();
        }

        var game = new GameMetadata()
        {
            Source = new MetadataNameProperty("Amazon"),
            GameId = item.product.id,
            Name = name.RemoveTrademarks(),
            Platforms = new HashSet<MetadataProperty> { new MetadataSpecProperty("pc_windows") }
        };

        games.Add(game);
    }

    return games;
}

This change makes most names correct and if if coupled with PR https://github.com/JosefNemec/PlayniteExtensions/pull/382, clicking install could help to know the correct name of the games that still have issues.

JosefNemec commented 6 months ago

Not a fan of this workaround. Better check traffic from the plugin to see what new API endpoints they are now using.

darklinkpower commented 6 months ago

I just checked and Amazon has fixed this issue in the response.

image

Closing issue.