/// <inheritdoc /> public Movie MapMovieToEntity(TMDbLib.Objects.Movies.Movie match, string imageUri) { return(new Movie { TmdbId = match.Id, ImdbId = match.ImdbId, Title = match.Title, ReleaseDate = match.ReleaseDate, Overview = match.Overview, Adult = match.Adult, Collection = match.BelongsToCollection?.Name.Replace(" - Collezione", string.Empty), Duration = TimeSpan.FromMinutes(match.Runtime.GetValueOrDefault()), Genres = match.Genres.Select(g => new Genre { Id = g.Id, Name = g.Name }).ToList(), ImageUri = imageUri, OriginalLanguage = match.OriginalLanguage, OriginalTitle = match.OriginalTitle, Popularity = match.Popularity, VoteAverage = match.VoteAverage, VoteCount = match.VoteCount, }); }
public Models.Movie Mapper(TMDbLib.Objects.Movies.Movie movie) { return(new Models.Movie { Adult = movie.Adult, BackdropPath = string.IsNullOrEmpty(movie.BackdropPath) ? string.Empty : "http://image.tmdb.org/t/p/w1280" + movie.BackdropPath, BelongsToCollection = movie.BelongsToCollection, Budget = movie.Budget, Genres = movie.Genres.Select(g => Mapper(g)).ToArray(), Homepage = movie.Homepage, Id = movie.Id, ImdbId = movie.ImdbId, OriginalLanguage = movie.OriginalLanguage, OriginalTitle = movie.OriginalTitle, Overview = movie.Overview, Popularity = movie.Popularity, PosterPath = string.IsNullOrEmpty(movie.PosterPath) ? string.Empty : "http://image.tmdb.org/t/p/w780" + movie.PosterPath, ProductionCompanies = movie.ProductionCompanies.Select(c => Mapper(c)).ToArray(), ProductionCountries = movie.ProductionCountries.Select(c => Mapper(c)).ToArray(), ReleaseDate = movie.ReleaseDate.Value, Revenue = movie.Revenue, Runtime = movie.Runtime.HasValue ? movie.Runtime.Value : 0, SpokenLanguages = movie.SpokenLanguages.Select(l => Mapper(l)).ToArray(), Status = movie.Status, Tagline = movie.Tagline, Title = movie.Title, Video = movie.Video, VoteAverage = movie.VoteAverage, VoteCount = movie.VoteCount }); }
// 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 Movie(TMDbLib.Objects.Movies.Movie movieTMDb) { ProductionCompanies = movieTMDb.ProductionCompanies.Select(p => p.Id).ToArray(); ProductionCountries = movieTMDb.ProductionCountries.Select(p => p.Iso_3166_1).ToArray(); ReleaseDate = movieTMDb.ReleaseDate; Revenue = movieTMDb.Revenue; PosterPath = movieTMDb.PosterPath; Runtime = movieTMDb.Runtime; SpokenLanguages = movieTMDb.SpokenLanguages.Select(sl => sl.Iso_639_1).ToArray(); Status = movieTMDb.Status; Tagline = movieTMDb.Tagline; Title = movieTMDb.Title; VoteAverage = movieTMDb.VoteAverage; Popularity = movieTMDb.Popularity; OriginalTitle = movieTMDb.OriginalTitle; Adult = movieTMDb.Adult; BackdropPath = movieTMDb.BackdropPath; Budget = movieTMDb.Budget; Overview = movieTMDb.Overview; Homepage = movieTMDb.Homepage; Id = movieTMDb.Id; ImdbId = movieTMDb.ImdbId; OriginalLanguage = movieTMDb.OriginalLanguage; Genres = movieTMDb.Genres.Select(g => g.Id).ToArray(); VoteCount = movieTMDb.VoteCount; }
private static Models.Movie MapDbItem(Movie match) { var res = new Models.Movie { Id = match.Id, Title = match.Title, OriginalTitle = match.OriginalTitle, ReleaseDate = match.ReleaseDate, Overview = match.Overview, Duration = TimeSpan.FromMinutes(match.Runtime.GetValueOrDefault()), Adult = match.Adult, Genres = match.Genres.Select(g => new MovieGenere { Id = g.Id, Name = g.Name }).ToArray(), ImdbId = match.ImdbId, OriginalLanguage = match.OriginalLanguage, Popularity = match.Popularity, PosterPath = match.PosterPath, VoteAverage = match.VoteAverage, VoteCount = match.VoteCount, Collection = match.BelongsToCollection?.Name.Replace(" - Collezione", string.Empty) }; //// match.Similar; // // match.Videos; return(res); }
public ActionResult SendMovies(IQueryable <Movie> movies, TMDbLib.Objects.Movies.Movie movie, TMDbClient client) { int id; CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); for (id = 0; id <= 30; id++) { try { movie = client.GetMovieAsync(id).Result; } catch (NullReferenceException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } if (movie != null) { if (movie.Adult == false) { Movie objMovie = movies.FirstOrDefault(x => x.RemoteId.Equals(movie.Id)); if (objMovie != null) //achei no banco local { objMovie.Original_title = movie.OriginalTitle; objMovie.Release_date = movie.ReleaseDate; objMovie.Original_Language = new CultureInfo(movie.OriginalLanguage).DisplayName; objMovie.Description = movie.Overview; objMovie.Budget = movie.Budget; objMovie.Vote_average = movie.VoteAverage; } else //não achei esse movie no banco local { objMovie = new Movie { RemoteId = movie.Id, Original_title = movie.OriginalTitle, Release_date = movie.ReleaseDate, Description = movie.Overview, Original_Language = new CultureInfo(movie.OriginalLanguage).DisplayName, Budget = movie.Budget, Vote_average = movie.VoteAverage }; //depois de atribuir tudo db.Movies.Add(objMovie); db.SaveChanges(); } } } } return(View(movies)); }
public void addToDB(int id, string Owner, string Format, string Original) { TMDbMovie movie = db.GetMovieAndCreditsWitchID(id); System.Diagnostics.Debug.WriteLine("Add " + movie.Title); //Todo test owner/Format db.AddMovie(movie, Owner, Format, Original); }
public void Refresh() { int index = 0; for (int x = 0; x < MovieGrid.ColumnDefinitions.Count; x++) { if (index < ActiveMovies.Count) { Rental m = ActiveMovies[index]; StackPanel sp = new StackPanel(); TextBlock title = new TextBlock(); TextBlock returnDate = new TextBlock(); Image image = new Image(); TMDbClient client = new TMDbClient(Helper.TmdbApi.APIKey); SearchContainer <SearchMovie> results = client.SearchMovieAsync(m.Movie.Title).Result; var movieId = results.Results.Where(r => r.Title.Equals(m.Movie.Title, StringComparison.OrdinalIgnoreCase)).First().Id; TMDbLib.Objects.Movies.Movie movie = client.GetMovieAsync(movieId).Result; string baseUrl = "https://image.tmdb.org/t/p/"; string size = "w500"; // "w500" för mindre version string path = movie.PosterPath; image.Source = new BitmapImage(new Uri($"{baseUrl}{size}{path}")); title.Cursor = Cursors.Hand; title.Text = $"{m.Movie.Title}"; title.FontSize = 18; title.FontWeight = FontWeight.FromOpenTypeWeight(700); title.Foreground = Brushes.White; title.HorizontalAlignment = HorizontalAlignment.Center; title.Margin = new Thickness(5, 5, 5, 0); returnDate.Cursor = Cursors.Hand; returnDate.Text = $"Active until: {m.ReturnDate}"; returnDate.FontSize = 12; returnDate.FontStyle = FontStyles.Italic; returnDate.Foreground = Brushes.White; returnDate.HorizontalAlignment = HorizontalAlignment.Center; returnDate.Margin = new Thickness(5, 5, 5, 8); image.Cursor = Cursors.Hand; image.MaxHeight = 210; sp.Children.Add(title); sp.Children.Add(returnDate); sp.Children.Add(image); MovieGrid.Children.Add(sp); sp.MouseUp += Mouse_Up; Grid.SetColumn(sp, x); index++; } } }
private void AddImages(Movie movie, MovieModel importedMovie) { ExecuteWithExceptionHandling(() => { _movieManager.AddPoster(movie, importedMovie); _movieManager.AddBackdrop(movie, importedMovie); } , string.Format("An error occurred while creating images for movie {0} with id {1}", movie.Title, movie.Id.ToString())); }
public ActionResult DisplayMovieDetails(int id) { TMDbClient client = new TMDbClient("c768e7308be543456c95aca82d106fcb"); TMDbMovie movie = client.GetMovieAsync(id, TMDbLib.Objects.Movies.MovieMethods.Credits).Result; System.Diagnostics.Debug.WriteLine(" " + id); System.Diagnostics.Debug.WriteLine(" " + movie); //TMDbMovie movie = jsonstring; System.Diagnostics.Debug.WriteLine("" + movie.Title); //return View(movie); return(PartialView(movie)); }
private static float GetMatch(Movie movie, AnalyzedItem item) { float res = 0; var dtt = LevenshteinDistance.ComputeIgnoreCase(item.Title, movie.Title); var dto = LevenshteinDistance.ComputeIgnoreCase(item.Title, movie.OriginalTitle); float score1 = Math.Max(0, 5 - Math.Min(dtt, dto)); res += score1; //if (string.Equals(item.Title, movie.Title, StringComparison.OrdinalIgnoreCase) // || string.Equals(item.Title, movie.OriginalTitle, StringComparison.OrdinalIgnoreCase)) //{ // res += 3; //} if (!string.IsNullOrEmpty(item.SubTitle)) { var dst = LevenshteinDistance.ComputeIgnoreCase(item.SubTitle, movie.Title); var dso = LevenshteinDistance.ComputeIgnoreCase(item.SubTitle, movie.OriginalTitle); float score2 = Math.Max(0, 3 - Math.Min(dst, dso)); res += score2; } //if (string.Equals(item.SubTitle, movie.Title, StringComparison.OrdinalIgnoreCase) // || string.Equals(item.SubTitle, movie.OriginalTitle, StringComparison.OrdinalIgnoreCase)) //{ // res += 2; //} if (LooksLike(item.Year, movie.ReleaseDate)) { res += 3; } if (item.Duration > TimeSpan.Zero && movie.Runtime.HasValue) { var mtime = TimeSpan.FromMinutes(movie.Runtime.Value); var diff = Math.Abs(item.Duration.Subtract(mtime).TotalMinutes); var score = (int)Math.Max(5 - diff, 0); { res += score; } } else { res += 1; } return(res / 16); }
private void ImportMovies() { _maxItemCount = 1000; DateTime now = DateTime.Now; DateTime startYear = new DateTime(now.Year - 2, now.Month, now.Day); SearchContainer <SearchMovie> movies = _movieManager.Discover(startYear); int resultCount = movies.TotalResults; if (_maxItemCount > resultCount) { _maxItemCount = resultCount; } int totalPageCount = _maxItemCount / RebootConstants.PageSize; for (int i = 0; i < totalPageCount;) { foreach (var m in movies.Results) { string title = "Unknown"; string id = Guid.Empty.ToString(); try { Movie movie = _movieManager.Get(m.Id); title = movie.Title; id = movie.Id.ToString(); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(title) || IDTableExtesions.HasIDTableEntry <MovieModel>(id)) { continue; } MovieModel importedMovie = _movieManager.GetMappedMovie(movie); AddGenres(movie, importedMovie); AddLanguageToMovie(movie, importedMovie); AddCrew(movie, importedMovie); AddCast(movie, importedMovie); AddImages(movie, importedMovie); AddTrailers(movie, importedMovie); AddProductionCompanies(movie, importedMovie); //Finally Add the movie to the database _movieManager.Save(importedMovie); } catch (Exception ex) { Log.Error(string.Format("An error occurred while creating movie {0} with id {1}", title, id), ex, title); } } i++; movies = _movieManager.Discover(startYear, i); } }
public Movie ParseSingleMovie(TMDbLib.Objects.Movies.Movie movie, bool fav, bool seen) { return(new Movie() { Id = movie.Id, Title = movie.Title, TitleFull = movie.Title, ReleaseDate = movie.ReleaseDate != null?movie.ReleaseDate.Value.Year.ToString() : "N/A", Overview = movie.Overview, PosterPath = $"https://image.tmdb.org/t/p/w185/{movie.PosterPath}", VoteAverage = movie.VoteAverage, VoteAverageStar = movie.VoteAverage * 5 / 10, Favourite = fav, Seen = seen }); }
public Entry ConvertMovie(TmdbMovie tmdbMovie) { // checks if (tmdbMovie == null) { return(DefaultEntry.Instance); } if (string.IsNullOrEmpty(tmdbMovie.Title)) { return(DefaultEntry.Instance); } if (!tmdbMovie.ReleaseDate.HasValue || tmdbMovie.ReleaseDate.Value < new DateTime(1870, 1, 1)) { return(DefaultEntry.Instance); } if (tmdbMovie.Adult) { return(DefaultEntry.Instance); } if (string.IsNullOrEmpty(tmdbMovie.PosterPath)) { return(DefaultEntry.Instance); } if (tmdbMovie.Popularity < MinPopularity) { return(DefaultEntry.Instance); } // build basic values var id = Id.FromMovieNumber(tmdbMovie.Id); var movie = new Movie(id) { Title = tmdbMovie.Title, Popularity = tmdbMovie.Popularity }; // TODO: create the connections return(movie); }
public DetailPage(int id) { InitializeComponent(); WaitingView.Opacity = 1.0; Task.Run(async() => { var client = new TMDbClient(TMDbAPIKey.Key); var taskMovie = client.GetMovieAsync(id); var taskSimilar = client.GetMovieSimilarAsync(id); var taskCredit = client.GetMovieCreditsAsync(id); var taskVideo = client.GetMovieVideosAsync(id); var movie = await taskMovie; Device.BeginInvokeOnMainThread(async() => { WaitingView.Opacity = 0.0; _movie = movie; BindingContext = movie; var credit = await taskCredit; var cast = new CastListModel { Items = credit.Cast }; CastList.BindingContext = cast; var similars = await taskSimilar; _similars = new MovieListModel { Title = "Similar Movies", Items = similars.Results, }; SimilarList.BindingContext = _similars; var videos = await taskVideo; int i = 0; foreach (var video in videos.Results) { if (video.Site == "YouTube") { i++; var button = new Button { Text = $"Watch trailer #{i}", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; button.Clicked += (s, e) => { #if USE_VIDEOPAGE Navigation.PushAsync(new VideoPage(video.Key)); #else AppControl appControl = new AppControl(); appControl.ApplicationId = "com.samsung.tv.cobalt-yt"; appControl.Operation = AppControlOperations.Default; appControl.ExtraData.Add("PAYLOAD", $"#play?v={video.Key}"); AppControl.SendLaunchRequest(appControl); #endif Console.WriteLine($"ID : {video.Key}"); }; Console.WriteLine($"Video : {video.Key} {video.Name} {video.Site}"); ButtonArea.Children.Add(button); InputEvents.GetEventHandlers(button).Add( new RemoteKeyHandler((arg) => { if (arg.KeyName == RemoteControlKeyNames.Up) { ScrollView.ScrollToAsync(0, 0, true); arg.Handled = true; } }, RemoteControlKeyTypes.KeyDown )); } if (i > 2) { break; } } }); }); }
private void Movies_SelectionChanged(object sender, SelectionChangedEventArgs e) { ActorList.Items.Clear(); try { Movie current = (Movie)MovieList.SelectedItem; MovieTitle.Text = current.Title; APIMovie movie = client.GetMovieAsync(current.MovieID).Result; // Use the API to get the movie poster Uri apiUri = new Uri("http://image.tmdb.org/t/p/w342//"); string posterPath = movie.PosterPath; System.UriBuilder uriBuilder = new System.UriBuilder(apiUri); uriBuilder.Path += posterPath; // TODO: Check if this is null Poster.Source = new BitmapImage(uriBuilder.Uri); MovieTitle.Text = current.Title; MovieOverview.Text = movie.Overview; GenreText.Text = current.Genre; int rating = current.Rating; if (rating >= 4) { RatingCircle.Stroke = Brushes.Green; RatingNumber.Text = rating.ToString(); RatingNumber.Foreground = Brushes.Green; } else if (rating >= 2 && rating < 4) { RatingCircle.Stroke = Brushes.Gold; RatingNumber.Text = rating.ToString(); RatingNumber.Foreground = Brushes.Gold; } else { RatingCircle.Stroke = Brushes.Red; RatingNumber.Text = rating.ToString(); RatingNumber.Foreground = Brushes.Red; } using (var context = new MovieRentalEntities()) { var query = context.Credits.Where(c => c.MovieID == current.MovieID).ToList(); foreach (Credit credit in query) { var actor = context.Actors.Where(a => a.ActorID == credit.ActorID).Single(); ActorList.Items.Add(actor); } ActorList.DisplayMemberPath = "FullName"; } } catch (NullReferenceException error) { Console.WriteLine(error.Message); } }
//Todo Format/Owner public void AddMovie(TMDbMovie movie, string Owner, string Format, string Original) { if (!db.Movies.Where(m => m.Title == movie.Title).Any()) { List <Crew> crew = movie.Credits.Crew; Regisseur tmpRegisseur = null; // Get/ Add Regisseur foreach (var crewmember in crew) { System.Diagnostics.Debug.WriteLine(crewmember.Job); if (crewmember.Job == "Director") { var tmpRegisseurs = db.Regisseurs.Where(r => r.FirstName + " " + r.LastName == crewmember.Name); if (tmpRegisseurs.Any()) { tmpRegisseur = tmpRegisseurs.First(); } else { var namesplit = crewmember.Name.Split(" "); tmpRegisseur = new Regisseur { FirstName = namesplit[0], LastName = crewmember.Name.Substring(namesplit[0].Length + 1) }; db.Regisseurs.Add(tmpRegisseur); db.SaveChanges(); } tmpRegisseur = db.Regisseurs.Where(r => r.FirstName + " " + r.LastName == crewmember.Name).First(); } } OwnerEnum owner; switch (Owner) { case "MS": owner = OwnerEnum.MS; break; case "CS": owner = OwnerEnum.CS; break; case "NS": owner = OwnerEnum.NS; break; case "TS": owner = OwnerEnum.TS; break; default: owner = OwnerEnum.MS; break; } FormatEnum format; switch (Format) { case "DVD": format = FormatEnum.DVD; break; case "BD": format = FormatEnum.BD; break; case "BD3D": format = FormatEnum.BD3D; break; default: format = FormatEnum.BD; break; } bool original; if (Original == "false") { original = false; } else { original = true; } // Add Movie to db db.Movies.Add(new Movie { Title = movie.Title, Description = movie.Overview, ReleaseDate = movie.ReleaseDate.GetValueOrDefault(), Runtime = movie.Runtime.GetValueOrDefault().ToString(), RegisseurID = tmpRegisseur.ID, Owner = owner, Format = format, Original = original }); db.SaveChanges(); Movie tmpMovie = null; //Get Movie try { tmpMovie = db.Movies.Where(m => m.Title == movie.Title).First(); } catch { db.Movies.Add(new Movie { Title = movie.Title, Description = movie.Overview, ReleaseDate = movie.ReleaseDate.Value, Runtime = movie.Runtime.Value.ToString(), RegisseurID = tmpRegisseur.ID, }); db.SaveChanges(); tmpMovie = db.Movies.Where(m => m.Title == movie.Title).First(); } // Add Genres foreach (var genre in movie.Genres) { Genre tmpGenre = null; try { tmpGenre = db.Genres.Where(g => g.Name == genre.Name).First(); } catch { db.Genres.Add(new Genre { Name = genre.Name }); db.SaveChanges(); tmpGenre = db.Genres.Where(g => g.Name == genre.Name).First(); } if (!db.GenreMovies.Where(gm => gm.GenreID == tmpGenre.ID && gm.MovieID == tmpMovie.ID).Any()) { db.GenreMovies.Add(new GenreMovie { GenreID = tmpGenre.ID, MovieID = tmpMovie.ID }); db.SaveChanges(); } } //db.GenreMovies foreach (var castmember in movie.Credits.Cast) { Actor actor = null; var actorquery = db.Actors.Where(a => a.FirstName + " " + a.LastName == castmember.Name); if (!actorquery.Any()) { db.Actors.Add(new Actor { FirstName = castmember.Name.Split(" ")[0], LastName = (castmember.Name.Length > castmember.Name.Split(" ")[0].Length + 1) ? castmember.Name.Substring(castmember.Name.Split(" ")[0].Length + 1) : "", }); db.SaveChanges(); actorquery = db.Actors.Where(a => a.FirstName + " " + a.LastName == castmember.Name); } actor = actorquery.First(); var actormoviequery = db.ActorMovies.Where(am => am.ActorID == actor.ID && am.MovieID == tmpMovie.ID); if (!actormoviequery.Any()) { db.ActorMovies.Add(new ActorMovie { ActorID = actor.ID, MovieID = tmpMovie.ID, Character = castmember.Character }); db.SaveChanges(); } } } }
private void AddGenres(Movie movie, MovieModel importedMovie) { ExecuteWithExceptionHandling(() => _movieManager.AddGenres(movie, importedMovie) , string.Format("An error occurred while creating Genres for movie {0} with id {1}", movie.Title, movie.Id.ToString())); }
public void InitializeMovieView() { if (Movies.DisplayMovies.Count > 0) { for (int y = 0; y < MovieGrid.RowDefinitions.Count; y++) { for (int x = 0; x < MovieGrid.ColumnDefinitions.Count; x++) { if (Index < Movies.DisplayMovies.Count) { Movie m = Movies.DisplayMovies[Index]; StackPanel sp = new StackPanel(); TextBlock title = new TextBlock(); Image image = new Image(); TMDbClient client = new TMDbClient(Helper.TmdbApi.APIKey); SearchContainer <SearchMovie> results = client.SearchMovieAsync(m.Title).Result; try { var movieId = results.Results.Where(r => r.Title.Equals(m.Title, StringComparison.InvariantCultureIgnoreCase)).First().Id; TMDbLib.Objects.Movies.Movie movie = client.GetMovieAsync(movieId).Result; string baseUrl = "https://image.tmdb.org/t/p/"; string size = "w500"; // "w500" för mindre version / "orginal" för full storlek string path = movie.PosterPath; image.Source = new BitmapImage(new Uri($"{baseUrl}{size}{path}")); } catch { image.Source = new BitmapImage(new Uri(Helper.Image.BjornAvatarURL)); } title.Cursor = Cursors.Hand; title.Text = m.Title; title.Foreground = Brushes.White; title.FontSize = 18; title.TextAlignment = TextAlignment.Center; title.TextWrapping = TextWrapping.WrapWithOverflow; title.Margin = new Thickness(10, 0, 10, 0); image.Cursor = Cursors.Hand; image.Margin = new Thickness(10, 20, 10, 5); image.MaxHeight = 280; sp.Children.Add(image); sp.Children.Add(title); MovieGrid.Children.Add(sp); sp.MouseUp += Mouse_Up; Grid.SetRow(sp, y); Grid.SetColumn(sp, x); Index++; } } } } else { // Text vid 0 resultat på sökning StackPanel sp = new StackPanel(); TextBlock tb = new TextBlock(); tb.Text = Helper.Message.SearchReturnedNoResultsLine1; tb.Background = Brushes.Black; tb.Foreground = Brushes.White; tb.FontSize = 35; tb.FontWeight = FontWeight.FromOpenTypeWeight(700); TextBlock tb2 = new TextBlock(); tb2.Text = Helper.Message.SearchReturnedNoResultsLine2; tb2.Background = Brushes.Black; tb2.Foreground = Brushes.White; tb2.FontSize = 20; tb2.FontWeight = FontWeight.FromOpenTypeWeight(500); sp.Children.Add(tb); sp.Children.Add(tb2); MovieGrid.Children.Add(sp); Grid.SetRow(sp, 0); Grid.SetColumn(sp, 0); Grid.SetColumnSpan(sp, 4); } }
protected void Page_Load(object sender, EventArgs e) { this.hide.Value = Request.QueryString["movie_id"]; Movies_id = Convert.ToInt32(this.hide.Value); TMDbClient client = new TMDbClient("e1b3af48ad2d28cab2fb3ac299948c08"); TMDbLib.Objects.Movies.Movie movie = client.GetMovieAsync(this.hide.Value).Result; string str1 = ""; string str2 = ""; string str3 = ""; string image = ""; if (movie.PosterPath == null) { image = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQP_gfN4auNNye--K2rquUrHBCrMl4QYedWLnLT14qSdT2AWPPo"; } else { image = "https://image.tmdb.org/t/p/w185_and_h278_bestv2" + movie.PosterPath; } str1 += "<img src='" + image + "' class='img-responsive' />"; string country = ""; if (movie.ProductionCountries.Count > 0) { country = movie.ProductionCountries[0].Name; } str2 += "<h3 style='font-family: 'Arial';'>" + movie.Title + "</h3><p class='movie_option'><strong>Country: </strong>" + country + "</p>" + "<p class='movie_option'><strong>Language:</strong > " + movie.OriginalLanguage + "</P>" + "<p class='movie_option'><strong>Spoken Language: </strong>"; for (int i = 0; i < movie.SpokenLanguages.Count; i++) { str2 += movie.SpokenLanguages[i].Name + ", "; } str2 += "</P><p class='movie_option'><strong>Genres: </strong>"; for (int i = 0; i < movie.Genres.Count; i++) { str2 += movie.Genres[i].Name + ", "; } try { str2 += "</P><p class='movie_option'><strong>Release date: </strong>" + movie.ReleaseDate.Value.ToString("D", CultureInfo.CreateSpecificCulture("en-US")) + "</p>"; } catch { str2 += "</P><p class='movie_option'><strong>Release date: </strong>" + "" + "</p>"; } str2 += "<p class='movie_option'><strong>Vote: </strong>" + movie.VoteAverage + "</p>"; str2 += "<p class='movie_option'><strong>Vote Count: </strong>" + movie.VoteCount + "</p>" + "<a href='" + "http://www.imdb.com/title/" + movie.ImdbId + "'>Go IMDB Link</a><br/>"; str3 += movie.Overview; client.SetSessionInformation(Program.Session_Id, SessionType.UserSession); SearchContainer <SearchMovie> results = client.AccountGetFavoriteMoviesAsync().Result; foreach (SearchMovie result in results.Results) { if (result.Id == Movies_id) { Favorit_btn.Text = "Remove From Favorite"; } } m_image.Controls.Add(new LiteralControl(str1)); info.Controls.Add(new LiteralControl(str2)); description.Controls.Add(new LiteralControl(str3)); }
private async void Mouse_Up(object sender, MouseButtonEventArgs e) { MovieFocus mf = new MovieFocus(); // -----------------------------------------------------------------------------------------------------------------------------------| // Info from API end -----------------------------------------------------------------------------------------------------------------| // -----------------------------------------------------------------------------------------------------------------------------------| // Centrera fönstret till MainWindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(x => x.IsInitialized); mf.Width = mw.Width - 150; mf.Height = mw.Height - 90; mf.Owner = mw; mf.WindowStartupLocation = WindowStartupLocation.CenterOwner; mf.Show(); // Referera klickad film till MovieFocus var y = Grid.GetRow(sender as UIElement); var x = Grid.GetColumn(sender as UIElement); int i = (y * MovieGrid.ColumnDefinitions.Count + x) + (Page * Movies.MOVIES_PER_PAGE); mf.MovieSelected = Movies.DisplayMovies[i]; // General Info till MovieFocus mf.MovieNameYear.Text = $"{Movies.DisplayMovies[i].Title} " + $"({Movies.DisplayMovies[i].Year})"; mf.MovieImdbRating.Text = $"IMDb Score : {Movies.DisplayMovies[i].Rating}"; // ------------------------------------------------------------------------------------------------------------------------------------| // API-call till TMDB -----------------------------------------------------------------------------------------------------------------| // ------------------------------------------------------------------------------------------------------------------------------------| try { // TMDB id från FilmTitel TMDbClient client = new TMDbClient(Helper.TmdbApi.APIKey); SearchContainer <SearchMovie> results = await client.SearchMovieAsync(Movies.DisplayMovies[i].Title); var movieId = results.Results.Where(m => m.Title.Equals(Movies.DisplayMovies[i].Title, StringComparison.OrdinalIgnoreCase)).First().Id; TMDbLib.Objects.Movies.Movie movie = await client.GetMovieAsync(movieId); // Synopsis till MovieFocus mf.Synopsis.Text = movie.Overview.Length < 350 ? movie.Overview : $"{movie.Overview.Substring(0, 349)}..."; // Synopsis Björn-Mode if (Status.N00bMode) { mf.Synopsis.Text = String.Join(' ', mf.Synopsis.Text.Split(' ').Select((x, y) => x = y % 7 != 0 ? x : "Björn")); } // Poster till MovieFocus string baseUrl = "https://image.tmdb.org/t/p/"; string size = "w500"; // "w500" för mindre version / "orginal" för full storlek string path = movie.PosterPath; mf.MoviePoster.Source = new BitmapImage(new Uri($"{baseUrl}{size}{path}")); } catch { mf.MoviePoster.Source = new BitmapImage(new Uri(Helper.Image.BjornAvatarURL)); mf.Synopsis.Text = String.Concat(mf.Synopsis.Text.Split(' ').Select(x => x = mf.Synopsis.Text.IndexOf(x) % 3 == 0 ? "Björn" : x)); } }