Example #1
0
        private async void buttonParallel_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api = new AlloCineApi();

            api.TvSeriesGetInfoCompleted += api_TvSeriesGetInfoCompleted;

            textBox1.AppendText(
                "\r\n\r\n\r\n//Batch retrieve - The UI is responsive - main tread is NOT waiting, asynchronous AND Parallel calls");
            Parallel.For(200, 250,
                         async i => { await api.TvSeriesGetInfoAsync(i, ResponseProfiles.Large, new[] { "synopsis" }, null); });
        }
Example #2
0
        private async void buttonAsync_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api = new AlloCineApi();

            api.TvSeriesGetInfoCompleted += api_TvSeriesGetInfoCompleted;

            textBox1.AppendText("\r\n\r\n\r\n//Batch retrieve - The UI is responsive - main tread is NOT waiting, asynchronous calls, yet sequential");
            for (int i = 223; i >= 200; i--)
            {
                await api.TvSeriesGetInfoAsync(i, ResponseProfiles.Large, new[] { "synopsis" }, null);
            }
        }
Example #3
0
        private void buttonEvent_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api = new AlloCineApi();

            api.TvSeriesGetInfoCompleted += api_TvSeriesGetInfoCompleted;

            textBox1.AppendText("\r\n\r\n\r\n//Batch retrieve - The UI is freezing - main tread is waiting");
            for (int i = 223; i >= 200; i--)
            {
                api.TvSeriesGetInfo(i, ResponseProfiles.Large, new[] { "synopsis" }, null);
            }
        }
