Exemplo n.º 1
0
        private void frmInformation_Load(object sender, EventArgs e)
        {
            //Gets well, the info
            List<String> countries = new List<String>();
            myPoster = API.GetMovieImages(movieID, "en");
            myMovie = API.GetMovieInfo(movieID);
            txtTitle.Text = myMovie.title;
            txtYear.Text = myMovie.release_date.ToString();

            //Don't know if there works for all movies......
            try
            {
                picPoster.ImageLocation = "http://image.tmdb.org/t/p/w185" + myPoster.posters[0].file_path;
            }
            catch (ArgumentException)
            {
                picPoster.ImageLocation = "noposter.jpg";
            }

            richTextBox1.Text = myMovie.overview;
            lstActors.DataSource = API.GetMovieCast(movieID).cast;

            //Craziness to just get the rating but makes sense
            foreach (ReleaseCountry elements in API.GetMovieReleases(movieID).countries)
            {
                countries.Add(elements.certification);
                txtRating.Text = countries[0];
            }
            //Crew members, really I only wanted director but this works, the more info the better I guess ^_^
            foreach (Crew members in API.GetMovieCast(movieID).crew)
            {
                lstCrew.Items.Add(members.job + ": " + members.name);
            }
        }
Exemplo n.º 2
0
        private static DbMovieInfo GetMovieInformation(Tmdb api, TmdbMovie movieNode, string language)
        {
            LogMyFilms.Debug("GetMovieInformation() - language = '" + (language ?? "") + "'");

              if (movieNode == null) return null;
              DbMovieInfo movie = new DbMovieInfo();

              try
              {
            TmdbMovie m = api.GetMovieInfo(movieNode.id);

            movie.Identifier = m.id.ToString();
            movie.ImdbId = m.imdb_id;
            movie.Name = m.original_title;
            movie.TranslatedTitle = m.title;
            movie.AlternativeTitle = m.original_title;
            DateTime date;
            if (DateTime.TryParse(m.release_date, out date))
              movie.Year = date.Year;
            movie.DetailsUrl = m.homepage;
            movie.Summary = m.overview;
            movie.Score = (float)Math.Round(m.vote_average, 1);
            // movie.Certification = "";
            foreach (SpokenLanguage spokenLanguage in m.spoken_languages)
            {
              movie.Languages.Add(spokenLanguage.name);
            }
            movie.Runtime = m.runtime;

            TmdbMovieCast p = api.GetMovieCast(movieNode.id);

            foreach (Cast cast in p.cast)
            {
              string name = cast.name;
              string character = cast.character;
              DbPersonInfo personToAdd = new DbPersonInfo { Id = cast.id.ToString(), Name = cast.name, DetailsUrl = cast.profile_path };
              movie.Persons.Add(personToAdd);

              if (character.Length > 0) name = name + " (" + character + ")";
              movie.Actors.Add(name);
            }

            foreach (Crew crew in p.crew)
            {
              DbPersonInfo personToAdd = new DbPersonInfo { Id = crew.id.ToString(), Name = crew.name, DetailsUrl = crew.profile_path };
              movie.Persons.Add(personToAdd);
              switch (crew.department)
              {
            case "Production":
              movie.Producers.Add(crew.name);
              break;
            case "Directing":
              movie.Directors.Add(crew.name);
              break;
            case "Writing":
              movie.Writers.Add(crew.name);
              break;
            case "Sound":
            case "Camera":
              break;
              }
            }

            foreach (Cast cast in p.cast)
            {
              string name = cast.name;
              string character = cast.character;
              string thumb = cast.profile_path;
              string job = cast.character;
              string id = cast.id.ToString();
              string url = cast.profile_path;
              var personToAdd = new DbPersonInfo { Id = id, Name = name, DetailsUrl = url, Job = job };
              movie.Persons.Add(personToAdd);
              switch (job)
              {
            case "Producer":
              movie.Producers.Add(name);
              break;
            case "Director":
              movie.Directors.Add(name);
              break;
            case "Actor":
              if (character.Length > 0)
                name = name + " (" + character + ")";
              movie.Actors.Add(name);
              break;
            case "Screenplay":
              movie.Writers.Add(name);
              break;
              }
            }
            foreach (ProductionCountry country in m.production_countries)
            {
              movie.Country.Add(country.name);
            }
            foreach (MovieGenre genre in m.genres)
            {
              movie.Country.Add(genre.name);
            }

            TmdbConfiguration tmdbConf = api.GetConfiguration();

            // load posters
            TmdbMovieImages movieImages = api.GetMovieImages(movieNode.id, language);
            LogMyFilms.Debug("GetMovieInformation() - language = '" + (language ?? "") + "', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");

            foreach (Poster poster in movieImages.posters)
            {
              movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
            }
            foreach (Backdrop backdrop in movieImages.backdrops)
            {
              movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
            }

            // english posters and backdrops
            movieImages = api.GetMovieImages(movieNode.id, "en"); // fallback to en language images
            LogMyFilms.Debug("GetMovieInformation() - language = 'en', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");
            if (movie.Posters.Count < 5)
            {
              foreach (Poster poster in movieImages.posters)
              {
            movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
              }
            }
            foreach (Backdrop backdrop in movieImages.backdrops)
            {
              movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
            }

            // non language posters and backdrops
            movieImages = api.GetMovieImages(movieNode.id, null); // fallback to non language images
            LogMyFilms.Debug("GetMovieInformation() - language = 'null', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");
            if (movie.Posters.Count < 11)
            {
              foreach (Poster poster in movieImages.posters)
              {
            movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
              }
            }

            if (movie.Backdrops.Count < 11) // only load foreign backdrops, if not anough are availabole
            {
              foreach (Backdrop backdrop in movieImages.backdrops)
              {
            movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
              }
            }
            LogMyFilms.Debug("GetMovieInformation() - Totals added - Posters: '" + movie.Posters.Count + "', Backdrops: '" + movie.Backdrops.Count + "'");
              }
              catch (Exception ex)
              {
            LogMyFilms.Debug(ex.StackTrace);
              }
              return movie;
        }
