Exemplo n.º 1
0
        internal KeyValue GetAppInfo(uint appId)
        {
            KeyValue data       = null;
            var      stringData = string.Empty;

            // First try to get cached data
            try
            {
                stringData = playniteServices.GetSteamAppInfoData(appId);
            }
            catch (Exception e)
            {
                logger.Error(e, $"Failed to get Steam appinfo cache data {appId}.");
            }

            // If no cache then download on client and push to cache
            if (string.IsNullOrEmpty(stringData))
            {
                data = apiClient.GetProductInfo(appId).GetAwaiter().GetResult();
                logger.Debug($"Steam appinfo got from live server {appId}");

                try
                {
                    using (var str = new MemoryStream())
                    {
                        data.SaveToStream(str, false);
                        using (var reader = new StreamReader(str, Encoding.UTF8))
                        {
                            str.Seek(0, SeekOrigin.Begin);
                            stringData = reader.ReadToEnd();
                        }
                    }

                    playniteServices.PostSteamAppInfoData(appId, stringData);
                }
                catch (Exception e)
                {
                    logger.Error(e, $"Failed to post steam appinfo data to cache {appId}");
                }
            }
            else
            {
                logger.Debug($"Steam appinfo data got from cache {appId}");
            }

            if (data != null)
            {
                return(data);
            }
            else if (!string.IsNullOrEmpty(stringData))
            {
                return(KeyValue.LoadFromString(stringData));
            }

            return(null);
        }
Exemplo n.º 2
0
 internal KeyValue GetAppInfo(uint appId)
 {
     try
     {
         return(apiClient.GetProductInfo(appId).GetAwaiter().GetResult());
     }
     catch (Exception e) when(!Debugger.IsAttached)
     {
         logger.Error(e, $"Failed to get Steam appinfo {appId}");
         return(null);
     }
 }
Exemplo n.º 3
0
        public void GetProductInfoTest()
        {
            var data = SteamApiClient.GetProductInfo(214490).GetAwaiter().GetResult();

            Assert.IsTrue(!string.IsNullOrEmpty(data["common"]["name"].Value));
        }