Exemplo n.º 1
0
        private async Task <string> GetToken()
        {
            string token = String.Empty;

            ConcurrentDictionary <string, string> headers = new ConcurrentDictionary <string, string>();

            headers.TryAdd("Authorization", "Basic bXV2aS5pb3NAaW5qaW4uY29tOmRLOHdqX1ludU4kRSFLNEs=");

            var result = await _http.Execute(o =>
            {
                o.Host    = new Uri("https://apiprod.muvicinemas.com/user/v1/token");
                o.Method  = HttpMethod.Post;
                o.Headers = headers;
            });

            if (result.IsSuccess)
            {
                dynamic json = JObject.Parse(result.Response);
                token = json.accessToken.Value;
            }
            else
            {
                throw new Exception();
            }

            return(token);
        }
Exemplo n.º 2
0
        // Get all cinemas
        private async Task <ParseResult <List <Parse.Cinema> > > GetCinemasAsync()
        {
            var result = await _http.Execute(o =>
            {
                o.Host   = new Uri("https://ksa.voxcinemas.com/cinemas");
                o.Method = HttpMethod.Get;
            });

            if (result.IsSuccess)
            {
                var document = new HtmlParser().ParseDocument(result.Response);

                var elements = document.QuerySelectorAll("a").Where(x => x.HasAttribute("href"))
                               .Where(x => x.GetAttribute("href").Contains(@"/showtimes/"));

                var tasks = elements.Select(i => Task.Run(() => ParseCinema(i))).ToArray();
                Task.WaitAll(tasks);

                List <Parse.Cinema> cinemas = new List <Parse.Cinema>();

                foreach (var action in tasks)
                {
                    cinemas.Add(await action);
                }

                return(new ParseResult <List <Parse.Cinema> >(Result.Success)
                {
                    Data = cinemas
                });
            }

            return(new ParseResult <List <Parse.Cinema> >(Result.Error));
        }
Exemplo n.º 3
0
        private async Task <ParseResult <List <Movie> > > GetMoviesAsync()
        {
            ConcurrentDictionary <string, string> headers = new ConcurrentDictionary <string, string>();

            headers.TryAdd("ContentType", "application/x-www-form-urlencoded");
            headers.TryAdd("Accept-Encoding", "gzip, deflate, br");
            headers.TryAdd("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6,pl;q=0.5");
            var result = await _http.Execute(o =>
            {
                o.Host    = new Uri("https://apiksa.empirecinemas.com.sa/GetAllCinemasSch");
                o.Method  = HttpMethod.Post;
                o.Headers = headers;
                o.Body    = @"{""Latitude"":10,""Longitude"":10,""CinemaType"":""normal"",""LanguageID"":2,""CountryID"":230}";
            });

            if (result.IsSuccess)
            {
                List <Parse.Movie> movies = new List <Parse.Movie>();
                dynamic            json   = JObject.Parse(result.Response);
                var arr = json.Data;
                foreach (var c_movie in arr)
                {
                    string movie_id   = c_movie.MovieID;
                    Movie  temp_movie = movies.FirstOrDefault(x => x.ExternalId == movie_id);
                    if (temp_movie == null)
                    {
                        Movie movie = new Movie();
                        movie.Title      = c_movie.Title;
                        movie.ExternalId = c_movie.MovieID;
                        Session session = new Session();
                        session.Format = c_movie.Format;
                        session.Url    = $"https://empirecinemas.com.sa/checkout/{c_movie.MovieID}/{c_movie.SchID}/1";
                        string date = c_movie.ShowDate + " " + c_movie.ShowTime;
                        session.CinemaId = c_movie.CinemaID;
                        session.MovieId  = c_movie.MovieID;
                        session.ShowTime = GetParsedDate(date);
                        movie.Sessions.Add(session);
                        movies.Add(movie);
                    }
                    else
                    {
                        Session session = new Session();
                        session.Format = c_movie.Format;
                        session.Url    = $"https://empirecinemas.com.sa/checkout/{c_movie.MovieID}/{c_movie.SchID}/1";
                        string date = c_movie.ShowDate + " " + c_movie.ShowTime;
                        session.CinemaId = c_movie.CinemaID;
                        session.MovieId  = movie_id;
                        session.ShowTime = GetParsedDate(date);
                        movies.First(x => x.ExternalId == movie_id).Sessions.Add(session);
                    }
                }
                return(new ParseResult <List <Movie> >(Result.Success)
                {
                    Data = movies
                });
            }
            return(new ParseResult <List <Movie> >(Result.Error));
        }
