public static List <YoutubeSearchItem> GetYoutubeSearchResults(string searchTerm, bool searchShortVideos)
        {
            var uri = string.Empty;

            if (searchShortVideos)
            {
                uri = string.Format(youtubeSearchTemplateShort, Uri.EscapeDataString(searchTerm));
            }
            else
            {
                uri = string.Format(youtubeSearchTemplate, Uri.EscapeDataString(searchTerm));
            }

            var downloadedString = HttpDownloader.DownloadStringAsync(uri).GetAwaiter().GetResult();

            if (!downloadedString.IsNullOrEmpty())
            {
                var embeddedJsonMatch = Regex.Match(downloadedString, youtubeResponseRegexStr);
                if (embeddedJsonMatch.Success)
                {
                    var response    = JsonConvert.DeserializeObject <YoutubeEmbeddedResponse>(embeddedJsonMatch.Groups[1].Value);
                    var itemSection = response.Contents.TwoColumnSearchResultsRenderer.PrimaryContents.SectionListRenderer.Contents[0].ItemSectionRenderer.Contents;
                    if (itemSection.Count < 13)
                    {
                        return(itemSection.Where(x => x.VideoRenderer != null).Select(x => ItemToYoutubeSearchObj(x)).ToList());
                    }
                    else
                    {
                        return(itemSection.Where(x => x.VideoRenderer != null).Take(14).Select(x => ItemToYoutubeSearchObj(x)).ToList());
                    }
                }
            }

            return(new List <YoutubeSearchItem>());
        }
        public static List <StoreSearchResult> GetSteamSearchResults(string searchTerm)
        {
            var results       = new List <StoreSearchResult>();
            var searchPageSrc = HttpDownloader.DownloadStringAsync(string.Format(steamGameSearchUrl, searchTerm)).GetAwaiter().GetResult();

            if (!string.IsNullOrEmpty(searchPageSrc))
            {
                var parser     = new HtmlParser();
                var searchPage = parser.Parse(searchPageSrc);
                foreach (var gameElem in searchPage.QuerySelectorAll(".search_result_row"))
                {
                    var title       = gameElem.QuerySelector(".title").InnerHtml;
                    var releaseDate = gameElem.QuerySelector(".search_released").InnerHtml;
                    if (gameElem.HasAttribute("data-ds-packageid"))
                    {
                        continue;
                    }

                    var gameId = gameElem.GetAttribute("data-ds-appid");
                    results.Add(new StoreSearchResult
                    {
                        Name        = HttpUtility.HtmlDecode(title),
                        Description = HttpUtility.HtmlDecode(releaseDate),
                        GameId      = gameId
                    });
                }
            }

            logger.Debug($"Obtained {results.Count} games from Steam search term {searchTerm}");
            return(results);
        }
        public static SteamAppDetails GetSteamAppDetails(string steamId)
        {
            var url = string.Format(@"https://store.steampowered.com/api/appdetails?appids={0}", steamId);
            var downloadedString = HttpDownloader.DownloadStringAsync(url).GetAwaiter().GetResult();

            if (!string.IsNullOrEmpty(downloadedString))
            {
                var parsedData = Serialization.FromJson <Dictionary <string, SteamAppDetails> >(downloadedString);
                if (parsedData.Keys?.Any() == true)
                {
                    var response = parsedData[parsedData.Keys.First()];
                    if (response.success == true && response.data != null)
                    {
                        return(response);
                    }
                }
            }

            return(null);
        }