public ActionResult GetPerson(int id) { /*Calling API https://developers.themoviedb.org/3/people */ string apiKey = "3356865d41894a2fa9bfa84b2b5f59bb"; HttpWebRequest apiRequest = WebRequest.Create("https://api.themoviedb.org/3/person/" + id + "?api_key=" + apiKey + "&language=en-US") as HttpWebRequest; string apiResponse = ""; using (HttpWebResponse response = apiRequest.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); apiResponse = reader.ReadToEnd(); } /*End*/ /*http://json2csharp.com*/ ResponsePerson rootObject = JsonConvert.DeserializeObject <ResponsePerson>(apiResponse); TheMovieDb theMovieDb = new TheMovieDb(); theMovieDb.name = rootObject.name; theMovieDb.biography = rootObject.biography; theMovieDb.birthday = rootObject.birthday; theMovieDb.place_of_birth = rootObject.place_of_birth; theMovieDb.profile_path = rootObject.profile_path == null?Url.Content("~/Content/Image/no-image.png") : "https://image.tmdb.org/t/p/w500/" + rootObject.profile_path; theMovieDb.also_known_as = string.Join(", ", rootObject.also_known_as); return(View(theMovieDb)); }
public async Task <Image> GetLogo(int companyID, TmdbWrapper.Utilities.LogoSize logoSize, String logoPath = null) { Image x = null; if (logoPath == null && HasLogo == true) { //LogoPath can be null and going out and trying to get it doesn't do anything but add useless time! //TODO - need to do something about the time it takes to get Company info over and over.. TmdbWrapper.Companies.Company c = await TheMovieDb.GetCompanyAsync(companyID); // TMDB Company ID logoPath = c.LogoPath; } if (logoPath != null) { String cachePath = PrivateData.GetAppPath() + @"\Cache\Images\production\" + logoPath.Replace("/", ""); if (File.Exists(cachePath)) { x = Image.FromFile(cachePath); } else { Directory.CreateDirectory(Path.GetDirectoryName(cachePath)); // Insure Directory Exists Uri uri = Uri(logoSize); var wc = new WebClient(); x = Image.FromStream(wc.OpenRead(uri)); x.Save(cachePath); // This should be a separate non-blocking Task } } return(x); }
public async Task <IActionResult> AddGenres(TheMovieDb theMovieDb, int movieId) { foreach (var gId in theMovieDb.Genre_ids) { string genreName = await GetGenreNameById((Int64)gId); MovieGenre mg = await _dbContext.MovieGenres .Where(mg => mg.Name == genreName) .FirstOrDefaultAsync(); Movie movie = await _dbContext.Movies .Where(m => m.Name == theMovieDb.Original_title) .FirstOrDefaultAsync(); GenreMovieLink gml = new GenreMovieLink { MovieId = movie.Id, MovieGenreId = mg.Id }; _dbContext.GenreMovieLinks.Add(gml); await _dbContext.SaveChangesAsync(); } return(RedirectToAction("HomeAdmin", "Administrator")); }
private async Task LoadCast() { var id = _summary == null ? _movie.Id : _summary.Id; var credits = await TheMovieDb.GetMovieCastAsync(id); Director = credits.Crew.Where(c => c.Job == "Director").Select(c => c.Name).FirstOrDefault(); Writer = credits.Crew.Where(c => c.Job == "Writer").Select(c => c.Name).FirstOrDefault(); Cast = credits.Cast.Select(CastFactory); }
public void ScrapeCertificationTest() { var target = new TheMovieDb(); string output; var result = target.ScrapeCertification(ID, 0, out output, string.Empty); Assert.IsTrue(result); }
public void ScrapeRatingTest() { var target = new TheMovieDb(); double output; var result = target.ScrapeRating(ID, 0, out output, string.Empty); Assert.IsTrue(result); }
public void ScrapeFanartTest() { var target = new TheMovieDb(); BindingList <ImageDetailsModel> output; var result = target.ScrapeFanart(ID, 0, out output, string.Empty); Assert.IsTrue(result); }
public void GetImagesTest() { var target = new TheMovieDb(); const int ThreadID = 0; var actual = target.GetImages(ImageUsageType.Poster, ThreadID, ID); Assert.IsTrue(actual.Count > 2); }
public void ScrapeWritersTest() { var target = new TheMovieDb(); BindingList <PersonModel> output; var result = target.ScrapeWriters(ID, 0, out output, string.Empty); Assert.IsTrue(result); }
public void ScrapeTaglineTest() { var target = new TheMovieDb(); string output; var result = target.ScrapeTagline(ID, 0, out output, string.Empty); Assert.IsTrue(result); Assert.IsFalse(string.IsNullOrEmpty(output)); }
public void ScrapeYearTest() { var target = new TheMovieDb(); int output; var result = target.ScrapeYear(ID, 0, out output, string.Empty); Assert.IsTrue(result); Assert.IsTrue(output == 2005); }
public void ScrapeStudioTest() { var target = new TheMovieDb(); BindingList <string> output; var result = target.ScrapeStudio(ID, 0, out output, string.Empty); Assert.IsTrue(result); Assert.IsTrue(output.Count > 0); }
public void ScrapePostersTest() { var target = new TheMovieDb(); BindingList <ImageDetailsModel> output; var result = target.ScrapePoster(ID, 0, out output, string.Empty); Assert.IsTrue(result); Assert.IsTrue(!string.IsNullOrEmpty(output[0].UriThumb.ToString())); }
public void SearchYANFOETest() { var target = new TheMovieDb(); var query = new Query { Results = new BindingList <QueryResult>(), Title = "Transformers", Year = "2007" }; const int ThreadID = 0; var actual = target.SearchYANFOE(query, ThreadID, string.Empty); Assert.IsTrue(actual); }
private async Task <Person> asyncUpdatePerson(Person p) { TmdbWrapper.Persons.Person fullPerson = await TheMovieDb.GetPersonAsync(p.Id); p.HomePage = fullPerson.Homepage; p.Biography = fullPerson.Biography; p.Birthday = fullPerson.Birthday; p.Deathday = fullPerson.Deathday; p.PlaceOfBirth = fullPerson.PlaceOfBirth; p.Updated = true; return(p); }
public void ScrapeTitleTest() { var target = new TheMovieDb(); string output; BindingList <string> alternatives; var result = target.ScrapeTitle(ID, 0, out output, out alternatives, string.Empty); Assert.IsTrue(result); Assert.IsTrue(output == "Sin City"); }
private async Task LoadInfoAsync() { var tmdbConfig = await TheMovieDb.GetConfiguration(); var tmdbInfo = await TheMovieDb.SearchPersonAsync(_name); if (tmdbInfo.Results != null && tmdbInfo.Results.Count == 1) { var details = await tmdbInfo.Results[0].PersonAsync(); Info = new TmdbPerson(tmdbConfig, details); } }
private async Task CreateMovieInRadarr(Movie movie) { var isAnime = false; try { var movieDbResponse = await TheMovieDb.GetMovieFromTheMovieDbAsync(_httpClientFactory.CreateClient(), movie.TheMovieDbId); await movieDbResponse.ThrowIfNotSuccessfulAsync("TheMovieDbFindMovie failed", x => x.status_message); var jsonResponse = await movieDbResponse.Content.ReadAsStringAsync(); var theMovieDbMovie = JsonConvert.DeserializeObject <TheMovieDbMovie>(jsonResponse); isAnime = theMovieDbMovie.IsAnime; } catch (System.Exception ex) { _logger.LogError(ex, $"An error occurred while requesting movie: " + ex.Message); } var jsonMovie = await SearchMovieByMovieDbId(int.Parse(movie.TheMovieDbId)); int[] tags = Array.Empty <int>(); if (RadarrSettings.Version != "2") { tags = isAnime ? RadarrSettings.AnimeTags : RadarrSettings.MovieTags; } var response = await HttpPostAsync($"{BaseURL}/movie", JsonConvert.SerializeObject(new { title = jsonMovie.title, qualityProfileId = isAnime ? RadarrSettings.AnimeProfileId : RadarrSettings.MovieProfileId, titleSlug = jsonMovie.titleSlug, monitored = RadarrSettings.MonitorNewRequests, tags = tags, images = new string[0], tmdbId = int.Parse(movie.TheMovieDbId), year = jsonMovie.year, rootFolderPath = isAnime ? RadarrSettings.AnimeRootFolder : RadarrSettings.MovieRootFolder, minimumAvailability = isAnime ? RadarrSettings.AnimeMinimumAvailability : RadarrSettings.MovieMinimumAvailability, addOptions = new { ignoreEpisodesWithFiles = false, ignoreEpisodesWithoutFiles = false, searchForMovie = RadarrSettings.SearchNewRequests } })); await response.ThrowIfNotSuccessfulAsync("RadarrMovieCreation failed", x => x.error); }
public static async Task Movie(TelegramBotClient botHandle, Message source, GroupCollection matches) { var replyText = Strings.MovieDefault; if (!string.IsNullOrWhiteSpace(matches[2].Value)) { var movies = await TheMovieDb.SearchMovie(matches[2].Value); replyText = movies.Count > 0 ? FormatMovie(movies.First()) : Strings.MovieNotFound; } await botHandle.SendSmartTextMessageAsync(source, replyText, ParseMode.Html); }
/// <summary> /// Do a quick lookup on TmDB /// </summary> /// <param name="query">The query.</param> /// <returns> /// The quick search tmdb. /// </returns> public static bool QuickSearchTmdb(Query query) { if (query == null) { query = new Query(); } var tmdb = new TheMovieDb(); tmdb.SearchSite(query, 0, "Tmdb"); return(query.Results.Count > 0); }
public AppContext(IPlatformServices platformServices, IView view) { View = view; PlatformServices = platformServices; Settings = new SettingsVm(platformServices); Downloads = new DownloadManager(this, view); //WatchList = new WatchList(this); Settings.SettingsChanged += _settings_SettingsChanged; Init(); TheMovieDb.Initialise(TmdbApiKey, View.PreferedCulture.TwoLetterISOLanguageName, PlatformServices); }
public void StackPanel_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount >= 2) { StackPanel temp = (StackPanel)sender; TheMovieDb new_movie = (TheMovieDb)temp.DataContext; TmdbAPI tmdb = new TmdbAPI(); movieDetails = tmdb.GetMovieDetails(new_movie.id); ((DiscoveryViewModel)DataContext).Model.movieDetailsView.DataContext = movieDetails; ((DiscoveryViewModel)DataContext).Model.CurrentView = ((DiscoveryViewModel)DataContext).Model.movieDetailsView; ((DiscoveryViewModel)DataContext).Model.IsMovieDetailsButtonChecked = true; ((DiscoveryViewModel)DataContext).Model.MovieDetailsVisibility = "Visible"; } }
public void GetPeopleTest() { var target = new TheMovieDb(); const int ThreadID = 0; var actual = target.GetPeople(TheMovieDb.PersonType.Actor, ThreadID, ID); Assert.IsTrue(actual.Count > 10); actual = target.GetPeople(TheMovieDb.PersonType.Author, ThreadID, ID); Assert.IsTrue(actual.Count == 1); actual = target.GetPeople(TheMovieDb.PersonType.Director, ThreadID, ID); Assert.IsTrue(actual.Count == 3); }
private async Task CreateMovieInRadarr(Movie movie) { var response = await TheMovieDb.GetMovieFromTheMovieDbAsync(_httpClientFactory.CreateClient(), movie.TheMovieDbId); if (!response.IsSuccessStatusCode) { throw new Exception(response.ReasonPhrase); } var jsonResponse = await response.Content.ReadAsStringAsync(); var theMovieDbMovie = JsonConvert.DeserializeObject <TheMovieDbMovie>(jsonResponse); var jsonMovie = await SearchMovieByMovieDbId(int.Parse(movie.TheMovieDbId)); int[] tags = Array.Empty <int>(); if (RadarrSettings.Version != "2") { tags = theMovieDbMovie.IsAnime ? RadarrSettings.AnimeTags : RadarrSettings.MovieTags; } response = await HttpPostAsync($"{BaseURL}/movie", JsonConvert.SerializeObject(new { title = jsonMovie.title, qualityProfileId = theMovieDbMovie.IsAnime ? RadarrSettings.AnimeProfileId : RadarrSettings.MovieProfileId, titleSlug = jsonMovie.titleSlug, monitored = true, tags = tags, images = new string[0], tmdbId = int.Parse(movie.TheMovieDbId), year = jsonMovie.year, rootFolderPath = theMovieDbMovie.IsAnime ? RadarrSettings.AnimeRootFolder : RadarrSettings.MovieRootFolder, minimumAvailability = theMovieDbMovie.IsAnime ? RadarrSettings.AnimeMinimumAvailability : RadarrSettings.MovieMinimumAvailability, addOptions = new { ignoreEpisodesWithFiles = false, ignoreEpisodesWithoutFiles = false, searchForMovie = true } })); if (!response.IsSuccessStatusCode) { throw new Exception(response.ReasonPhrase); } }
public async Task Add(TheMovieDb theMovieDb, MovieSearch movieSearch) { Movie movie = new Movie { Name = theMovieDb.Original_title, Synopsis = theMovieDb.Overview, Duration = movieSearch.Duration, TrailerUrl = movieSearch.Trailer, PosterUrl = movieSearch.Poster, Director = "director" }; _dbContext.Movies.Add(movie); await _dbContext.SaveChangesAsync(); await AddCast(theMovieDb); }
public ActionResult GetMovie(int id) { /*Calling API https://developers.themoviedb.org/3/people */ string apiKey = "1660ca5fe5b0e26bdcd9c838a9b5c7c7"; HttpWebRequest apiRequest = WebRequest.Create("https://api.themoviedb.org/3/Movie/" + id + "?api_key=" + apiKey + "&language=en-US") as HttpWebRequest; string apiResponse = ""; using (HttpWebResponse response = apiRequest.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); apiResponse = reader.ReadToEnd(); } /*End*/ /*http://json2csharp.com*/ ResponseMovie rootObject = JsonConvert.DeserializeObject <ResponseMovie>(apiResponse); TheMovieDb theMovieDb = new TheMovieDb(); theMovieDb.adult = rootObject.adult; theMovieDb.backdrop_path = rootObject.backdrop_path; theMovieDb.belongs_to_collection = rootObject.belongs_to_collection; theMovieDb.homepage = rootObject.homepage; theMovieDb.id = rootObject.id; theMovieDb.imdb_id = rootObject.imdb_id; theMovieDb.original_language = rootObject.original_language; theMovieDb.original_title = rootObject.original_title; theMovieDb.overview = rootObject.overview; theMovieDb.popularity = rootObject.popularity; theMovieDb.poster_path = rootObject.poster_path; theMovieDb.release_date = rootObject.release_date; theMovieDb.revenue = rootObject.revenue; theMovieDb.runtime = rootObject.runtime; theMovieDb.status = rootObject.status; theMovieDb.tagline = rootObject.tagline; theMovieDb.title = rootObject.title; theMovieDb.video = rootObject.video; theMovieDb.vote_average = rootObject.vote_average; theMovieDb.vote_count = rootObject.vote_count; return(View(theMovieDb)); }
async protected override Task <DataListPageResult <TmdbItem> > FetchPageAsync(int pageNumber) { if (_config == null) { _config = await TheMovieDb.GetConfiguration(); } if (personID == null) { personID = 0; var resultPerson = await TheMovieDb.SearchPersonAsync(_query, 1); if (resultPerson.Results != null && resultPerson.Results.Count == 1) { personID = resultPerson.Results[0].Id; } } if (personID == 0) { return(new DataListPageResult <TmdbItem>(0, PageSize, pageNumber, new List <TmdbItem>())); } if (_credits == null) { _credits = await TheMovieDb.GetCreditsAsync(personID.Value); } List <TmdbItem> list = new List <TmdbItem>(); var movies = _credits.Cast.Skip((pageNumber - 1) * PageSize).Take((pageNumber - 1) * PageSize + PageSize).Select(r => r.Id); foreach (var movieId in movies) { var movie = await TheMovieDb.GetMovieAsync(movieId); var tmdbItem = new TmdbItem (_config, movie); list.Add(tmdbItem); } return(new DataListPageResult <TmdbItem>(_credits.Cast.Count, PageSize, pageNumber, list)); }
async protected override Task <DataListPageResult <TmdbPerson> > FetchPageAsync(int pageNumber) { if (_config == null) { _config = await TheMovieDb.GetConfiguration(); } var result = await TheMovieDb.SearchPersonAsync(_query, pageNumber); List <TmdbPerson> list; if (result.Results != null) { list = result.Results.Select(PersonFactory).ToList(); } else { list = new List <TmdbPerson>(); } return(new DataListPageResult <TmdbPerson>(result.TotalResults, PageSize, pageNumber, list)); }
public async Task <IActionResult> AddMovie(MovieSearch movieSearch) { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var baseAddress = new Uri("http://api.themoviedb.org/3/"); TheMovieDb theMovieDb = new TheMovieDb { }; using (var httpClient = new HttpClient { BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); // api_key can be requestred on TMDB website using (var response = await httpClient.GetAsync("search/movie?api_key=c1a1318b6fec8983ec3d16aa9efa6b79&query=" + movieSearch.Search)) { string responseData = await response.Content.ReadAsStringAsync(); var model = JsonConvert.DeserializeObject <RootObject>(responseData); foreach (var result in model.Results) { theMovieDb = result; break; } } } await Add(theMovieDb, movieSearch); return(RedirectToAction("HomeAdmin", "Administrator")); }
/// <summary> /// Retrieves the credits for this company /// </summary> /// <param name="page">The request page of the search results, giving 0 will give all results.</param> /// <returns>A page of credits</returns> public async Task <SearchResult <MovieSummary> > CreditsAsync(int page = 1) { return(await TheMovieDb.GetCompanyCreditsAsync(Id, page)); }