/// <summary>
        /// Translates a DBMovieInfo object to a follw.it MovieDTO object.
        /// </summary>
        public static FitMovie MovieToFitMovie(DBMovieInfo movie)
        {
            FitMovie fitMovie = new FitMovie();
            fitMovie.InternalId = movie.ID.GetValueOrDefault();
            fitMovie.Directors = "";
            fitMovie.Writers = "";
            fitMovie.Cast = "";
            fitMovie.Genres = "";
            foreach (var person in movie.Directors) {
                fitMovie.Directors += "|" + person;
            }
            foreach (var person in movie.Writers) {
                fitMovie.Writers += "|" + person;
            }
            foreach (var person in movie.Actors) {
                fitMovie.Cast += "|" + person;
            }
            foreach (var genre in movie.Genres) {
                fitMovie.Genres += "|" + genre;
            }

            fitMovie.Resources = "";
            fitMovie.Locale = "";
            bool foundIMDB = false;

            if (movie.PrimarySource != null && movie.PrimarySource.Provider != null)
                fitMovie.Locale = movie.PrimarySource.Provider.LanguageCode;

            foreach (DBSourceMovieInfo smi in movie.SourceMovieInfo) {
                if (smi.Source == null || smi.Source.Provider == null)
                    continue;

                if (String.IsNullOrEmpty(smi.Identifier))
                    continue;

                fitMovie.Resources += "|"
                    + System.Web.HttpUtility.UrlEncode(smi.Source.Provider.Name)
                    + "="
                    + System.Web.HttpUtility.UrlEncode(smi.Identifier)
                    ;

                if (smi.Source.Provider.Name.ToLower().Contains("imdb"))
                    foundIMDB = true;

                if (string.IsNullOrEmpty(fitMovie.Locale)) {
                    fitMovie.Locale = smi.Source.Provider.LanguageCode;
                }
            }

            if (!foundIMDB) {
                fitMovie.Resources += "|"
                    + "imdb.com="
                    + System.Web.HttpUtility.UrlEncode(movie.ImdbID)
                    ;
            }

            if (MovingPicturesCore.Settings.EnableFollwitFileHashSync)
                fitMovie.FileHash = movie.LocalMedia[0].FileHash ?? "";
            else
                fitMovie.FileHash = "";

            fitMovie.Title = movie.Title ?? "";
            fitMovie.Year = movie.Year.ToString() ?? "";
            fitMovie.Certification = movie.Certification ?? "";
            fitMovie.Language = movie.Language ?? "";
            fitMovie.Tagline = movie.Tagline ?? "";
            fitMovie.Summary = movie.Summary ?? "";
            fitMovie.Score = movie.Score.ToString() ?? "";
            fitMovie.Popularity = movie.Popularity.ToString() ?? "";
            fitMovie.Runtime = movie.Runtime.ToString() ?? "";
            fitMovie.TranslatedTitle = movie.Title ?? "";

            if (movie.ActiveUserSettings.WatchedCount > 0) {
                fitMovie.Watched = true;
                if (movie.WatchedHistory.Count > 0)
                    fitMovie.LastWatchDate = movie.WatchedHistory[movie.WatchedHistory.Count - 1].DateWatched;
            }
            else {
                fitMovie.Watched = false;
                fitMovie.LastWatchDate = DateTime.MinValue;
            }

            fitMovie.UserRating = movie.ActiveUserSettings.UserRating.GetValueOrDefault(0);

            return fitMovie;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a new movie with data to follw.it, and adds it to the user's collection.
 /// </summary>
 public void AddMoviesToCollection(ref FitMovie movie)
 {
     List<FitMovie> movies = new List<FitMovie>() { movie };
     AddMoviesToCollection(ref movies);
 }