Exemplo n.º 1
0
        private static void FetchConfig(TMDbClient client)
        {
            FileInfo configXml = new FileInfo("config.xml");

            Console.WriteLine("Config file: " + configXml.FullName + ", Exists: " + configXml.Exists);

            if (configXml.Exists && configXml.LastWriteTimeUtc >= DateTime.UtcNow.AddHours(-1))
            {
                Console.WriteLine("Using stored config");
                string xml = File.ReadAllText(configXml.FullName, Encoding.Unicode);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);

                client.SetConfig(Serializer.Deserialize<TMDbConfig>(xmlDoc));
            }
            else
            {
                Console.WriteLine("Getting new config");
                client.GetConfig();

                Console.WriteLine("Storing config");
                XmlDocument xmlDoc = Serializer.Serialize(client.Config);
                File.WriteAllText(configXml.FullName, xmlDoc.OuterXml, Encoding.Unicode);
            }

            Spacer();
        }
Exemplo n.º 2
0
        private static void FetchImagesExample(TMDbClient client)
        {
            const int movieId = 76338; // Thor: The Dark World (2013)

            // In the call below, we're fetching the wanted movie from TMDb, but we're also doing something else.
            // We're requesting additional data, in this case: Images. This means that the Movie property "Images" will be populated (else it will be null).
            // We could combine these properties, requesting even more information in one go:
            //      client.GetMovie(movieId, MovieMethods.Images);
            //      client.GetMovie(movieId, MovieMethods.Images | MovieMethods.Releases);
            //      client.GetMovie(movieId, MovieMethods.Images | MovieMethods.Trailers | MovieMethods.Translations);
            //
            // .. and so on..
            //
            // Note: Each method normally corresponds to a property on the resulting object. If you haven't requested the information, the property will most likely be null.

            // Also note, that while we could have used 'client.GetMovieImages()' - it was better to do it like this because we also wanted the Title of the movie.
            Movie movie = client.GetMovie(movieId, MovieMethods.Images);

            Console.WriteLine("Fetching images for '" + movie.Title + "'");

            // Images come in two forms, each dispayed below
            Console.WriteLine("Displaying Backdrops");
            ProcessImages(client, movie.Images.Backdrops.Take(3), client.Config.Images.BackdropSizes);
            Console.WriteLine();

            Console.WriteLine("Displaying Posters");
            ProcessImages(client, movie.Images.Posters.Take(3), client.Config.Images.PosterSizes);
            Console.WriteLine();

            Spacer();
        }
Exemplo n.º 3
0
        public TestConfig(bool useSsl = false)
        {
            if (APIKey.Length == 0)
                throw new ConfigurationException("You need to configure the API Key before running any tests. Look at the TestConfig class.");

            Client = new TMDbClient(APIKey, useSsl);
        }
Exemplo n.º 4
0
        public static Task<TvShowUpdate> GetUpdate(int id, DateTime? lastUpdate = null, Language language = Language.English) {
            return Task.Run(() => {
                var client = new TMDbClient(ApiKey);

                var episodes = new List<TvShowEpisodeInfo>();
                var updateDate = DateTime.Now;
                var show = client.GetTvShow(id, language: GetLanguage(language));
                if (show == null) return null;

                foreach (var seasonTmp in show.Seasons) {
                    if (seasonTmp.SeasonNumber == 0) continue;

                    var season = client.GetTvSeason(show.Id, seasonTmp.SeasonNumber);
                    if (season == null) continue;

                    foreach (var episode in season.Episodes) {
                        var ad = episode.AirDate;
                        DateTime? airDate;
                        if (ad.Year < 1896) airDate = null;
                        else
                            airDate = new DateTime(ad.Year, ad.Month, ad.Day, 20, 0, 0, DateTimeKind.Utc);
                        episodes.Add(new TvShowEpisodeInfo(season.SeasonNumber, episode.EpisodeNumber, episode.Name, airDate, episode.Overview));
                    }
                }

                return new TvShowUpdate(updateDate, show.InProduction, show.Status, episodes);
            });
        }