Exemplo n.º 4
0
        private async Task <ParseResult <Data> > GetDataAsync(int days)
        {
            ConcurrentDictionary <string, string> headers = new ConcurrentDictionary <string, string>();

            headers.TryAdd("ContentType", "application/x-www-form-urlencoded");
            headers.TryAdd("Accept-Encoding", "gzip, deflate, br");
            headers.TryAdd("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6,pl;q=0.5");
            ConcurrentDictionary <string, string> parameters = new ConcurrentDictionary <string, string>();

            parameters.TryAdd("movieid", "");
            parameters.TryAdd("cinemaid", "");
            parameters.TryAdd("date", DateTime.Now.AddDays(days).ToString("yyyy-MM-dd"));
            parameters.TryAdd("experience", "");

            var result = await _http.Execute(o =>
            {
                o.Host       = new Uri("https://uae.novocinemas.com/showtimes/GetCinemaShowTimes");
                o.Method     = HttpMethod.Post;
                o.Headers    = headers;
                o.Parameters = parameters;
            });

            if (result.IsSuccess)
            {
                List <Parse.Movie>  movies  = new List <Movie>();
                List <Parse.Cinema> cinemas = new List <Parse.Cinema>();
                dynamic             json    = JArray.Parse(result.Response);
                foreach (var item in json)
                {
                    Parse.Cinema cinema = new Cinema()
                    {
                        ExternalId = item.CinemaId,
                        Name       = item.CinemaName
                    };
                    cinemas.Add(cinema);
                    List <Parse.Movie> c_movies = new List <Movie>();
                    foreach (var c_movie in item.movieDetails)
                    {
                        Parse.Movie movie = new Movie();
                        movie.ExternalId = c_movie.VistaMovieId;
                        movie.Title      = c_movie.MovieName;
                        movie.Url        = @$ "https://uae.novocinemas.com/movie/details/{c_movie.VistaMovieId}";
                        foreach (var c_languge in c_movie.LanguageList)
                        {
                            List <Parse.Session> sessions = new List <Session>();
                            foreach (var c_session in c_languge.showtimelist)
                            {
                                Parse.Session session = new Session();
                                session.Format   = c_session.ExperienceName;
                                session.ShowTime = c_session.SessionShowTime;
                                session.CinemaId = cinema.ExternalId.ToString();
                                session.MovieId  = movie.ExternalId.ToString();
                                sessions.Add(session);
                            }
                            if (sessions.Count != 0)
                            {
                                movie.Sessions.AddRange(sessions);
                            }
                        }
                        if (movie.Sessions.Count != 0)
                        {
                            c_movies.Add(movie);
                        }
                    }
                    movies.AddRange(c_movies);
                }
                return(new ParseResult <Parse.Data>(Result.Success)
                {
                    Data = new Data()
                    {
                        Cinemas = cinemas,
                        Movies = movies
                    }
                });
            }
            return(new ParseResult <Parse.Data>(Result.Error));
        }
