示例#1
0
        // Override additional methods based on supported metadata fields.
        public override MetadataFile GetCoverImage()
        {
            var logger = LogManager.GetLogger();

            logger.Info("GetCoverImage");
            if (options.IsBackgroundDownload)
            {
                string gameUrl;
                if (options.GameData.Source != null && options.GameData.Source.ToString().ToLower() == "steam" && options.GameData.GameId != null)
                {
                    gameUrl = services.getCoverImageUrl(options.GameData.Name, convertPlayniteGameSourceToSGDBPlatformEnum(options.GameData.Source.ToString().ToLower()), options.GameData.GameId);
                }
                else
                {
                    gameUrl = services.getCoverImageUrl(options.GameData.Name);
                }
                if (gameUrl == "bad path")
                {
                    return(base.GetCoverImage());
                }
                else
                {
                    return(new MetadataFile(gameUrl));
                }
            }
            else
            {
                if (AvailableFields.Contains(MetadataField.Name))
                {
                    logger.Info("search Selection" + searchSelection);
                    if (searchSelection != null)
                    {
                        var     covers    = services.getCoverImages(searchSelection.Name);
                        dynamic selection = null;
                        if (covers != null)
                        {
                            selection = GetCoverManually(covers);
                        }
                        if (selection == null || selection.Path == "nopath")
                        {
                            return(base.GetCoverImage());
                        }
                        else
                        {
                            return(new MetadataFile(selection.Path));
                        }
                    }
                    else
                    {
                        return(base.GetCoverImage());
                    }
                }
                else
                {
                    return(base.GetCoverImage());
                }
            }
        }
        // Override additional methods based on supported metadata fields.
        public override MetadataFile GetCoverImage()
        {
            if (options.IsBackgroundDownload)
            {
                if (options.GameData.Source != null)
                {
                    return(new MetadataFile(services.getCoverImageUrl(options.GameData.Name, options.GameData.Source.ToString().ToLower(), options.GameData.GameId)));
                }
                else
                {
                    return(new MetadataFile(services.getCoverImageUrl(options.GameData.Name)));
                }
            }
            else
            {
                var gameList = new List <GenericItemOption>(services.getGameListSGDB(options.GameData.Name).Select(game => new GenericItemOption(game.name, game.id.ToString())));
                GetGame(gameList, "Cover");

                if (searchSelection != null)
                {
                    var covers    = services.getCoverImages(searchSelection.Name);
                    var selection = GetCoverManually(covers);
                    if (selection == null || selection.Path == "nopath")
                    {
                        return(base.GetCoverImage());
                    }
                    else
                    {
                        return(new MetadataFile(selection.Path));
                    }
                }
                else
                {
                    return(base.GetCoverImage());
                }
            }
        }