Example #4
0
        public override bool GetResults(string keywords, string imdbID, bool skipImages)
        {
            bool result = false;

            try
            {
                var api  = new AlloCineApi();
                var feed = api.Search(keywords);
                if (feed.Error == null)
                {
                    foreach (var movie in feed.MovieList)
                    {
                        if (FileManager.CancellationPending)
                        {
                            return(ResultsList.Count != 0);
                        }
                        try
                        {
                            string id            = movie.Code;
                            string originalTitle = movie.OriginalTitle;
                            string title         = movie.Title;
                            title = string.IsNullOrEmpty(title) ? originalTitle : title;
                            MovieInfo movieInfo  = GetMovieInfo(id);
                            string    posterPath = movie.Poster.Href;
                            string    imageUrl   = string.IsNullOrEmpty(posterPath) ? null : posterPath;

                            var movieItem = new ResultMovieItem(id, title, imageUrl, CollectorName);
                            movieItem.CollectorMovieUrl = id != null?GetMovieUrl(id) : null;

                            movieItem.MovieInfo = movieInfo;
                            ResultsList.Add(movieItem);
                            result = true;
                        }
                        catch (Exception ex)
                        {
                            Loggy.Logger.DebugException("Allocine iteration: ", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Loggy.Logger.DebugException("Allocine results: ", ex);
            }

            return(result);
        }
Example #5
0
        private void buttonVariousCalls_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            //"ah si j'etais riche" = 42346
            var api = new AlloCineApi();

            textBox1.AppendText("//Look for anything in Allocine that contains 'riche'");
            var alFeed = api.Search("riche", new[] { TypeFilters.Movie }, 8, 1);

            if (alFeed.Error != null)
            {
                textBox1.AppendText("\r\n" + alFeed.Error.Value);
            }
            else
            {
                foreach (var mov in alFeed.MovieList)
                {
                    textBox1.AppendText("\r\n" + mov.Code + "\t" + mov.OriginalTitle + "\t");
                }
            }

            textBox1.AppendText("\r\n\r\n\r\n//Retrieve the details of the Movie 'Ah si j'etais riche");
            var alMovie = api.MovieGetInfo(42346, ResponseProfiles.Large, new[] { TypeFilters.Movie, TypeFilters.News }, new[] { "synopsis" }, new[] { MediaFormat.Mpeg2 });

            if (alMovie.Error != null)
            {
                textBox1.AppendText("\r\n" + alMovie.Error.Value);
            }
            else
            {
                textBox1.AppendText("\r\n" + alMovie.Code + "\t" + alMovie.OriginalTitle + "\t" + alMovie.MovieType.Code);
            }

            textBox1.AppendText("\r\n\r\n\r\n//Retrieve the details about the TvSeries 'Lost'");
            var alTvSeries = api.TvSeriesGetInfo(223, ResponseProfiles.Large, new[] { "synopsis" }, null);

            if (alTvSeries.Error != null)
            {
                textBox1.AppendText("\r\n" + alTvSeries.Error.Value);
            }
            else
            {
                textBox1.AppendText("\r\n" + alTvSeries.Code + "\t" + alTvSeries.OriginalTitle + "\t" + alTvSeries.Title + "\t" + alTvSeries.OriginalBroadcast.DateStart);
            }
        }
Example #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api    = new AlloCineApi();
            var alFeed = api.MovieGetOnTheaterList(filters: new[] { MovieListFilters.NowShowing }, resultsPerPage: 10);

            if (alFeed.Error != null)
            {
                textBox1.AppendText("\r\n" + alFeed.Error.Value);
            }
            else
            {
                if (alFeed.MovieList != null)
                {
                    foreach (var movie in alFeed.MovieList)
                    {
                        textBox1.AppendText("\r\n" + movie.Code + "\t" + movie.Title + "\t");
                    }
                }
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api    = new AlloCineApi();
            var alFeed = api.TheaterGetList(theaterNameSearch: "normandy");

            if (alFeed.Error != null)
            {
                textBox1.AppendText("\r\n" + alFeed.Error.Value);
            }
            else
            {
                textBox1.AppendText("\r\n" + alFeed.Updated);
                if (alFeed.TheaterList != null)
                {
                    foreach (var thea in alFeed.TheaterList)
                    {
                        textBox1.AppendText("\r\n" + thea.Code + "\t" + thea.Name + "\t");
                    }
                }
            }
        }
Example #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            var api    = new AlloCineApi();
            var alFeed = api.TheaterGetShowtimeList(date: DateTime.Now, postalCode: 45000);

            if (alFeed.Error != null)
            {
                textBox1.AppendText("\r\n" + alFeed.Error.Value);
            }
            else
            {
                textBox1.AppendText("\r\n" + alFeed.Updated);
                if (alFeed.TheaterShowtimeList != null)
                {
                    foreach (var thea in alFeed.TheaterShowtimeList)
                    {
                        textBox1.AppendText("\r\n" + thea.Place.Theater.Name);
                        foreach (var showTime in thea.MovieShowtimeList)
                        {
                            textBox1.AppendText("\r\n\t" + showTime.OnShow.Movie.Title + "\t" + showTime.Version.Value + "\t");

                            foreach (var day in showTime.ScrList)
                            {
                                textBox1.AppendText("\r\n\t\t" + day.D.ToString("yyyy-MM-dd") + "\t");
                                foreach (var time in day.T)
                                {
                                    textBox1.AppendText("\r\n\t\t\t" + time.Value + "\t");
                                }
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        protected override MovieInfo GetMovieInfo(string input)
        {
            // input is the id of the movie
            var _result = new MovieInfo();

            if (string.IsNullOrEmpty(input))
            {
                return(_result);
            }
            var id = -1;

            if (!int.TryParse(input, out id))
            {
                return(_result);
            }

            var api   = new AlloCineApi();
            var movie = api.MovieGetInfo(id);

            if (movie.Error != null)
            {
                return(_result);
            }
            try
            {
                _result.OriginalTitle = movie.OriginalTitle;

                string _title = movie.Title;
                _result.Name = string.IsNullOrEmpty(_title) ? _result.OriginalTitle : _title;

                _result.Year = movie.ProductionYear;

                if (movie.Release != null)
                {
                    _result.ReleaseDate = movie.Release.ReleaseDate;
                }

                if (movie.Trailer != null)
                {
                    _result.Trailer = movie.Trailer.Href;
                }

                _result.Countries = movie.NationalityList.Select(x => x.Value).ToList();

                _result.Genre = movie.GenreList.Select(x => x.Value).ToList();

                //_result.Cast = movie.CastMemberList.Take(Math.Max(movie.CastMemberList.Count, 5)).Select(x => x.Person.Name).ToList();
                _result.Cast = movie.CastingShort.Actors.Split(',').ToTrimmedList();

                _result.Director = movie.CastingShort.Directors.Split(',').ToTrimmedList();

                int _minutes = 0;
                Int32.TryParse(movie.Runtime, out _minutes);
                _result.Runtime = Math.Abs(_minutes / 60).ToString();

                if (movie.Statistics != null)
                {
                    string _r = movie.Statistics.UserRating;
                    if (!string.IsNullOrEmpty(_r))
                    {
                        _result.Rating = _r;
                        _result.Rating = (_result.dRating * 2).ToString();
                    }
                }
                _result.Overview = movie.SynopsisShort;
                if (string.IsNullOrEmpty(_result.Overview))
                {
                    _result.Overview = movie.Synopsis;
                }
                else
                {
                    _result.Comments = movie.Synopsis;
                }

                // backdrops
                movie.MediaList
                .Where(x => x.Type != null && x.Type.Code == "31006" && x.Thumbnail != null)
                .Select(x => x.Thumbnail.Href).ToList()
                .ForEach(x =>
                {
                    var _bi = new BackdropItem(input, null, this.CollectorName, x, x);
                    BackdropsList.Add(_bi);
                });
            }
            catch (Exception ex)
            {
                Loggy.Logger.DebugException("Allocine: ", ex);
            }
            return(_result);
        }