Exemplo n.º 3
0
        public static List<MFFanart> GetAll(int SeriesID, bool availableOnly)
        {
            lock (cache)
              {
            if (SeriesID < 0) return new List<MFFanart>();

            if (cache == null || !cache.ContainsKey(SeriesID))
            {
              try
              {
            // make sure the table is created - create a dummy object
            MFFanart dummy = new MFFanart();

            // retrieve all fields in the table
            // ToDo: Get TMDB fanarts here ...
            var movies = new List<TmdbMovie>();
            var movie = new TmdbMovie();
            var results = movie.backdrop_path;
            if (results.Length > 0)
            {
              var ourFanart = new List<MFFanart>(results.Length);

              for (int index = 0; index < results.Length; index++)
              {
                ourFanart.Add(new MFFanart());
                // ourFanart[index].Read(ref results, index);
              }
              if (cache == null) cache = new Dictionary<int, List<MFFanart>>();
              cache.Add(SeriesID, ourFanart);
            }
            LogMyFilms.Debug("Found " + results.Length + " Fanart from TMDB");

              }
              catch (Exception ex)
              {
            LogMyFilms.Error("Error in MFFanart.Get (" + ex.Message + ").");
              }
            }
            List<MFFanart> faForSeries = null;
            if (cache != null && cache.TryGetValue(SeriesID, out faForSeries))
              return faForSeries;
            return new List<MFFanart>();
              }
        }
Exemplo n.º 4
0
 private static void PrintMovie(TmdbMovie result)
 {
     Console.WriteLine("Id: " + result.id);
     Console.WriteLine("Title: " + result.title);
     Console.WriteLine("BackdropPath: " + result.backdrop_path);
     Console.WriteLine("Budget: " + result.budget);
     Console.WriteLine("Genres: " + result.genres.JoinStrings(g => g.name, ","));
     Console.WriteLine("Homepage: " + result.homepage);
     Console.WriteLine("Imdb: " + result.imdb_id);
     Console.WriteLine("Overview: " + result.overview);
     Console.WriteLine("Popularity: " + result.popularity);
     Console.WriteLine("PosterPath: " + result.poster_path);
     Console.WriteLine("Companies: " + result.production_companies.JoinStrings(p => p.name, ","));
     Console.WriteLine("Countries: " + result.production_countries.JoinStrings(p => p.name, ","));
     Console.WriteLine("ReleaseDate: " + result.release_date);
     Console.WriteLine("Revenue: " + result.revenue);
     Console.WriteLine("Runtime: " + result.runtime);
     Console.WriteLine("Title: " + result.spoken_languages.JoinStrings(s => s.name, ","));
     Console.WriteLine("Tagline: " + result.tagline);
     Console.WriteLine("VoteAverage: " + result.vote_average);
     Console.WriteLine("VoteCount: " + result.vote_count);
     Console.WriteLine("Adult: " + result.adult);
     Console.WriteLine("OriginalTitle: " + result.original_title);
 }