Exemplo n.º 5
0
        public async Task <ParseResult <Parse.Data> > GetMoviesByDateAsync(DateTime date, List <Cinema> cinemas, List <Movie> movies_proto)
        {
            List <Movie> movies = new List <Movie>();

            movies.AddRange(movies_proto);
            string param = "";

            param = $"{date.Year}-{date.Month}-{date.Day}";
            ConcurrentDictionary <string, string> headers = new ConcurrentDictionary <string, string>();

            headers.TryAdd("ContentType", "application/json");
            headers.TryAdd("Cookie", "cookieLanguageCode=en-US; _gcl_au=1.1.1238722976.1602705939; _fbp=fb.1.1602705939926.1048953155; _gid=GA1.2.445262349.1603531359; moe_uuid=56694985-c80f-499b-b8ee-353d2ba58144; movieDetails=qeoEzVnzBc-6cYMbYWwS4scp_uWZetsLEfEwEONYBHu6Ug3EcLkPOkkIJRxNIl21LoXAHMoiLl-K2GFvWFxLoLetERKNJ9mg2n5nJuGQnCTm4cLcKFW7kZ4wKrzk7QcgU5mbqjSflnb4_PeFk656nOlvLWaS7p8iFkS-zpiG8sRM94UJOeX_RAJBHeSg-2ca0iolX65I08aDzQXISNe834N45rFvnlXKnczOqHQxCJvkiScCXPEMudUt0mZ50_zT4mA6cD08aIHg-Hc-kaOI0Sg3RjPFVqt3tsn14JDZoCeu0PFyc7VLVr79jwvPn6r--qKRLudWoNJO5aJNQv_2smOTfz0_ZUF7RxCpwQ8geT_vx7XKrH_0c9o23bsv5jiokSdBTwrkHbiwYk4ITrwCkmhHtkHeJVYs3sKRoroNevKirCwY585fkH59_SHcrTA8RUc6JMj2ixXsezJeeszlngooxw8GHDdH5o1ASeVsvKFbOcHeWPCNjA5XgQZvyIFKoHDQjZXS5N-Tu0-G_wNFmL4aQBnOdvIbFw0_DfbDHLaFTfeJY9NuTSyhoZJP8mOaebaIZMokCCFINDhBcgerB1CcAhP5SUnKdXkeLbBADZskqh_sU-f8QzGsesP1dOa1tNQmRDwenGOKb3MDof1EkQCYenShYRMmJC7VY1SBqmlM8n0aOMycbc1kcoLME98Z7F4BGJUKMMxa4PB1XU_e3OIEZYobFZ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dmEWMrPK5h2jNpOwjtfbwxGxFFSp6txscWxaMDbo9mGSJeE6e27tb2WvX5YSNi68fccyo3PZLTF-H8ZixtfoTn4g1nL1JGA55-oXDCjq95ivHCJfGSdXmV99vayz6I_wp5O_JtUWqNz7kdy0Pf_SsPVbZS7bHyZ5WPNbHJLBWDCQRmaq_l8Z5Wq_QSwv4obJ14EiI6gO4QyDgrNISZkkg3fwMSDiTDKMoMVLi0xsXF7xJnGUoaH2Dvehd22ZFaozIpZB94wHIE0elFyUtXCLVqeNo-gyAUcIOdORSk7XqfCElKheoGzI4Op1kfF3rouycJtpjGcztaWblB-nY52VmuwOpsfRatMz60tA06ZSAQK3FzQmbJNPi_LyWagUDokf3pvAxfz1LJgnxe7cn55cPBW8IWOuHoxAPIZ7HePAxFtttra0C2F9_CB6SI11M9QSweb-rSgZwU_xc5wFsEb2CIWj3SgE4gbO3WxnbCJcXTd8RK_7yG9OzGhvLk-uzz7W6g1KXVFjb8mCWoxgGMK97SL_CjmkTQGcgwup24JzVo_IGkxVNJQyUDhfndbHoxLZstyyfKlrGxtEq6lS8JMPOGXaUEQK3yn_wkykYX0yrtmgM99sTXzHcpK1916aI_ev7q5X2KUjdDofJfybNKEVcSE8n-hSP8b652vCeFdkY7P4cXN29; _ga_EJRWLKGJNW=GS1.1.1603541129.5.1.1603542988.47; _ga=GA1.2.87188470.1602703684");
            var result = await _http.Execute(o =>
            {
                o.Host    = new Uri("https://www.amccinemas.com/showtime/getallmovies");
                o.Method  = HttpMethod.Post;
                o.Headers = headers;
                o.Body    = @"{""url"":""showdate=" + param + @"""}";
            });

            if (result.IsSuccess)
            {
                var config = Configuration.Default;

                //Create a new context for evaluating webpages with the given config
                var context = BrowsingContext.New(config);

                //Just get the DOM representation
                var document = await context.OpenAsync(req => req.Content(result.Response));

                //Select all sessions of films
                var listofgroups = document.All.Where(m => m.ClassName == "amc-time-list");

                foreach (var item in listofgroups)
                {
                    string cinemaName = item.GetAttribute("data-cinemaname");
                    string movieName  = item.GetAttribute("data-moviename");
                    var    childdoc   = await context.OpenAsync(req => req.Content(item.InnerHtml));

                    var            listofsessions = childdoc.QuerySelectorAll("span").Where(m => m.ClassName == "amc-time");
                    List <Session> sessions       = new List <Session>();
                    foreach (var c_session in listofsessions)
                    {
                        Session  session     = new Session();
                        DateTime sessionDate = new DateTime(date.Year, date.Month, date.Day);
                        string   time        = c_session.InnerHtml;
                        time = time.Remove(0, 1);
                        time = time.Remove(time.Length - 1, 1);
                        time = "10/10/2000 " + time;
                        DateTime parsedTime = DateTime.ParseExact(time, "M/d/yyyy h:mm tt", CultureInfo.InvariantCulture);
                        sessionDate      = sessionDate.AddHours(parsedTime.Hour);
                        sessionDate      = sessionDate.AddMinutes(parsedTime.Minute);
                        session.ShowTime = sessionDate;
                        session.CinemaId = cinemas.First(x => x.Name == cinemaName).ExternalId;
                        sessions.Add(session);
                    }

                    movies.First(x => x.Title == movieName).Sessions.AddRange(sessions);
                }
                return(new ParseResult <Data>(Result.Success)
                {
                    Data = new Data()
                    {
                        Movies = movies
                    }
                });
            }

            return(new ParseResult <Parse.Data>(Result.Error));
        }