Exemplo n.º 5
0
 public Task<ExternalIds> GetExternalIds(string imdbId) {
     return Task.Run(() => {
         var client = new TMDbClient(ApiKey);
         var tvShow = client.Find(FindExternalSource.Imdb, imdbId).TvResults.FirstOrDefault();
         return tvShow != null ? client.GetTvShowExternalIds(tvShow.Id) : null;
     });
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initialize a new instance of MovieService class
 /// </summary>
 public MovieService()
 {
     TmdbClient = new TMDbClient(Constants.TmDbClientId)
     {
         MaxRetryCount = 10
     };
 }
Exemplo n.º 7
0
 private TvShowRepo()
 {
     _tmdbClient = new TMDbClient(Settings.TMDB_API_KEY);
     _tmdbClient.GetConfig();
     _strikeClient = new Strike();
     _jsonStorage = new JsonStorage();
 }
Exemplo n.º 8
0
        private static void FetchMovieExample(TMDbClient client)
        {
            string query = "Thor";

            // This example shows the fetching of a movie.
            // Say the user searches for "Thor" in order to find "Thor: The Dark World" or "Thor"
            SearchContainer<SearchMovie> results = client.SearchMovie(query);

            // The results is a list, currently on page 1 because we didn't specify any page.
            Console.WriteLine("Searched for movies: '" + query + "', found " + results.TotalResults + " results in " +
                              results.TotalPages + " pages");

            // Let's iterate the first few hits
            foreach (SearchMovie result in results.Results.Take(3))
            {
                // Print out each hit
                Console.WriteLine(result.Id + ": " + result.Title);
                Console.WriteLine("\t Original Title: " + result.OriginalTitle);
                Console.WriteLine("\t Release date  : " + result.ReleaseDate);
                Console.WriteLine("\t Popularity    : " + result.Popularity);
                Console.WriteLine("\t Vote Average  : " + result.VoteAverage);
                Console.WriteLine("\t Vote Count    : " + result.VoteCount);
                Console.WriteLine();
                Console.WriteLine("\t Backdrop Path : " + result.BackdropPath);
                Console.WriteLine("\t Poster Path   : " + result.PosterPath);

                Console.WriteLine();
            }

            Spacer();
        }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MovieService()
 {
     TmdbClient = new TMDbClient(Constants.TmDbClientId)
     {
         MaxRetryCount = 10,
         RetryWaitTimeInSeconds = 1
     };
 }
Exemplo n.º 10
0
 public TMDb()
 {
     try {
         client = new TMDbClient(API_KEY);
         client.GetConfig();
         //client.MaxRetryCount = 15;
     } catch(Exception) { }
 }
Exemplo n.º 11
0
 public Netflix_ContentVM()
 {
   NFGenreSelectedIndex = 0;
   NFMovieSelectedIndex = 0;
   client = new TMDbClient("ecaa9ae8c8346269b53c80e2a61aa0ea");
   client.GetConfig();
   Messenger.Default.Register<string>(this, "LoadStatus", successfulLoad);
   NetflixUpdater NFU = new NetflixUpdater(); //NetflixUpdater checks for xml file and loads or updates if older than 7 days      
 }
Exemplo n.º 12
0
        public TMDbManager()
        {
            TMDbClient = new TMDbClient(ConfigurationManager.AppSettings["TheMovieDB"]);
            MongoManager = new MongoDBManager();

            TMDbClient.GetConfig();
            TMDbConfig config = TMDbClient.Config;
            ImageBase = config.Images.BaseUrl + config.Images.PosterSizes.Where(o => o == "w342").First();
            Client = new TMDbClient(ConfigurationManager.AppSettings["TheMovieDB"]);
        }
Exemplo n.º 13
0
        public void ClientRateLimitTest()
        {
            const int tomorrowLand = 158852;
            TMDbClient client = new TMDbClient(TestConfig.APIKey);
            client.ThrowErrorOnExeedingMaxCalls = true;

            for (int i = 0; i < 100; i++)
            {
                client.GetMovie(tomorrowLand);
            }

            Assert.Fail();
        }
Exemplo n.º 14
0
        public void ClientConstructorUrlTest()
        {
            TMDbClient clientA = new TMDbClient(TestConfig.APIKey, false, "http://api.themoviedb.org");
            clientA.GetConfig();

            TMDbClient clientB = new TMDbClient(TestConfig.APIKey, true, "http://api.themoviedb.org");
            clientB.GetConfig();

            TMDbClient clientC = new TMDbClient(TestConfig.APIKey, false, "https://api.themoviedb.org");
            clientC.GetConfig();

            TMDbClient clientD = new TMDbClient(TestConfig.APIKey, true, "https://api.themoviedb.org");
            clientD.GetConfig();
        }
Exemplo n.º 15
0
 //=============================================================
 //    Public static methods
 //=============================================================
 /// <summary>
 /// Checks if TMDB API key is valid.
 /// </summary>
 /// <param name="key">TMDB API key.</param>
 /// <returns>True if API key is valid, false - otherwise.</returns>
 public static bool IsKeyValid(string key)
 {
     if (string.IsNullOrEmpty(key)) return false;
     try
     {
         var client = new TMDbClient(key);
         client.AuthenticationRequestAutenticationToken();
         return true;
     }
     catch (UnauthorizedAccessException)
     {
         return false;
     }
 }
Exemplo n.º 16
0
        // This code is to get Movies from THE Movie Database (http://www.themoviedb.org)
        public static MovieModel getSingleFromTMDB(string title)
        {
            // Year
            int year = DateTime.Now.Year;

            MovieModel expectedMovie = new MovieModel();
            TMDbClient client = new TMDbClient("34c356b1eb1a362f5a3b958a9e94a113");
            SearchContainer<SearchMovie> results = client.SearchMovie(title);

            if(results.Results.Count> 0)
            {
                try
                {
                    int id = results.Results[0].Id;
                    Movie movie = client.GetMovie(id);
                    if (movie.OriginalLanguage.Equals("hi")) return null;
                    List<Genre> genres = movie.Genres;
                    var credits = client.GetMovieCredits(id);
                    List<string> credit = getStringFromCrewList(credits);

                    expectedMovie.Title = title;
                    expectedMovie.Year = movie.ReleaseDate.Value.Year.ToString();
                    expectedMovie.Released = movie.ReleaseDate.Value.Date.ToString();
                    expectedMovie.Runtime = movie.Runtime.ToString() + " Minutes";
                    expectedMovie.Genre = getStringFromGenereList(movie.Genres);

                    expectedMovie.Actors = credit[0].ToString();

                    expectedMovie.Director = credit[1].ToString();

                    expectedMovie.Writer = credit[2].ToString();

                    expectedMovie.Plot = movie.Overview;
                    expectedMovie.Language = movie.OriginalLanguage;
                    if(movie.ProductionCountries.Count>0) expectedMovie.Country = movie.ProductionCountries[0].Name;
                    expectedMovie.Poster = Constants.POSTER_LINK_HOST_PATH + movie.PosterPath;
                    expectedMovie.imdbRating = movie.VoteAverage.ToString();
                    expectedMovie.imdbVotes = movie.VoteCount.ToString();
                    expectedMovie.imdbID = movie.ImdbId.ToString();
                    expectedMovie.Showtype = "2D";
                    return expectedMovie;
                }
                catch (Exception e)
                {
                    return null;
                }
            }
            else return null;
        }
Exemplo n.º 17
0
        //=============================================================
        //    Public constructors
        //=============================================================
        /// <summary>
        /// Creates instance of this class.
        /// </summary>
        /// <param name="key">TMDB API key.</param>
        /// <exception cref="System.ArgumentException">Thrown when provided key is invalid.</exception>
        public Database(string key)
        {
            if (!IsKeyValid(key))
            {
                throw new ArgumentException("Invalid key.", "key");
            }

            // Initialization.
            _client = new TMDbClient(key);
            _progress = new SearchProgress();
            _seriesProgress = new SearchProgress();

            // Setting up current state.
            CurrentState = State.Idle;
            Reset();
        }
Exemplo n.º 18
0
 public EPG_Control_V3(string SourceDirectory)
 {
   this.sourceDirectory = SourceDirectory;
   currentTime = DateTime.Now;
   lastTime = DateTime.Now.AddHours(4);
   incrementalTime = new System.TimeSpan(0, 30, 0);
   epg_Data = new EPG_Program_Channel();
   epg_Times = new EPG_Time();
   epg_SelectedItem = new EPG_SelectedItem();
   tvdbHandler = new TvdbHandler(new XmlCacheProvider("C:\\test"), "572328F18DC4374A");
   tvdbHandler.InitCache();
   client = new TMDbClient("ecaa9ae8c8346269b53c80e2a61aa0ea");
   client.GetConfig();
   epg_ChannelIndex = 0;
   epg_ProgramIndex = 0;
 }
Exemplo n.º 19
0
        //Retrieve TMDB info with a TMDBNum
        public Models.Movie ReturnMovieInfoFromTMDB(int tmdbNum)
        {
            TMDbClient client = new TMDbClient("1fee8f2397ff73412985de2bb825f020");

            Movie movie = client.GetMovie(tmdbNum);

            Models.Movie movieInfo = new Models.Movie();
            movieInfo.MovieTitle = movie.Title;
            movieInfo.MovieTMDBNum = movie.Id;
            movieInfo.MpaaRating = movie.Releases.Countries.FirstOrDefault(m => m.Iso_3166_1 == "US").Certification;
            movieInfo.ReleaseDate = movie.ReleaseDate.Value;
            movieInfo.Synopsis = movie.Overview;
            movieInfo.Duration = movie.Runtime.Value;
            movieInfo.PosterUrl = "https://image.tmdb.org/t/p/original/" + movie.Images.Posters[0].FilePath;

            foreach (var g in movie.Genres)
            {
                movieInfo.Genres.Add(g.Name);
            }

            movieInfo.Director.DirectorName = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Name;
            movieInfo.Director.DirectorTMDBNum = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Id;
            movieInfo.Studio.StudioName = movie.ProductionCompanies[0].Name;
            movieInfo.Studio.StudioTMDBNum = movie.ProductionCompanies[0].Id;

            foreach (var t in movie.AlternativeTitles.Titles)
            {
                if (t.Iso_3166_1 == "US")
                {
                    movieInfo.MovieAliases.Add(t.Title);
                }
            }

            for (int i = 0; i < 15; i++)
            {
                Actor newActor = new Actor();
                newActor.ActorName = movie.Credits.Cast[i].Name;
                newActor.ActorTMDBNum = movie.Credits.Cast[i].Id;
                movieInfo.MovieActors.Add(newActor);
            }

            return movieInfo;
        }
Exemplo n.º 20
0
        public MainController()
        {
            Client = new TMDbClient(APIKEY);

            // this is just a temporary fix
            try
            {
                HttpContext HttpContext = System.Web.HttpContext.Current;

                SessionUserId = HttpContext.Session["UserId"].ToString();
                SessionUserEmail = HttpContext.Session["Email"].ToString();

                ViewBag.UserId = SessionUserId;
                ViewBag.UserEmail = SessionUserEmail;
            }
            catch (NullReferenceException e)
            {
                FormsAuthentication.SignOut();
            }
        }
Exemplo n.º 21
0
 public EPG_Control_V4(string SourceDirectory)
 {
   this.sourceDirectory = SourceDirectory;;
   if (DateTime.Now.Minute < 30)
     currentTime = DateTime.Now.AddMinutes(-DateTime.Now.Minute);
   else
     currentTime = DateTime.Now.AddMinutes(30 - DateTime.Now.Minute);
   currentSelectedTime = currentTime;
   lastTime = currentTime.AddHours(2);
   currentChannel = 0;
   lastChannel = 2;
   incrementalTime = new System.TimeSpan(0, 30, 0);
   epg_Data = new EPG_Program_Channel();
   epg_Times = new EPG_Time();
   epg_SelectedItem = new EPG_SelectedItem();
   tvdbHandler = new TvdbHandler(new XmlCacheProvider("C:\\test"), "572328F18DC4374A");
   tvdbHandler.InitCache();
   client = new TMDbClient("ecaa9ae8c8346269b53c80e2a61aa0ea");
   client.GetConfig();
 }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string v = Request.QueryString["id"];

            string connstring = "Server=ec2-54-217-202-110.eu-west-1.compute.amazonaws.com;Port=5432;" +
                "User Id=iwzexazhfjxbbt;Password=4JVMJFooosyfdM5Y79Si-c691D;Database=d8u6uelvine6d6;ssl=true";

            NpgsqlConnection conn = new NpgsqlConnection(connstring);
            conn.Open();

            string sql = "SELECT original_title, vote_average FROM movie where id = " + v;

            NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);

            da.Fill(ds, "movie_genre");

            dt = ds.Tables[0];

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Label1.Text = row["original_title"].ToString();
                Label2.Text = row["vote_average"].ToString();
            }
            string sql1 = "SELECT a.name as Genre FROM genre a, movie_genre b where a.id=b.genre_id and b.movie_id = " + v;

            NpgsqlDataAdapter da1 = new NpgsqlDataAdapter(sql1, conn);

            da1.Fill(ds1);

            dt1 = ds1.Tables[0];

            GridView1.DataSource = dt1;
            GridView1.DataBind();
            conn.Close();

            TMDbClient client = new TMDbClient("c6d0e337dede3d1affc1e12252ced4d4");
               Movie movie = client.GetMovie(Int32.Parse(v));

            Label5.Text = v;
            Label4.Text = movie.Overview;
        }
