public List <GoogleResult> GatherSearchResults(bool googleApiChoice)
        {
            var api = new GoogleSearch();

            var eilishResults = new List <GoogleResult>();
            var grandeResults = new List <GoogleResult>();
            var mendesResults = new List <GoogleResult>();

            if (googleApiChoice)
            {
                eilishResults = api.GetSearchResults("Billie Eilish - Therefore I am");
                if (eilishResults.Count > 0) //Prevent multiple dialog boxes from appearing
                {
                    grandeResults = api.GetSearchResults("Ariana Grande - Positions");
                    mendesResults = api.GetSearchResults("Shawn Mendes - Monster");
                }
            }
            else
            {
                eilishResults = api.GetGoogleApiResults("Billie Eilish - Therefore I am");
                grandeResults = api.GetGoogleApiResults("Ariana Grande - Positions");
                mendesResults = api.GetGoogleApiResults("Shawn Mendes - Monster");
            }

            MergedResults = eilishResults.Union(grandeResults).Union(mendesResults).ToList();

            return(MergedResults);
        }
Exemple #2
0
        public async Task<List<RemoteSearchResult>> Search(int[] siteNum, string searchTitle, DateTime? searchDate, CancellationToken cancellationToken)
        {
            var result = new List<RemoteSearchResult>();
            if (siteNum == null || string.IsNullOrEmpty(searchTitle))
            {
                return result;
            }

            var directURL = searchTitle.Replace(" ", "-", StringComparison.OrdinalIgnoreCase).ToLowerInvariant();
            if (!directURL.Contains("/", StringComparison.OrdinalIgnoreCase))
            {
                directURL = directURL.Replace("-", "/", 1, StringComparison.OrdinalIgnoreCase);
            }

            if (!int.TryParse(directURL.Split('/')[0], out _))
            {
                directURL = directURL.Replace("/", "-", 1, StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                directURL = directURL.Split('/')[1];
            }

            directURL = Helper.GetSearchSearchURL(siteNum) + directURL;
            var searchResultsURLs = new List<string>
            {
                directURL,
            };

            var searchResults = await GoogleSearch.GetSearchResults(searchTitle, siteNum, cancellationToken).ConfigureAwait(false);
            foreach (var searchResult in searchResults)
            {
                if (searchResult.Contains("/movies/", StringComparison.OrdinalIgnoreCase) && !searchResultsURLs.Contains(searchResult))
                {
                    searchResultsURLs.Add(searchResult);
                }
            }

            foreach (var url in searchResultsURLs)
            {
                var sceneURL = new Uri(url);
                var sceneID = new List<string> { Helper.Encode(sceneURL.AbsolutePath) };

                if (searchDate.HasValue)
                {
                    sceneID.Add(searchDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
                }

                var searchResult = await Helper.GetSearchResultsFromUpdate(this, siteNum, sceneID.ToArray(), searchDate, cancellationToken).ConfigureAwait(false);
                if (searchResult.Any())
                {
                    result.AddRange(searchResult);
                }
            }

            return result;
        }