示例#1
0
        public GogGameMetadata DownloadGameMetadata(string id, string storeUrl = null)
        {
            var metadata   = new GogGameMetadata();
            var gameDetail = WebApiClient.GetGameDetails(id);

            metadata.GameDetails = gameDetail;

            if (gameDetail != null)
            {
                if (gameDetail.links.product_card != @"https://www.gog.com/" && !string.IsNullOrEmpty(gameDetail.links.product_card))
                {
                    metadata.StoreDetails = WebApiClient.GetGameStoreData(gameDetail.links.product_card);
                }
                else if (!string.IsNullOrEmpty(storeUrl))
                {
                    metadata.StoreDetails = WebApiClient.GetGameStoreData(storeUrl);
                }

                var icon      = HttpDownloader.DownloadData("http:" + gameDetail.images.icon);
                var iconName  = Path.GetFileName(new Uri(gameDetail.images.icon).AbsolutePath);
                var image     = HttpDownloader.DownloadData("http:" + gameDetail.images.logo2x);
                var imageName = Path.GetFileName(new Uri(gameDetail.images.logo2x).AbsolutePath);

                metadata.Icon = new MetadataFile(
                    string.Format("images/gog/{0}/{1}", id, iconName),
                    iconName,
                    icon
                    );

                metadata.Image = new MetadataFile(
                    string.Format("images/gog/{0}/{1}", id, imageName),
                    imageName,
                    image
                    );

                metadata.BackgroundImage = "http:" + gameDetail.images.background;
            }

            return(metadata);
        }