Exemplo n.º 23
0
        private static void Main(string[] args)
        {
            // Instantiate a new client, all that's needed is an API key, but it's possible to 
            // also specify if SSL should be used, and if another server address should be used.
            TMDbClient client = new TMDbClient("c6b31d1cdad6a56a23f0c913e2482a31");

            // We need the config from TMDb in case we want to get stuff like images
            // The config needs to be fetched for each new client we create, but we can cache it to a file (as in this example).
            FetchConfig(client);

            // Try fetching a movie
            FetchMovieExample(client);

            // Once we've got a movie, or person, or so on, we can display images. 
            // TMDb follow the pattern shown in the following example
            // This example also shows an important feature of most of the Get-methods.
            FetchImagesExample(client);

            Console.WriteLine("Done.");
            Console.ReadLine();
        }
Exemplo n.º 24
0
    public EPG_Control_V2(string SourceDirectory)
    {
      this.sourceDirectory = SourceDirectory;
      epg_Data = new EPG_Program_Channel();
      epg_Times = new EPG_Time();
      epg_SelectedItem = new EPG_SelectedItem();
      tvdbHandler = new TvdbHandler(new XmlCacheProvider("C:\\test"), "572328F18DC4374A");
      tvdbHandler.InitCache();
      client = new TMDbClient("ecaa9ae8c8346269b53c80e2a61aa0ea");
      client.GetConfig();
      epg_ChannelIndex = 0;
      epg_ProgramIndex = 0;
      incTimeSpan = new TimeSpan(0, 30, 0);
      int ts = 0;

      if (DateTime.Now.Minute < 30)      
        ts = -(DateTime.Now.Minute);      
      else      
        ts = 30 - DateTime.Now.Minute;        
      
      currentTime = DateTime.Now.AddMinutes(ts);
      lastTime = currentTime.AddHours(2);
    }
