示例#1
0
        private static string GetWeek(string buildId)
        {
            var url       = $"https://top10.netflix.com/_next/data/{buildId}/united-states.json";
            var getParams = HttpRequester.GetAsync <NetflixMovieDto>(new Uri(url)).Result;

            return(getParams?.PageProps?.PathParams?.Week);
        }
示例#2
0
        private static string GetBuildId()
        {
            var doc = HttpRequester.GetHtmlDocumentAsync(baseUrl + "/films").Result;

            var startIndex = doc.DocumentNode.InnerHtml.IndexOf("buildId");
            var lastIndex  = doc.DocumentNode.InnerHtml.IndexOf(",", startIndex);

            return((startIndex > 0 && lastIndex > 0) ?
                   doc.DocumentNode.InnerHtml.Substring(startIndex, lastIndex - startIndex).Replace("\"", "").Replace(":", "").Replace("buildId", "")
                : null);
        }
示例#3
0
        public static async Task <IEnumerable <ImdbMovieInfo> > GetImdbMoviesInfoAsync(string movieTitle)
        {
            var imdbMoviesInfo = new List <ImdbMovieInfo>();

            try
            {
                var searchUrl = $"https://www.imdb.com/find?q={movieTitle}&s=tt&ttype=ft&exact=true&ref_=fn_tt_ex";
                var doc       = await HttpRequester.GetHtmlDocumentAsync(searchUrl);

                var searchResultList = doc.DocumentNode.SelectNodes("//tr[contains(@class, 'findResult')]/td[@class='result_text']");

                if (searchResultList == null)
                {
                    return(null);
                }

                foreach (var node in searchResultList)
                {
                    doc = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(node.InnerHtml);

                    var originalTitle = doc.DocumentNode.SelectSingleNode("/i")?.InnerText.Replace("\"", "") ?? doc.DocumentNode.SelectSingleNode("/a")?.InnerText;
                    var frenchTitle   = doc.DocumentNode.SelectSingleNode("/a")?.InnerText;
                    var year          = doc.DocumentNode.InnerText.Replace(originalTitle, "").Replace(frenchTitle, "").Replace("aka", "").Replace("(", "").Replace(")", "").Replace("\"", "").Trim();

                    if (originalTitle.Contains(movieTitle, StringComparison.OrdinalIgnoreCase))
                    {
                        imdbMoviesInfo.Add(new ImdbMovieInfo()
                        {
                            ImdbCode      = doc.DocumentNode.SelectSingleNode("/a")?.Attributes["href"].Value.Split("/")[2],
                            OriginalTitle = WebUtility.HtmlDecode(originalTitle),
                            FrenchTitle   = WebUtility.HtmlDecode(frenchTitle),
                            Year          = year
                        });
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(imdbMoviesInfo);
        }
示例#4
0
        public async static Task <string> GetFrenchMovieTitleAsync(string imdbCode)
        {
            if (string.IsNullOrEmpty(imdbCode))
            {
                return(null);
            }

            var searchUrl = $"https://www.imdb.com/title/{imdbCode}";

            try
            {
                var doc = await HttpRequester.GetHtmlDocumentAsync(searchUrl);

                var frenchTitle = doc?.DocumentNode.SelectSingleNode("//h1[contains(@class, 'TitleHeader__TitleText')]")?.InnerText;

                return(string.IsNullOrEmpty(frenchTitle) ? null : WebUtility.HtmlDecode(frenchTitle));
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#5
0
        private static async Task <string[]> GetMoviesNamesAsync(string url)
        {
            var topMovies = await HttpRequester.GetAsync <NetflixMovieDto>(new Uri(url));

            return(topMovies.PageProps.Data.WeeklyTopTen.Select(m => m.Name).ToArray());
        }