public TmdbMovieInfoCompletedEventArgs( TmdbMovie movie, Exception e, bool canceled, object state) : base(e, canceled, state) { _movie = movie; }
private void AssignGenres(ContentItem movie, TmdbMovie tmdbMovie) { var genreTaxonomy = _taxonomyService.GetTaxonomyByName("Genre"); var allGenres = _taxonomyService.GetTerms(genreTaxonomy.Id); var movieGenres = new List<TermPart>(); foreach (var tmdbGenre in tmdbMovie.Genres) { var genre = allGenres.SingleOrDefault(g => g.Name == tmdbGenre.Name); if (genre == null) { genre = _taxonomyService.NewTerm(genreTaxonomy); genre.Name = tmdbGenre.Name; _orchardServices.ContentManager.Create(genre, VersionOptions.Published); } movieGenres.Add(genre); } _taxonomyService.UpdateTerms(movie, movieGenres, "Genre"); }
internal static TheMovieDb.TmdbMovie LookupMovieOnLine(string str) { TmdbMovie currentMovie = new TheMovieDb.TmdbMovie(); try { TmdbApi login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c"); TmdbMovie m = login.MovieSearch(str).FirstOrDefault(); //if( currentMovie = login.MovieSearchByImdb(m.ImdbId).FirstOrDefault(); } catch (Exception ex) { //do nothing } return currentMovie; }
internal static TheMovieDb.TmdbMovie LookupMovieOnLine(string str) { TmdbMovie currentMovie = new TheMovieDb.TmdbMovie(); try { TmdbApi login = new TheMovieDb.TmdbApi("d49ca7319b09616c927940697304294c"); TmdbMovie m = login.MovieSearch(str).FirstOrDefault(); //if( currentMovie = login.MovieSearchByImdb(m.ImdbId).FirstOrDefault(); } catch (Exception ex) { //do nothing } return(currentMovie); }
private void GetMovieImagesWorker(string id, object userState, AsyncOperation asyncOp) { Exception exception = null; TmdbMovie movie = null; try { movie = GetMovieImages(id); } catch (Exception ex) { exception = ex; } var args = new TmdbMovieInfoCompletedEventArgs(movie, exception, false, userState); asyncOp.PostOperationCompleted( e => OnGetMovieImagesCompleted((TmdbMovieInfoCompletedEventArgs)e), args); }
public static void MovieDirectoryList() { try { //declare variables MyMoviesEntities dbContext = new MyMoviesEntities(); List <string> paths = new List <string>(); Dictionary <string, List <string> > movieName = new Dictionary <string, List <string> >(); //get list of movies in db List <Movie> CurrentMovies = new List <Movie>(); CurrentMovies = dbContext.Movies.Select(s => s).ToList(); //Scan Directorys Utility.TreeScan(@"\\MEDIAHUB\media\videos\Downloads\Movies", ref paths); //Put Titles and path in a map foreach (string str in paths) { //format movie name string dir = Path.GetDirectoryName(str); string[] dirParts = dir.Split(Path.DirectorySeparatorChar); string name = dirParts[dirParts.Count() - 1]; //string out year from the title int yearPos = name.IndexOf("("); if (yearPos > 0) { name = name.Substring(0, yearPos); name = name.Trim(); } //string out dash from the title name = name.Replace('-', ':'); List <Movie> dbmovielist = CurrentMovies.Where(m => name.Contains(m.Name) || name.Equals(m.Name)).ToList(); if (!(dbmovielist.Count() > 0)) { if (movieName.ContainsKey(name)) { movieName[name].Add(str); } else { movieName.Add(name, new List <string>()); movieName[name].Add(str); } } }//enf for using (System.IO.StreamWriter file = new System.IO.StreamWriter("Movies Not added.txt")) { foreach (var pair in movieName) { TheMovieDb.TmdbMovie MovieData = Utility.LookupMovieOnLine(pair.Key.ToString()); if (MovieData != null && MovieData.Name == null) { file.WriteLine(pair.Key.ToString() + "---- Not Added"); continue; } Movie currentMovie = new Movie(); List <String> currentPaths = pair.Value.ToList(); currentMovie.Name = pair.Key.ToString(); currentMovie.Released = Convert.ToDateTime(MovieData.Released); currentMovie.Runtime = Convert.ToInt32(MovieData.Runtime); currentMovie.ImdbId = MovieData.ImdbId; dbContext.Movies.Add(currentMovie); dbContext.SaveChanges(); foreach (TmdbGenre genreData in MovieData.Genres) { MovieGenre mg = new MovieGenre(); mg.Genre_ID = dbContext.Genres.FirstOrDefault(g => g.Name == genreData.Name).Id; mg.Movies_ID = currentMovie.Id; dbContext.MovieGenres.Add(mg); dbContext.SaveChanges(); } foreach (String pathData in currentPaths) { MoviePath mp = new MoviePath(); mp.path = pathData; mp.Movies_ID = currentMovie.Id; dbContext.MoviePaths.Add(mp); dbContext.SaveChanges(); } Thread.Sleep(100); } //end for } //end using } //end try catch (Exception ex) { Console.WriteLine(ex.Message); } //end catch } //end method
private static MovieDataSourceQueryResult ConvertTmdbMovie(TmdbMovie m) { if (m.Cast == null) m.Cast = new List<TmdbCastPerson>(); if (m.Genres == null) m.Genres = new List<TmdbGenre>(); return new MovieDataSourceQueryResult { Title = (string.IsNullOrEmpty(m.OriginalName) || m.OriginalName == m.Name) ? m.Name : string.Format("{0} ({1})", m.OriginalName, m.Name), ImdbId = m.ImdbId, TmdbId = m.Id, Plot = m.Overview, Runtime = !string.IsNullOrWhiteSpace(m.Runtime) ? int.Parse(m.Runtime) : 0, Score = (int)(double.Parse(m.Rating, CultureInfo.InvariantCulture) * 10.0), Votes = int.Parse(m.Votes), Poster = GetPoster(m.Posters), Homepage = !string.IsNullOrWhiteSpace(m.Homepage) ? m.Homepage : null, Year = !string.IsNullOrEmpty(m.Released) ? (short)DateTime.Parse(m.Released).Year : (short)-1, Casts = (from c in m.Cast let cc = CreateCast(c) where cc.HasValue select cc.Value).Distinct().ToArray(), Genres = (from g in m.Genres select g.Name).ToArray(), TrailerUrl = !string.IsNullOrWhiteSpace(m.Trailer) ? m.Trailer : null }; }
private void AssignActors(MoviePart movie, TmdbMovie movieInfo) { var movieActors = new List<MovieActorRecord>(); foreach (var tmdbCastMember in movieInfo.Cast.Where(c => c.Job == "Actor").OrderBy(c => c.Order).Take(5)) { var actor = _actorRepository.Fetch(a => a.Name == tmdbCastMember.Name).SingleOrDefault(); if (actor == null) { actor = new ActorRecord {Name = tmdbCastMember.Name}; _actorRepository.Create(actor); } movieActors.Add(new MovieActorRecord {ActorRecord = actor, MoviePartRecord = movie.Record}); } movieActors.ForEach(ma => _movieActorRepository.Create(ma)); }