Exemplo n.º 25
0
		public static List<MovieDB_Movie_Result> Search(string criteria)
		{
			List<MovieDB_Movie_Result> results = new List<MovieDB_Movie_Result>();
			
			try
			{
                TMDbClient client = new TMDbClient(apiKey);
                SearchContainer<SearchMovie> resultsTemp = client.SearchMovie(criteria);

                Console.WriteLine("Got {0} of {1} results", resultsTemp.Results.Count, resultsTemp.TotalResults);
                foreach (SearchMovie result in resultsTemp.Results)
                {
                    MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                    Movie movie = client.GetMovie(result.Id);
                    ImagesWithId imgs = client.GetMovieImages(result.Id);
                    searchResult.Populate(movie, imgs);
                    results.Add(searchResult);
                    SaveMovieToDatabase(searchResult, false);
                }	

			}
			catch (Exception ex)
			{
				logger.Error("Error in MovieDB Search: " + ex.Message);
			}

			return results;
		}
Exemplo n.º 26
0
        private void MediaInfoLoadButton_Click(object sender, RoutedEventArgs e)
        {
            string searchMedia = MediaTitleInfo.Text;
            if (string.IsNullOrEmpty(searchMedia)) return;

            string selectedLang = (string) SearchLanguage.SelectedValue;
            if (string.IsNullOrEmpty(selectedLang))
                selectedLang = "en";

            string selectedCertCountry = (string) RatingCountry.SelectedValue;
            if (string.IsNullOrEmpty(selectedCertCountry))
                selectedCertCountry = "us";

            AppSettings.MovieDBLastLanguage = selectedLang;
            AppSettings.MovieDBLastRatingCountry = selectedCertCountry;

            TMDbClient client = new TMDbClient(MovieDBApiKey);

            FileInfo configXml = new FileInfo("TMDbconfig.xml");
            if (configXml.Exists && configXml.LastWriteTimeUtc >= DateTime.UtcNow.AddHours(-1))
            {
                Log.Info("TMDbClient: Using stored config");
                string xml = File.ReadAllText(configXml.FullName, Encoding.Unicode);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);

                client.SetConfig(TMDbSerializer.Deserialize<TMDbConfig>(xmlDoc));
            }
            else
            {
                Log.Info("TMDbClient: Getting new config");
                client.GetConfig();

                Log.Info("TMDbClient: Storing config");
                XmlDocument xmlDoc = TMDbSerializer.Serialize(client.Config);
                File.WriteAllText(configXml.FullName, xmlDoc.OuterXml, Encoding.Unicode);
            }

            SearchContainer<SearchMovie> movieList = client.SearchMovie(searchMedia, selectedLang);
            if (movieList == null || movieList.TotalResults <= 0) return;

            SearchMovie resultMovie = new SearchMovie();
            if (movieList.TotalResults > 1)
            {
                MovieDBMultipleSelection selectWindow = new MovieDBMultipleSelection
                    {
                        Owner = this,
                        SearchResults = movieList
                    };
                if (selectWindow.ShowDialog() == true)
                    resultMovie = selectWindow.SelectionResult;
            }
            else
                resultMovie = movieList.Results.First();

            if (resultMovie.Id == 0) return;

            Movie searchResult = client.GetMovie(resultMovie.Id, selectedLang);
            ImagesWithId imageList = client.GetMovieImages(resultMovie.Id);
            Casts movieCasts = client.GetMovieCasts(resultMovie.Id);
            KeywordsContainer movieKeywords = client.GetMovieKeywords(resultMovie.Id);
            Trailers movieTrailers = client.GetMovieTrailers(resultMovie.Id);
            Releases movieReleases = client.GetMovieReleases(resultMovie.Id);

            if (searchResult == null) return;

            MovieTitle.Text = searchResult.Title;
            MovieOriginalTitle.Text = searchResult.OriginalTitle;

            Genre.Text = searchResult.Genres != null
                             ? string.Join(" / ", searchResult.Genres.ConvertAll(input => input.Name))
                             : string.Empty;

            Rating.Text = searchResult.VoteAverage.ToString("g");
            Runtime.Text = searchResult.Runtime.ToString("g");
            Votes.Text = searchResult.VoteCount.ToString("g");
            Year.Text = searchResult.ReleaseDate.Year.ToString("g");
            Tagline.Text = searchResult.Tagline;
            Plot.Text = searchResult.Overview;

            if (movieKeywords != null && movieKeywords.Keywords != null)
                Keywords.Text = string.Join(", ", movieKeywords.Keywords.ConvertAll(input => input.Name));
            else
                Keywords.Text = string.Empty;

            ImdbId.Text = searchResult.ImdbId;

            Country.Text = searchResult.ProductionCountries != null
                               ? string.Join(" / ", searchResult.ProductionCountries.ConvertAll(input => input.Name))
                               : string.Empty;

            if (movieCasts != null && movieCasts.Crew != null)
            {
                Director.Text = string.Join(" / ",
                                            movieCasts.Crew.Where(crew => crew.Job == "Director")
                                                      .ToList()
                                                      .ConvertAll(input => input.Name));
                Writers.Text = string.Join(" / ",
                                           movieCasts.Crew.Where(crew => crew.Job == "Writer" || crew.Job == "Screenplay")
                                                     .ToList()
                                                     .ConvertAll(input => input.Name));
            }
            else
            {
                Director.Text = string.Empty;
                Writers.Text = string.Empty;
            }

            Studio.Text = searchResult.ProductionCompanies != null
                              ? string.Join(" / ", searchResult.ProductionCompanies.ConvertAll(input => input.Name))
                              : string.Empty;

            SetName.Text = searchResult.BelongsToCollection != null
                               ? string.Join(" / ", searchResult.BelongsToCollection.ConvertAll(input => input.Name))
                               : string.Empty;

            if (movieTrailers != null && movieTrailers.Youtube != null && movieTrailers.Youtube.Count > 0)
                Trailer.Text = "plugin://plugin.video.youtube/?action=play_video&amp;videoid=" +
                               movieTrailers.Youtube.First().Source;
            else
                Trailer.Text = string.Empty;

            Country selCountry =
                movieReleases.Countries.Single(country => country.Iso_3166_1.ToLowerInvariant() == selectedCertCountry) ??
                movieReleases.Countries.Single(country => country.Iso_3166_1.ToLowerInvariant() == "us");

            MovieDBCertCountry certCountry =
                MovieDBCertCountries.CountryList.Single(country => country.CountryName == selectedCertCountry);

            MPAARating.Text = certCountry.Prefix + selCountry.Certification;

            // loading image sizes
            string posterOriginal = client.Config.Images.PosterSizes.Last();

            string posterPreview = client.Config.Images.PosterSizes.Count >= 2
                                       ? client.Config.Images.PosterSizes[client.Config.Images.PosterSizes.Count - 2]
                                       : client.Config.Images.PosterSizes.Last();

            string backdropOriginal = client.Config.Images.BackdropSizes.Last();

            string backdropPreview = client.Config.Images.BackdropSizes.Count >= 3
                                         ? client.Config.Images.BackdropSizes[
                                             client.Config.Images.BackdropSizes.Count - 3]
                                         : client.Config.Images.BackdropSizes.Last();

            // remove duplicate entries
            imageList.Backdrops.RemoveAt(imageList.Backdrops.FindIndex(data => data.FilePath == searchResult.BackdropPath));
            imageList.Posters.RemoveAt(imageList.Posters.FindIndex(data => data.FilePath == searchResult.PosterPath));

            // create image lists
            _postersList.Add(new MovieDBPosterImage
                {
                    Title = "Default",
                    UrlOriginal = client.GetImageUrl(posterOriginal, searchResult.PosterPath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(posterPreview, searchResult.PosterPath).AbsoluteUri
                });
            _backdropsList.Add(new MovieDBImageInfo
                {
                    Title = "Default",
                    UrlOriginal = client.GetImageUrl(backdropOriginal, searchResult.BackdropPath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(backdropPreview, searchResult.BackdropPath).AbsoluteUri
                });

            int cnt = 1;
            foreach (ImageData poster in imageList.Posters)
            {
                _postersList.Add(new MovieDBPosterImage
                    {
                        Title = "Online image " + cnt,
                        UrlOriginal = client.GetImageUrl(posterOriginal, poster.FilePath).AbsoluteUri,
                        UrlPreview = client.GetImageUrl(posterPreview, poster.FilePath).AbsoluteUri
                    });
                cnt++;
            }
            PosterList.ItemsSource = _postersList;
            PosterList.SelectedIndex = 0;

            cnt = 1;
            foreach (ImageData backdrop in imageList.Backdrops)
            {
                _backdropsList.Add(new MovieDBImageInfo
                {
                    Title = "Online image " + cnt,
                    UrlOriginal = client.GetImageUrl(backdropOriginal, backdrop.FilePath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(backdropPreview, backdrop.FilePath).AbsoluteUri
                });
                cnt++;
            }
            BackdropList.ItemsSource = _backdropsList;
            BackdropList.SelectedIndex = 0;

            foreach (Cast cast in movieCasts.Cast)
            {
                _castList.Casts.Add(new MovieDBCast
                    {
                        Name = cast.Name,
                        Role = cast.Character,
                        Thumbnail = client.GetImageUrl("original", cast.ProfilePath).AbsoluteUri
                    });
            }
            CastListView.ItemsSource = _castList.Casts;
        }
Exemplo n.º 27
0
        //Retrieve TMDB info with a TMDBNum
        public Models.Movie ReturnMovieInfoFromTMDB(int tmdbNum)
        {
            TMDbClient client = new TMDbClient("1fee8f2397ff73412985de2bb825f020");

            Movie movie = client.GetMovie(tmdbNum,
                MovieMethods.AlternativeTitles | MovieMethods.Credits | MovieMethods.Images | MovieMethods.Releases |
                MovieMethods.Videos);

            Models.Movie movieInfo = new Models.Movie();
            movieInfo.MovieTitle = movie.Title;
            movieInfo.MovieTMDBNum = movie.Id;
            if (movie.Releases.Countries.FirstOrDefault(m => m.Iso_3166_1 == "US") != null)
            {
                movieInfo.MpaaRating = movie.Releases.Countries.FirstOrDefault(m => m.Iso_3166_1 == "US").Certification;
            }
            else
            {
                movieInfo.MpaaRating = "NR";
            }
            if (movie.ReleaseDate != null)
            {
                movieInfo.ReleaseDate = movie.ReleaseDate.Value.Date;
            }
            if (movie.Overview != null)
            {
                movieInfo.Synopsis = movie.Overview;
            }
            if (movie.Runtime != null)
            {
                movieInfo.Duration = movie.Runtime.Value;
            }
            if (movie.PosterPath != null)
            {
                movieInfo.PosterUrl = "http://image.tmdb.org/t/p/w396" + movie.PosterPath;
            }
            else
            {
                movieInfo.PosterUrl =
                    "http://assets.tmdb.org/assets/7f29bd8b3370c71dd379b0e8b570887c/images/no-poster-w185-v2.png";
            }
            if (movie.Videos.Results.Where(v => v.Type == "Trailer").FirstOrDefault() != null)
            {
                movieInfo.YouTubeTrailer = "http://www.youtube.com/embed/" +
                                           movie.Videos.Results.Where(v => v.Type == "Trailer").FirstOrDefault().Key;
            }
            if (movie.Genres.Count != 0)
            {
                foreach (var g in movie.Genres)
                {
                    var newGenre = new Models.Genre();
                    newGenre.GenreName = g.Name;
                    movieInfo.Genres.Add(newGenre);
                }
            }
            if (movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director") != null)
            {
                movieInfo.Director.DirectorName = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Name;
                movieInfo.Director.DirectorTMDBNum = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Id;
            }
            if (movie.ProductionCompanies.Count != 0)
            {
                movieInfo.Studio.StudioName = movie.ProductionCompanies[0].Name;
                movieInfo.Studio.StudioTMDBNum = movie.ProductionCompanies[0].Id;
            }

            if (movie.AlternativeTitles.Titles.Count != 0)
            {
                foreach (var t in movie.AlternativeTitles.Titles)
                {
                    if (t.Iso_3166_1 == "US")
                    {
                        var newMovieAlias = new MovieAlias();
                        newMovieAlias.MovieAliasTitle = t.Title;
                        movieInfo.MovieAliases.Add(newMovieAlias);
                    }
                }
            }

            if (movie.Credits.Cast.Count < 10 && movie.Credits.Cast.Count > 0)
            {
                foreach (var a in movie.Credits.Cast)
                {
                    Actor newActor = new Actor();
                    newActor.ActorName = a.Name;
                    newActor.ActorTMDBNum = a.Id;
                    newActor.CharacterName = a.Character;
                    movieInfo.MovieActors.Add(newActor);
                }
            }
            else if (movie.Credits.Cast.Count == 0)
            {
                return movieInfo;
            }
            else
            {
                for (int i = 0; i < 10; i++)
                {
                    Actor newActor = new Actor();
                    newActor.ActorName = movie.Credits.Cast[i].Name;
                    newActor.ActorTMDBNum = movie.Credits.Cast[i].Id;
                    newActor.CharacterName = movie.Credits.Cast[i].Character;
                    movieInfo.MovieActors.Add(newActor);
                }
            }

            return movieInfo;
        }
Exemplo n.º 28
0
        //Search TMDB for movies to add depending on Search String
        public List<SearchTMDBResult> RetrieveTMDBSearchResults(string movieName)
        {
            List<SearchTMDBResult> listOfSearchTMDBResults = new List<SearchTMDBResult>();

            TMDbClient client = new TMDbClient("1fee8f2397ff73412985de2bb825f020");

            SearchContainer<SearchMovie> initResults = client.SearchMovie("\"" + movieName + "\"");

            if (initResults.TotalPages >= 1)
            {
                for (int i = 1; i < initResults.TotalPages + 1; i++)
                {
                    SearchContainer<SearchMovie> results = client.SearchMovie("\"" + movieName + "\"", i);

                    foreach (SearchMovie r in results.Results)
                    {
                        SearchTMDBResult newResult = new SearchTMDBResult();
                        newResult.MovieTitle = r.Title;
                        newResult.TMDBNum = r.Id;
                        if (r.ReleaseDate != null)
                        {
                            newResult.ReleaseDate = r.ReleaseDate.Value;
                        }
                        if (r.Overview != null)
                        {
                            newResult.Synopsis = r.Overview;
                        }
                        if (r.PosterPath != null)
                        {
                            newResult.PosterUrl = "http://image.tmdb.org/t/p/w185" + r.PosterPath;
                        }
                        else
                        {
                            newResult.PosterUrl =
                                "http://assets.tmdb.org/assets/7f29bd8b3370c71dd379b0e8b570887c/images/no-poster-w185-v2.png";
                        }

                        listOfSearchTMDBResults.Add(newResult);
                    }
                }
            }

            return listOfSearchTMDBResults;
        }
Exemplo n.º 29
0
		public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages)
		{

			try
			{
                TMDbClient client = new TMDbClient(apiKey);
                Movie movie = client.GetMovie(movieID);
                ImagesWithId imgs = client.GetMovieImages(movieID);

                MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                searchResult.Populate(movie, imgs);

                // save to the DB
                SaveMovieToDatabase(session, searchResult, saveImages);
			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in ParseBanners: " + ex.ToString(), ex);
			}
		}
Exemplo n.º 30
0
 private void TmdbComplete(TMDbClient tmdb)
 {
     try
     {
         String[] split = Title.Split(new char[] { ' ', '.', '_', '-' });
         TMDbLib.Objects.General.SearchContainer<SearchMovie> results = tmdb.SearchMovie(this.Title);
         for (int i = split.Length; results.TotalResults == 0 && i > 0 ; --i)
         {
             String name = null;
             for (int j = 0; j < i; ++j)
                 name += " " + split[j];
             results = tmdb.SearchMovie(name);
         }
         Movie mov = tmdb.GetMovie(results.Results[0].Id);
         this.Adult = mov.Adult;
         this.Url = mov.Homepage;
         this.Title = mov.Title;
         if (mov != null && this.Picture == @"/WindowsMediaPlayer;component/assets/video_cover.png")
             SetImage(@"https://image.tmdb.org/t/p/w185" + mov.PosterPath, Lastfm.Utilities.md5(Path));
     }
     catch (Exception e)
     {
         Debug.Add(e.ToString() + "\n");
     }
 }