// GET: Movies public ActionResult Index(string movieGenre, string movieName, string searchString, int?page) { TMDbClient client = new TMDbClient("f5d4250fed4b807034758b556e333c90"); var GenreLst = new List <string>(); var GenreQry = from d in db.Movies orderby d.Original_Language select d.Original_Language; TMDbLib.Objects.Movies.Movie movie = null; GenreLst.AddRange(GenreQry.Distinct()); ViewBag.movieGenre = new SelectList(GenreLst); var movies = from m in db.Movies select m; SendMovies(movies.OrderBy(x => x.Original_title), movie, client); if (!String.IsNullOrEmpty(searchString)) { movies = movies.Where(s => s.Original_title.Contains(searchString)); } if (!string.IsNullOrEmpty(movieGenre)) { movies = movies.Where(x => x.Original_Language == movieGenre); } return(View(movies.OrderBy(x => x.Original_title))); }
public ActionResult AddMovie(string query) { TMDbClient client = new TMDbClient("71e4cebd739f9f30aec016154250620f"); SearchContainer <SearchMovie> search = client.SearchMovieAsync(query).Result; return(View(search.Results)); }
/// <summary> /// Initialize a new instance of MovieService class /// </summary> public MovieService() { TmdbClient = new TMDbClient(Constants.TmDbClientId) { MaxRetryCount = 10 }; }
private static async Task 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.GetMovieAsync(movieId, MovieMethods.Images); // client.GetMovieAsync(movieId, MovieMethods.Images | MovieMethods.Releases); // client.GetMovieAsync(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.GetMovieImagesAsync()' - it was better to do it like this because we also wanted the Title of the movie. Movie movie = await client.GetMovieAsync(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(); }
/// <summary> /// Initializes a new instance of the <see cref="TmdbClientManager"/> class. /// </summary> /// <param name="memoryCache">An instance of <see cref="IMemoryCache"/>.</param> public TmdbClientManager(IMemoryCache memoryCache) { _memoryCache = memoryCache; _tmDbClient = new TMDbClient(TmdbUtils.ApiKey); // Not really interested in NotFoundException _tmDbClient.ThrowApiExceptions = false; }
public ActionResult SerieDetail(int id, string language) { TMDbClient client = new TMDbClient("0464ee9cc3ccc27c18a7cbe6802c87c1"); var seriez = client.GetTvShowAsync(id, language: "fr").Result; return(View(seriez)); }
private static async Task 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"); //var tv = await client.GetTvShowAsync(82856, TMDbLib.Objects.TvShows.TvShowMethods.Credits, null); var people = await client.GetPersonListAsync(TMDbLib.Objects.People.PersonListType.Popular); var person = await client.GetPersonAsync(138); //var movie = await client.GetMovieAsync(138); // 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). //await FetchConfig(client); // Try fetching a movie await 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. await FetchImagesExample(client); Console.WriteLine("Done."); Console.ReadLine(); }
public async Task TestTvShowAccountStateRatingSet() { await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession); await TestMethodsHelper.SetValidateRemoveTest(async() => { // Rate await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 5); }, async() => { // Un-rate Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.BreakingBad)); }, async shouldBe => { AccountState accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad); Assert.Equal(IdHelper.BreakingBad, accountState.Id); if (shouldBe) { Assert.NotNull(accountState.Rating); Assert.Equal(5, accountState.Rating.Value); } else { Assert.Null(accountState.Rating); } }); }
public Movie SearchMovieInTMDBByID(int TMDbID) { try { TMDbClient client = new TMDbClient(ApiKey.tmdbkeyV3, true); //TMDbConfig conf = await client.GetConfigAsync(); var result = client.GetMovieAsync(TMDbID, CultureInfo.CurrentCulture.TwoLetterISOLanguageName).Result; Movie MovieFound = new Movie(); if (result.Id != 0) { MovieFound = new Movie(); MovieFound.TmdbID = result.Id; MovieFound.Title = result.Title; MovieFound.Poster = (result.PosterPath ?? "").Replace("/", ""); } return(MovieFound); } catch (Exception ex) { Crashes.TrackError(ex); throw ex; } }
public async Task TestTvShowSeasonCountAsync() { // TODO: Is this test obsolete? TvShow tvShow = await TMDbClient.GetTvShowAsync(1668); await Verify(tvShow); }
public async Task TestTvShowLists() { foreach (TvShowListType type in Enum.GetValues(typeof(TvShowListType)).OfType <TvShowListType>()) { await TestHelpers.SearchPagesAsync(i => TMDbClient.GetTvShowListAsync(type, i)); } }
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(); }
/// <summary> /// Get the link to the youtube trailer of a movie /// </summary> /// <param name="imdbCode">The unique identifier of a movie</param> public Tuple <Trailers, Exception> GetMovieTrailer(string imdbCode) { Exception ex = null; Trailers trailers = new Trailers(); TMDbClient tmDbclient = new TMDbClient(Constants.TmDbClientId); tmDbclient.GetConfig(); try { TMDbLib.Objects.Movies.Movie movie = tmDbclient.GetMovie(imdbCode); if (movie.ImdbId != null) { trailers = tmDbclient.GetMovieTrailers(movie.Id); } else { ex = new Exception(); } } catch (Exception e) { ex = e; } return(new Tuple <Trailers, Exception>(trailers, ex)); }
public void ClientRateLimitTest() { const int id = IdHelper.AGoodDayToDieHard; TMDbClient client = new TMDbClient(TestConfig.APIKey); client.MaxRetryCount = 0; try { Parallel.For(0, 100, i => { try { client.GetMovieAsync(id).Wait(); } catch (AggregateException ex) { // Unpack the InnerException throw ex.InnerException; } }); } catch (AggregateException ex) { // Unpack the InnerException throw ex.InnerException; } Assert.Fail(); }
public ActionResult GetVideo(int id) { TMDbClient client = new TMDbClient("0464ee9cc3ccc27c18a7cbe6802c87c1"); ResultContainer <Video> videos = client.GetMovieVideosAsync(id).Result; return(PartialView("_Video", videos.Results)); }
public TvShow SearchTvShowInTMDBByID(int TMDbID) { try { TMDbClient client = new TMDbClient(ApiKey.tmdbkeyV3, true); //TMDbConfig conf = await client.GetConfigAsync(); var result = client.GetTvShowAsync(TMDbID, language: CultureInfo.CurrentCulture.TwoLetterISOLanguageName).Result; TvShow TvShowFound = new TvShow(); if (result.Id != 0) { TvShowFound = new TvShow(); TvShowFound.TmdbID = result.Id; TvShowFound.Title = result.Name; TvShowFound.Poster = (result.PosterPath ?? "").Replace("/", ""); TvShowFound.SeasonCount = result.Seasons.Count(); } return(TvShowFound); } catch (Exception ex) { Crashes.TrackError(ex); throw ex; } }
public ActionResult Serie() { TMDbClient client = new TMDbClient("0464ee9cc3ccc27c18a7cbe6802c87c1"); var seriez = client.GetTvShowTopRatedAsync(language: "fr").Result; return(View(seriez.Results)); }
public void ClientConstructorUrlTest() { TMDbClient clientA = new TMDbClient(TestConfig.APIKey, false, "http://api.themoviedb.org") { MaxRetryCount = 2 }; clientA.GetConfigAsync().Sync(); TMDbClient clientB = new TMDbClient(TestConfig.APIKey, true, "http://api.themoviedb.org") { MaxRetryCount = 2 }; clientB.GetConfigAsync().Sync(); TMDbClient clientC = new TMDbClient(TestConfig.APIKey, false, "https://api.themoviedb.org") { MaxRetryCount = 2 }; clientC.GetConfigAsync().Sync(); TMDbClient clientD = new TMDbClient(TestConfig.APIKey, true, "https://api.themoviedb.org") { MaxRetryCount = 2 }; clientD.GetConfigAsync().Sync(); }
private static async Task 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 = await client.SearchMovieAsync(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(); }
public async Task TestDiscoverMoviesLanguageAsync() { SearchContainer <SearchMovie> query = await TMDbClient.DiscoverMoviesAsync() .WhereOriginalLanguageIs("en-US") .WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01)) .Query(); SearchContainer <SearchMovie> queryDanish = await TMDbClient.DiscoverMoviesAsync() .WhereLanguageIs("da-DK") .WhereOriginalLanguageIs("en-US") .WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01)) .Query(); // Should be the same identities, but different titles Assert.Equal(query.TotalResults, queryDanish.TotalResults); for (int i = 0; i < query.Results.Count; i++) { SearchMovie a = query.Results[i]; SearchMovie b = queryDanish.Results[i]; Assert.Equal(a.Id, b.Id); Assert.NotEqual(a.Title, b.Title); } }
private static async Task FetchConfig(TMDbClient client) { FileInfo configJson = new FileInfo("config.json"); Console.WriteLine("Config file: " + configJson.FullName + ", Exists: " + configJson.Exists); if (configJson.Exists && configJson.LastWriteTimeUtc >= DateTime.UtcNow.AddHours(-1)) { Console.WriteLine("Using stored config"); string json = File.ReadAllText(configJson.FullName, Encoding.UTF8); client.SetConfig(JsonConvert.DeserializeObject <APIConfiguration>(json)); } else { Console.WriteLine("Getting new config"); var config = await client.GetConfigAsync(); Console.WriteLine("Storing config"); string json = JsonConvert.SerializeObject(config); File.WriteAllText(configJson.FullName, json, Encoding.UTF8); } Spacer(); }
public SearchContainer <SearchMovie> RequestMovieSuggestionsUpcoming() { TMDbClient client = new TMDbClient(Constants.OmdbKey); return(client.DiscoverMoviesAsync() .WherePrimaryReleaseDateIsAfter(DateTime.Today).Query().Result); }
public GetMovieID(TMDbClient client) { InitializeComponent(); Client = client; progressBar1.Visible = false; //listViewMovies.Activation = ItemActivation.TwoClick; listViewMovies.MouseDoubleClick += (sender, e) => { ListViewItem li = listViewMovies.GetItemAt(e.X, e.Y); System.Diagnostics.Debug.WriteLine($"clicks: {e.Clicks}"); if (e.Clicks == 2 && li != null) { AddItem(li.Tag as SearchMovie); DialogResult = DialogResult.OK; } }; KeyPreview = true; KeyUp += (sender, e) => { if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; } }; }
public SearchContainer <SearchTv> RequestTvSuggestionsUpcoming() { TMDbClient client = new TMDbClient(Constants.OmdbKey); return(client.DiscoverTvShowsAsync() .WhereFirstAirDateIsAfter(DateTime.Today).Query().Result); }
/// <summary> /// Initializes a new instance of the <see cref="TmdbClientManager"/> class. /// </summary> /// <param name="memoryCache">An instance of <see cref="IMemoryCache"/>.</param> public TmdbClientManager(IMemoryCache memoryCache) { _memoryCache = memoryCache; _tmDbClient = new TMDbClient(TmdbPlugin.Instance?.Configuration.ApiKey); // Not really interested in NotFoundException _tmDbClient.ThrowApiExceptions = false; }
public ActionResult Index() { TMDbClient client = new TMDbClient("0464ee9cc3ccc27c18a7cbe6802c87c1"); var movie = client.GetMovieNowPlayingListAsync("fr").Result; return(View(movie.Results)); }
public static List <MovieDB_Movie_Result> SearchWithTVShowID(int id, bool isTrakt) { List <MovieDB_Movie_Result> results = new List <MovieDB_Movie_Result>(); try { TMDbClient client = new TMDbClient(apiKey); TvShow result = client.GetTvShow(id, TvShowMethods.Images, null); if (result != null) { logger.Info("Got TMDB results for id: {0} | show name: {1}", id, result.Name); 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, true, isTrakt); } } catch (Exception ex) { logger.Error("Error in MovieDB Search: " + ex.Message); } return(results); }
public ActionResult GetSimilarMovie(int id) { TMDbClient client = new TMDbClient("0464ee9cc3ccc27c18a7cbe6802c87c1"); var similar = client.GetMovieSimilarAsync(id, "fr").Result; return(PartialView("_SimilarMovies", similar.Results)); }
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); logger.Info($"Got {resultsTemp.Results.Count} of {resultsTemp.TotalResults} results"); 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, false); } } catch (Exception ex) { logger.Error("Error in MovieDB Search: " + ex.Message); } return(results); }
public async Task ClientConstructorUrlTest() { using TMDbClient clientA = new TMDbClient(TestConfig.APIKey, false, "http://api.themoviedb.org") { MaxRetryCount = 2 }; await clientA.GetConfigAsync(); using TMDbClient clientB = new TMDbClient(TestConfig.APIKey, true, "http://api.themoviedb.org") { MaxRetryCount = 2 }; await clientB.GetConfigAsync(); using TMDbClient clientC = new TMDbClient(TestConfig.APIKey, false, "https://api.themoviedb.org") { MaxRetryCount = 2 }; await clientC.GetConfigAsync(); using TMDbClient clientD = new TMDbClient(TestConfig.APIKey, true, "https://api.themoviedb.org") { MaxRetryCount = 2 }; await clientD.GetConfigAsync(); }