Beispiel #1
0
        public static void InitializeApis()
        {
            var serviceCodes = new Dictionary <string, string>();

            try
            {
                using (StreamReader sr = new StreamReader("servicecodes.key"))
                {
                    while (!sr.EndOfStream)
                    {
                        String line  = sr.ReadLine();
                        var    split = line.Split('=');
                        serviceCodes.Add(split[0], split[1]);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            RequestChecker.TmDbReadyOrWait();
            TmdbApi = new Tmdb(serviceCodes["Tmdb"], "de");

            RequestChecker.TomatoReadyOrWait();
            TomatoApi = new Tomato(serviceCodes["Tomato"]);
        }
Beispiel #2
0
        public TmdbMovie GetTmdbDetails(TVTProgramme movie)
        {
            if (!movie.TmdbId.HasValue)
            {
                throw new Exception();
            }

            if (ImdbMovies.ContainsKey(movie.TmdbId.Value))
            {
                return(ImdbMovies[movie.TmdbId.Value]);
            }
            else
            {
                RequestChecker.TmDbReadyOrWait();
                var tmdbMovieDetails = ServiceApi.TmdbApi.GetMovieInfo(movie.TmdbId.Value, "de");
                ImdbMovies.Add(movie.TmdbId.Value, tmdbMovieDetails);
                return(tmdbMovieDetails);
            }
        }
Beispiel #3
0
        private void RegisterPerson(TVTPerson person, int id)
        {
            RequestChecker.TmDbReadyOrWait();
            var personInfo = ServiceApi.TmdbApi.GetPersonInfo(id);

            person.ImdbId   = personInfo.imdb_id;
            person.ImageUrl = @"https://d3gtl9l2a4fn1j.cloudfront.net/t/p/original" + personInfo.profile_path;
            int parseValue;

            if (int.TryParse(personInfo.birthday, out parseValue))
            {
                person.Birthday = parseValue;
            }

            if (int.TryParse(personInfo.deathday, out parseValue))
            {
                person.Deathday = parseValue;
            }
            //person.PlaceOfBirth = personInfo.place_of_birth;
            person.Country = GetCountryCode(GetCountry(personInfo.place_of_birth));
            //person.MovieRegistrations++;
        }
        public void LoadDetailsFromTmDB(MovieImporter importer, TVTProgramme movie, MovieResult tmdbMovie)
        {
            movie.TmdbId  = tmdbMovie.id;
            movie.TitleDE = tmdbMovie.title;
            movie.TitleEN = tmdbMovie.original_title;

            var tmdbMovieDetails = importer.GetTmdbDetails(movie);

            movie.ImdbId = tmdbMovieDetails.imdb_id;

            var tomatoeDetails = importer.GetTomatoeDetails(movie);

            movie.RottenTomatoesId = tomatoeDetails.RottenTomatoesId;



            RequestChecker.TmDbReadyOrWait();
            var tmdbMovieCast = ServiceApi.TmdbApi.GetMovieCast(tmdbMovie.id);



            movie.TitleDE                 = tmdbMovie.title;
            movie.TitleEN                 = tmdbMovieDetails.original_title;
            movie.DescriptionMovieDB      = tmdbMovieDetails.tagline;
            movie.TmdbId                  = tmdbMovie.id;
            movie.ImdbId                  = tmdbMovieDetails.imdb_id;
            movie.ImageUrl                = @"https://d3gtl9l2a4fn1j.cloudfront.net/t/p/original" + tmdbMovieDetails.backdrop_path;
            movie.MovieAdditional.Budget  = tmdbMovieDetails.budget;
            movie.MovieAdditional.Revenue = tmdbMovieDetails.revenue;


            var castCounter = 1;

            movie.Staff = new IndexingList <TVTStaff>();
            foreach (var cast in tmdbMovieCast.cast)
            {
                if (castCounter > 3)
                {
                    break;
                }

                var person = importer.RegisterActor(cast);
                if (person != null)
                {
                    movie.Staff.Add(new TVTStaff(person, TVTPersonFunction.Actor));
                }

                castCounter++;
            }

            foreach (var crew in tmdbMovieCast.crew)
            {
                if (crew.department != "Directing")
                {
                    break;
                }

                var person = importer.RegisterDirector(crew);
                movie.Staff.Add(new TVTStaff(person, TVTPersonFunction.Director));

                break;
            }

            foreach (var currCountry in tmdbMovieDetails.production_countries)
            {
                if (movie.Country == null)
                {
                    movie.Country = currCountry.iso_3166_1;
                }
                else
                {
                    movie.Country = currCountry.iso_3166_1 + ", " + currCountry.iso_3166_1;
                }
            }

            movie.Year = DateTime.Parse(tmdbMovieDetails.release_date).Year;

            var genreChecker = new GenreChecker();

            movie.MainGenre = genreChecker.GetGenre(tmdbMovieDetails.genres);
            //TODO: Subgenre

            var runtime = tmdbMovieDetails.runtime;

            if (runtime == 0)
            {
                if (tomatoeDetails != null && tomatoeDetails.Runtime.HasValue)
                {
                    runtime = tomatoeDetails.Runtime.Value;
                }
                else
                {
                    runtime = 120;                     //Dann 2 Blocks
                }
            }

            if (runtime < 85)
            {
                movie.Blocks = 1;
            }
            else if (runtime < 145)
            {
                movie.Blocks = 2;
            }
            else if (runtime < 205)
            {
                movie.Blocks = 3;
            }
            else if (runtime < 265)
            {
                movie.Blocks = 4;
            }
            else
            {
                movie.Blocks = 5;
            }

            //priceRate = 10;
            //criticRate = 11;
            //speedRate = 12;
            //boxOfficeRate = 13;
        }
Beispiel #5
0
        public void Start()
        {
            var fillMovies = new FillMovieExtended();

            List <MovieResult> movieExport = new List <MovieResult>();

            ServiceApi.InitializeApis();

            //for ( var year = 1954; year <= 1955; year++ )
            for (var year = 1954; year <= 1959; year++)
            //for ( var year = 1920; year <= 2013; year++ ) //Kein Film vor 1920 gefunden
            {
                if (_shouldStop)
                {
                    break;
                }

                Console.WriteLine("Import year '{0}'", year);

                var maxpage         = 1;
                var movieCollection = new List <MovieResult>();

                for (var page = 1; page <= maxpage; page++)
                {
                    Console.WriteLine("Import movies '{0}'", page);

                    RequestChecker.TmDbReadyOrWait();
                    var movieList = ServiceApi.TmdbApi.DiscoverMovie(page, "DE", true, null, year, 10, 2, "DE", "A");

                    movieCollection.AddRange(movieList.results);

                    maxpage = movieList.total_pages;
                }
                var sortedList = movieCollection.OrderByDescending(x => x.popularity);

                if (year < 1950)
                {
                    movieExport.AddRange(sortedList.Take(3));
                }
                else if (year < 1965)
                {
                    movieExport.AddRange(sortedList.Take(5));
                }
                else if (year < 1980)
                {
                    movieExport.AddRange(sortedList.Take(8));
                }
                else if (year < 1990)
                {
                    movieExport.AddRange(sortedList.Take(12));
                }
                else
                {
                    movieExport.AddRange(sortedList.Take(25));
                }
            }



            var resultList = GenerateTVTMovies(movieExport);

            foreach (var entry in resultList)
            {
                Console.WriteLine("Add result '{0}'", entry.TitleDE);
                MovieStatistics.Add(entry.Year, entry.MovieAdditional.Budget, entry.MovieAdditional.Revenue);
            }

            foreach (var entry in resultList)
            {
                Console.WriteLine("Calc rating '{0}'", entry.TitleDE);
                if (!_shouldStop)
                {
                    fillMovies.calcRating(this, entry);
                }
                Database.AddProgramme(entry);
            }

            Result = resultList;

            if (FinishEvent != null)
            {
                FinishEvent(this, new EventArgs());
            }
        }