예제 #1
0
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private MovieModel CreateTestMovie()
        {
            var movieModel = new MovieModel();

            movieModel.Title = "this is a title";
            movieModel.Year = 2008;
            movieModel.Top250 = 2;
            movieModel.ReleaseDate = new DateTime(2008, 02, 03);
            movieModel.Rating = 6.5;
            movieModel.Votes = 199999;
            movieModel.Plot = "This is a plot";
            movieModel.Tagline = "This is a tagline";
            movieModel.Runtime = 199;
            movieModel.Mpaa = "Rated G";
            movieModel.Certification = "USA:G";
            movieModel.SetStudio = "Fox Studios";
            movieModel.Country = new BindingList<string> { "USA", "UK" };
            movieModel.Genre = new BindingList<string> { "Comedy", "Drama" };
            var person1 = new PersonModel("Russell Lewis", role: "Actors person");
            movieModel.Writers = new BindingList<PersonModel> { person1, person1 };
            movieModel.Director = new BindingList<PersonModel> { person1 };
            movieModel.Cast = new BindingList<PersonModel> { person1, person1 };
            movieModel.CurrentPosterImageUrl = "http://cf1.themoviedb.org/posters/011/4cdb8b335e73d605e6000011/toy-story-3-cover.jpg";
            movieModel.CurrentFanartImageUrl = "http://cf1.themoviedb.org/backdrops/0bf/4bc92cb5017a3c57fe0120bf/toy-story-3-thumb.jpg";

            movieModel.AssociatedFiles.AddToMediaCollection(this.CreateTextMediaPathFileModel());

            return movieModel;
        }
예제 #2
0
        /// <summary>
        /// Adds the movie to set.
        /// </summary>
        /// <param name="movie">
        /// The movie.
        /// </param>
        public void AddMovieToSet(MovieModel movie)
        {
            if (string.IsNullOrEmpty(MovieSetManager.GetCurrentSet.SetName))
            {
                XtraMessageBox.Show("No set selected to add movie too");
                return;
            }

            MovieSetManager.AddMovieToCurrentSet(movie);
        }
예제 #3
0
        /// <summary>
        /// Generatoe Movie Output using current IO Handler
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        /// <returns>
        /// The output path
        /// </returns>
        public static string GenerateMovieOutput(MovieModel movieModel)
        {
            switch (Get.InOutCollection.IoType)
            {
                case NFOType.YAMJ:
                    return yamj.GenerateMovieOutput(movieModel);
            }

            return string.Empty;
        }
예제 #4
0
        /// <summary>
        /// Initializes static members of the <see cref="MovieDBFactory"/> class. 
        /// </summary>
        static MovieDBFactory()
        {
            MovieDatabase = new BindingList<MovieModel>();
            currentMovie = new MovieModel();
            galleryGroup = new GalleryItemGroup();
            multiSelectedMovies = new BindingList<MovieModel>();

            inGallery = new BindingList<string>();

            multiSelectedMovies.ListChanged += MultiSelectedMovies_ListChanged;
            MovieDatabase.ListChanged += MovieDB_ListChanged;
        }
예제 #5
0
        public void TestTitleScrape()
        {
            MovieScraperHandler target = new MovieScraperHandler();
            MovieModel movie = new MovieModel();

            movie.ImdbId = "0401792";

            movie.ScraperGroup = "test";

            var result = target.RunSingleScrape(movie, true);

            Assert.IsTrue(result);
            Assert.IsFalse(string.IsNullOrEmpty(movie.Title));
        }
예제 #6
0
        public void RunSingleScrapeTest()
        {
            MovieScraperHandler target = new MovieScraperHandler();
            MovieModel movie = new MovieModel();

            movie.Title = "Sin City";
            movie.ImdbId = "0401792";

            movie.ScraperGroup = "test";

            var result = target.RunSingleScrape(movie, true);

            // Test Title
            Assert.IsTrue(result);

            // Test Year
            Assert.IsTrue(movie.Year == 2005);

            //test  Cast
            Assert.IsTrue(movie.Cast.Count > 0);

        }
예제 #7
0
        /// <summary>
        /// Converts the media path import database into a MovieModel DB.
        /// </summary>
        public static void ConvertMediaPathImportToDB()
        {
            cancelImport = false;

            var db = MediaPathDBFactory.GetMediaPathMoviesUnsorted();

            var count = 0;

            MovieDBFactory.ImportProgressMaximum = db.Count;

            ImportDatabase.Clear();
            ImportDuplicatesDatabase.Clear();

            var getFiles = new string[1];
            var currentGetPathFiles = string.Empty;

            UI.Windows7UIFactory.StartProgressState(db.Count);
            
            foreach (var file in db)
            {
                if (cancelImport)
                {
                    break;
                }

                MovieDBFactory.ImportProgressCurrent = count;

                MovieDBFactory.ImportProgressStatus = string.Format("Processing: " + file.PathAndFileName.Replace("{", "{{").Replace("}", "}}"));

                if (file.Path != currentGetPathFiles)
                {
                    getFiles = FileHelper.GetFilesRecursive(file.Path, "*.*").ToArray();
                    currentGetPathFiles = file.Path;
                }

                var videoSource = file.DefaultVideoSource;

                if (MovieNaming.IsBluRay(file.PathAndFileName))
                {
                    videoSource = "Bluray";
                }
                else if (MovieNaming.IsDVD(file.PathAndFileName))
                {
                    videoSource = "DVD";
                }
                else
                {
                    var detect = Tools.IO.DetectType.FindVideoSource(file.PathAndFileName);

                    if (!string.IsNullOrEmpty(detect))
                    {
                        videoSource = detect;
                    }
                }

                string title = MovieNaming.GetMovieName(file.PathAndFileName, file.MediaPathType);
                var movieModel = new MovieModel
                    {
                        Title = title,
                        Year = MovieNaming.GetMovieYear(file.PathAndFileName),
                        ScraperGroup = file.ScraperGroup,
                        VideoSource = videoSource,
                        NfoPathOnDisk = FindNFO(file.FilenameWithOutExt, FindFilePath(title, file), getFiles),
                        PosterPathOnDisk = FindPoster(file.FilenameWithOutExt, FindFilePath(title, file), getFiles),
                        FanartPathOnDisk = FindFanart(file.FilenameWithOutExt, FindFilePath(title, file), getFiles)
                    };

                if (!string.IsNullOrEmpty(movieModel.NfoPathOnDisk))
                {
                    InOut.OutFactory.LoadMovie(movieModel);
                    movieModel.ChangedText = false;
                }

                var result = (from m in ImportDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList();

                if (result.Count == 0)
                {
                    if (!string.IsNullOrEmpty(movieModel.PosterPathOnDisk))
                    {
                        movieModel.GenerateSmallPoster(movieModel.PosterPathOnDisk);
                        movieModel.ChangedPoster = false;
                    }

                    if (!string.IsNullOrEmpty(movieModel.FanartPathOnDisk))
                    {
                        movieModel.GenerateSmallFanart(movieModel.FanartPathOnDisk);
                        movieModel.ChangedFanart = false;
                    }

                    movieModel.AssociatedFiles.AddToMediaCollection(file);

                    // Does the movie exist in our current DB?
                    var result2 = (from m in MovieDBFactory.MovieDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList();
                    if (result2.Count > 0)
                    {
                        if (movieModel.Year != null)
                        {
                            var r = (from m in result2 where m.Year == movieModel.Year select m).ToList();
                            if (r.Count > 0)
                            {
                                // We already have a movie with that name and year, mark as dupe
                                ImportDuplicatesDatabase.Add(movieModel);
                            }
                        }
                        else
                        {
                            // No year, so we can't ensure it's a dupe
                            ImportDuplicatesDatabase.Add(movieModel);
                        }
                    }
                    
                    // Add it to the list anyway, since there's no implementation of any action on duplicates.
                    ImportDatabase.Add(movieModel);
                }
                else
                {
                    var r = (from m in result where m.Year == movieModel.Year select m).ToList();
                    if (Regex.IsMatch(file.PathAndFileName.ToLower(), @"(disc|disk|part|cd|vob|ifo|bup)", RegexOptions.IgnoreCase))
                    {
                        // Only associate with an existing movie if its not a dupe
                        result[0].AssociatedFiles.AddToMediaCollection(file);
                    }
                    else if (r.Count == 0)
                    {
                        // Same title, different year
                        ImportDatabase.Add(movieModel);
                    }
                    else
                    {
                        // Dont count a disc or part as a dupe or movies with different years
                        ImportDuplicatesDatabase.Add(movieModel);
                        // Add it to the list anyway, since there's no implementation of any action on duplicates.
                        ImportDatabase.Add(movieModel);
                    }
                }

                count++;
                UI.Windows7UIFactory.SetProgressValue(count);
            }

            UI.Windows7UIFactory.StopProgressState();
        }
예제 #8
0
        /// <summary>
        /// Saves the movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        public void SaveMovie(MovieModel movieModel)
        {
            string actualTrailerFileName = "";
            string actualTrailerFileNameExt = "";
            string actualFilePath = movieModel.AssociatedFiles.Media[0].FileModel.Path;
            string actualFileName = movieModel.AssociatedFiles.Media[0].FileModel.FilenameWithOutExt;
            string currentTrailerUrl = movieModel.CurrentTrailerUrl;

            MovieSaveSettings movieSaveSettings = Get.InOutCollection.CurrentMovieSaveSettings;

            string nfoPath = string.IsNullOrEmpty(movieSaveSettings.NfoPath)
                                 ? actualFilePath
                                 : movieSaveSettings.NfoPath;

            string posterPath = Downloader.ProcessDownload(
                movieModel.CurrentPosterImageUrl, DownloadType.Binary, Section.Movies);

            string fanartPathFrom = Downloader.ProcessDownload(
                movieModel.CurrentFanartImageUrl, DownloadType.Binary, Section.Movies);

            string trailerPathFrom = Downloader.ProcessDownload(
                movieModel.CurrentTrailerUrl, DownloadType.AppleBinary, Section.Movies);

            string nfoXml = GenerateOutput.GenerateMovieOutput(movieModel);

            string nfoTemplate;
            string posterTemplate;
            string fanartTemplate;
            string trailerTemplate;
            string setPosterTemplate;
            string setFanartTemplate;

            if (MovieNaming.IsDVD(movieModel.GetBaseFilePath))
            {
                actualFilePath = MovieNaming.GetDvdPath(movieModel.GetBaseFilePath);
                actualFileName = MovieNaming.GetDvdName(movieModel.GetBaseFilePath);

                nfoTemplate = movieSaveSettings.DvdNfoNameTemplate;
                posterTemplate = movieSaveSettings.DvdPosterNameTemplate;
                fanartTemplate = movieSaveSettings.DvdFanartNameTemplate;
                trailerTemplate = movieSaveSettings.DvdTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.DvdSetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.DvdSetFanartNameTemplate;
            }
            else if (MovieNaming.IsBluRay(movieModel.GetBaseFilePath))
            {
                actualFilePath = MovieNaming.GetBluRayPath(movieModel.GetBaseFilePath);
                actualFileName = MovieNaming.GetBluRayName(movieModel.GetBaseFilePath);

                nfoTemplate = movieSaveSettings.BlurayNfoNameTemplate;
                posterTemplate = movieSaveSettings.BlurayPosterNameTemplate;
                fanartTemplate = movieSaveSettings.BlurayFanartNameTemplate;
                trailerTemplate = movieSaveSettings.BlurayTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.BluraySetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.BluraySetFanartNameTemplate;
            }
            else
            {
                nfoTemplate = movieSaveSettings.NormalNfoNameTemplate;
                posterTemplate = movieSaveSettings.NormalPosterNameTemplate;
                fanartTemplate = movieSaveSettings.NormalFanartNameTemplate;
                trailerTemplate = movieSaveSettings.NormalTrailerNameTemplate;
                setPosterTemplate = movieSaveSettings.NormalSetPosterNameTemplate;
                setFanartTemplate = movieSaveSettings.NormalSetFanartNameTemplate;
            }

            if (!string.IsNullOrEmpty(currentTrailerUrl))
            {
                actualTrailerFileName = currentTrailerUrl.Substring(currentTrailerUrl.LastIndexOf('/')+1, currentTrailerUrl.LastIndexOf('.') - currentTrailerUrl.LastIndexOf('/')-1);
                actualTrailerFileNameExt = currentTrailerUrl.Substring(currentTrailerUrl.LastIndexOf('.')+1);
            }
            
            string nfoOutputName = nfoTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName);

            string posterOutputName =
                posterTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<ext>", "jpg");

            string fanartOutputName =
                fanartTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<ext>", "jpg");

            string trailerOutputName =
                trailerTemplate.Replace("<path>", actualFilePath).Replace("<filename>", actualFileName).Replace(
                    "<trailername>", actualTrailerFileName).Replace("<ext>", actualTrailerFileNameExt);

            string setPosterOutputPath = setPosterTemplate.Replace("<path>", actualFilePath).Replace(
                "<filename>", actualFileName);

            string setFanartOutputPath = setFanartTemplate.Replace("<path>", actualFilePath).Replace(
                "<filename>", actualFileName);

            // Handle Set Images
            List<string> sets = MovieSetManager.GetSetsContainingMovie(movieModel);

            if (sets.Count > 0)
            {
                foreach (string setName in sets)
                {
                    MovieSetModel set = MovieSetManager.GetSet(setName);

                    MovieSetObjectModel setObjectModel =
                        (from s in set.Movies where s.MovieUniqueId == movieModel.MovieUniqueId select s).
                            SingleOrDefault();

                    string currentSetPosterPath = setPosterOutputPath.Replace("<setname>", setName).Replace(
                        "<ext>", ".jpg");

                    string currentSetFanartPath = setFanartOutputPath.Replace("<setname>", setName).Replace(
                        "<ext>", ".jpg");

                    if (setObjectModel.Order == 1)
                    {
                        if (File.Exists(set.PosterUrl))
                        {
                            File.Copy(set.PosterUrl, currentSetPosterPath);
                        }

                        if (File.Exists(set.FanartUrl))
                        {
                            File.Copy(set.FanartUrl, currentSetFanartPath);
                        }
                    }
                    else
                    {
                        if (File.Exists(set.PosterUrl) && File.Exists(currentSetPosterPath))
                        {
                            File.Delete(currentSetPosterPath);
                        }

                        if (File.Exists(set.FanartUrl) && File.Exists(currentSetFanartPath))
                        {
                            File.Delete(currentSetFanartPath);
                        }
                    }
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Nfo)
            {
                try
                {
                    this.WriteNFO(nfoXml, nfoOutputName);
                    movieModel.ChangedText = false;
                    Log.WriteToLog(
                        LogSeverity.Info, 0, "NFO Saved To Disk for " + movieModel.Title, nfoPath + nfoOutputName);
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving NFO Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Poster ||
                movieSaveSettings.IoType == MovieIOType.Images)
            {
                try
                {
                    if (!string.IsNullOrEmpty(movieModel.CurrentPosterImageUrl))
                    {
                        this.CopyFile(posterPath, posterOutputName);
                        movieModel.ChangedPoster = false;
                        Log.WriteToLog(
                            LogSeverity.Info, 
                            0, 
                            "Poster Saved To Disk for " + movieModel.Title, 
                            posterPath + " -> " + posterOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Poster Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Fanart ||
                movieSaveSettings.IoType == MovieIOType.Images)
            {
                try
                {
                    if (!string.IsNullOrEmpty(movieModel.CurrentFanartImageUrl))
                    {
                        this.CopyFile(fanartPathFrom, fanartOutputName);
                        movieModel.ChangedFanart = false;
                        Log.WriteToLog(
                            LogSeverity.Info, 
                            0, 
                            "Fanart Saved To Disk for " + movieModel.Title, 
                            fanartPathFrom + " -> " + fanartOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Fanart Failed for " + movieModel.Title, ex.Message);
                }
            }

            if (movieSaveSettings.IoType == MovieIOType.All || movieSaveSettings.IoType == MovieIOType.Trailer)
            {
                try
                {
                    if (!string.IsNullOrEmpty(movieModel.CurrentTrailerUrl))
                    {
                        this.CopyFile(trailerPathFrom, trailerOutputName);
                        movieModel.ChangedTrailer = false;
                        Log.WriteToLog(
                            LogSeverity.Info,
                            0,
                            "Trailer Saved To Disk for " + movieModel.Title,
                            trailerPathFrom + " -> " + trailerOutputName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteToLog(LogSeverity.Error, 0, "Saving Trailer Failed for " + movieModel.Title, ex.Message);
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Removes the movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        public void RemoveMovie(MovieModel movieModel)
        {
            MovieSetObjectModel foundObj =
                (from m in this.Movies where m.MovieUniqueId == movieModel.MovieUniqueId select m).SingleOrDefault();

            if (foundObj == null)
            {
                return;
            }

            this.Movies.Remove(foundObj);
        }
예제 #10
0
        /// <summary>
        /// The get scraper id.
        /// </summary>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// The scraper id
        /// </returns>
        private static string GetScraperID(string scraperNameString, MovieModel movie)
        {
            var results = new BindingList<QueryResult>();
            var query = new Query
                {
                    Results = results, Title = movie.Title, Year = movie.Year.ToString(), ImdbId = movie.ImdbId 
                };

            var scraperName = (ScraperList)Enum.Parse(typeof(ScraperList), scraperNameString);

            if (scraperName == ScraperList.Imdb || scraperName == ScraperList.TheMovieDB)
            {
                if (string.IsNullOrEmpty(movie.ImdbId) || string.IsNullOrEmpty(movie.TmdbId))
                {
                    MovieScrapeFactory.QuickSearchTmdb(query);

                    if (query.Results.Count > 0)
                    {
                        if (string.IsNullOrEmpty(movie.ImdbId))
                        {
                            movie.ImdbId = query.Results[0].ImdbID;
                        }

                        if (string.IsNullOrEmpty(movie.TmdbId))
                        {
                            movie.TmdbId = query.Results[0].TmdbID;
                        }
                    }
                }
            }

            switch (scraperName)
            {
                case ScraperList.Imdb:
                    return "tt" + movie.ImdbId;
                case ScraperList.TheMovieDB:
                    return movie.TmdbId;
                case ScraperList.Apple:
                    return movie.Title;
                case ScraperList.Allocine:

                    if (string.IsNullOrEmpty(movie.AllocineId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.Allocine select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.AllocineId = query.Results[0].AllocineId;
                        }
                    }

                    return movie.AllocineId;

                case ScraperList.FilmAffinity:

                    if (string.IsNullOrEmpty(movie.FilmAffinityId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.FilmAffinity select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.FilmAffinityId = query.Results[0].FilmAffinityId;
                        }
                    }

                    return movie.FilmAffinityId;
                case ScraperList.FilmDelta:

                    if (string.IsNullOrEmpty(movie.FilmDeltaId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.FilmDelta select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.FilmDeltaId = query.Results[0].FilmDeltaId;
                        }
                    }

                    return movie.FilmDeltaId;
                case ScraperList.FilmUp:

                    if (string.IsNullOrEmpty(movie.FilmUpId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.FilmUp select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.FilmUpId = query.Results[0].FilmUpId;
                        }
                    }

                    return movie.FilmUpId;
                case ScraperList.FilmWeb:

                    if (string.IsNullOrEmpty(movie.FilmWebId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.FilmWeb select s).SingleOrDefault();

                        scraper.SearchSite(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.FilmWebId = query.Results[0].FilmWebId;
                        }
                    }

                    return movie.FilmWebId;
                case ScraperList.Impawards:
                    return movie.ImpawardsId;
                case ScraperList.MovieMeter:

                    if (string.IsNullOrEmpty(movie.MovieMeterId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.MovieMeter select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.MovieMeterId = query.Results[0].MovieMeterId;
                        }
                    }

                    return movie.MovieMeterId;
                case ScraperList.OFDB:

                    if (string.IsNullOrEmpty(movie.OfdbId))
                    {
                        var scraper =
                            (from s in scrapers where s.ScraperName == ScraperList.OFDB select s).SingleOrDefault();

                        scraper.SearchViaBing(query, 0, string.Empty);

                        if (query.Results.Count > 0)
                        {
                            movie.OfdbId = query.Results[0].OfdbId;
                        }
                    }

                    return movie.OfdbId;

                case ScraperList.Kinopoisk:
                    return movie.KinopoiskId;
                case ScraperList.Sratim:
                    return movie.SratimId;
                case ScraperList.RottenTomato:
                    return movie.RottenTomatoId;
            }

            return null;
        }
예제 #11
0
        /// <summary>
        /// The add movie to set.
        /// </summary>
        /// <param name="movie">The movie.</param>
        /// <param name="setName">The set name.</param>
        /// <param name="order">The order.</param>
        public static void AddMovieToSet(MovieModel movie, string setName, int? order = null)
        {
            MovieSetModel check = (from m in database where m.SetName == setName select m).SingleOrDefault();

            var movieSetObjectModel = new MovieSetObjectModel { MovieUniqueId = movie.MovieUniqueId };

            if (order != null)
            {
                movieSetObjectModel.Order = (int)order;
            }

            if (check == null)
            {
                var movieSetModel = new MovieSetModel();

                movieSetModel.Movies.Add(movieSetObjectModel);
                movieSetModel.SetName = setName;

                database.Add(movieSetModel);
            }
            else
            {
                check.AddMovie(movie, order);
            }

            movie.ChangedText = true;

            SetAllMoviesChangedInCurrentSet();
        }
예제 #12
0
        /// <summary>
        /// The load movie.
        /// </summary>
        /// <param name="movie">The movie.</param>
        /// <returns>
        /// Always returns true
        /// </returns>
        public static bool LoadMovie(MovieModel movie)
        {
            try
            {
                if (Get.InOutCollection.IoType == NFOType.YAMJ)
                {
                    yamj.LoadMovie(movie);
                }
                else if (Get.InOutCollection.IoType == NFOType.XBMC)
                {
                    xbmc.LoadMovie(movie);
                }

                return true;
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "LoadMovie", exception.Message);
                return false;
            }
        }
예제 #13
0
        /// <summary>
        /// The run single scrape.
        /// </summary>
        /// <param name="movieModel">The movie model.</param>
        public static void RunSingleScrape(MovieModel movieModel)
        {
            var movieModelList = new BindingList<MovieModel>
                {
                    movieModel
                };

            RunMultiScrape(movieModelList);
        }
예제 #14
0
        /// <summary>
        /// The set current movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        public static void SetCurrentMovie(MovieModel movieModel)
        {
            if (movieModel.MultiSelectModel)
            {
                PopulateMultiSelectMovieModel(movieModel);
            }

            currentMovie = movieModel;
            InvokeCurrentMovieChanged(new EventArgs());
        }
예제 #15
0
        /// <summary>
        /// The replace movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        public static void ReplaceMovie(MovieModel movieModel)
        {
            MovieModel getMovieInDatabase =
                (from m in MovieDatabase where m.MovieUniqueId == movieModel.MovieUniqueId select m).SingleOrDefault();

            int index = MovieDatabase.IndexOf(getMovieInDatabase);
            movieModel.IsBusy = false;
            MovieDatabase[index] = movieModel;

            if (movieModel.MovieUniqueId == currentMovie.MovieUniqueId)
            {
                SetCurrentMovie(movieModel);
                InvokeCurrentMovieChanged(new EventArgs());
            }
        }
예제 #16
0
 /// <summary>
 /// Is same as current movie.
 /// </summary>
 /// <param name="movieModel">
 /// The movie model.
 /// </param>
 /// <returns>
 /// The is same as current movie.
 /// </returns>
 public static bool IsSameAsCurrentMovie(MovieModel movieModel)
 {
     return movieModel.MovieUniqueId == currentMovie.MovieUniqueId;
 }
예제 #17
0
        /// <summary>
        /// The scrape rating.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeRating(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            double output;

            bool scrapeSuccess = scraper.ScrapeRating(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Rating = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
예제 #18
0
        /// <summary>
        /// The scrape poster.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapePoster(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList<ImageDetailsModel> output;

            bool scrapeSuccess = scraper.ScrapePoster(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                if (output.Count > 0)
                {
                    movie.CurrentPosterImageUrl = output[0].UriFull.ToString();
                }

                movie.AlternativePosters = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
예제 #19
0
        /// <summary>
        /// The scrape language.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeLanguage(
            IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList<string> output;

            bool scrapeSuccess = scraper.ScrapeLanguage(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Language = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
예제 #20
0
 /// <summary>
 /// Initializes static members of the <see cref="ImportMoviesFactory"/> class. 
 /// </summary>
 static ImportMoviesFactory()
 {
     ImportDatabase = new BindingList<MovieModel>();
     ImportDuplicatesDatabase = new BindingList<MovieModel>();
     CurrentRecord = new MovieModel();
 }
예제 #21
0
 /// <summary>
 /// Updates the movie model.
 /// </summary>
 /// <param name="movieModel">The movie model.</param>
 /// <param name="result">The result to gather values from</param>
 private void UpdateMovieModel(MovieModel movieModel, QueryResult result)
 {
     movieModel.YanfoeID = result.YanfoeId;
     movieModel.Title = result.Title;
     movieModel.Year = result.Year;
     movieModel.ImdbId = result.ImdbID;
     movieModel.TmdbId = result.TmdbID;
     movieModel.SmallPoster = result.Poster;
 }
예제 #22
0
        /// <summary>
        /// The set current movie.
        /// </summary>
        /// <param name="id">
        /// The movie ID
        /// </param>
        public static void SetCurrentMovie(string id)
        {
            if (IsMultiSelected)
            {
                currentMovie = multiSelect;
                currentMovie.PropertyChanged += MultiSelectMovie_PropertyChanged;
            }
            else
            {
                MovieModel movie = (from m in MovieDatabase where m.MovieUniqueId == id select m).SingleOrDefault();

                if (movie != null)
                {
                    SetCurrentMovie(movie);
                }
            }
        }
예제 #23
0
        /// <summary>
        /// The scrape movie.
        /// </summary>
        /// <param name="movieModel">The movie Model.</param>
        private static void ScrapeMovie(MovieModel movieModel)
        {
            var bgw = new BackgroundWorker();
            bgw.DoWork += BgwSingle_DoWork;
            bgw.RunWorkerCompleted += BgwSingle_RunWorkerCompleted;

            MovieModel scrape = movieModel.Clone();

            bgw.RunWorkerAsync(scrape);
        }
예제 #24
0
        /// <summary>
        /// Gets the set return list for output handlers.
        /// </summary>
        /// <param name="movieModel">The movie model.</param>
        /// <returns>SetReturnModel Collection</returns>
        public static List<SetReturnModel> GetSetReturnList(MovieModel movieModel)
        {
            var sets = GetSetsContainingMovie(movieModel);

            return sets.Select(set => new SetReturnModel { SetName = set, Order = GetOrderOfMovieInSet(set, movieModel) }).ToList();
        }
예제 #25
0
        /// <summary>
        /// Adds the movie to current set.
        /// </summary>
        /// <param name="movie">The movie to add to set</param>
        public static void AddMovieToCurrentSet(MovieModel movie)
        {
            MovieSetObjectModel check =
                (from m in currentSet.Movies where m.MovieUniqueId == movie.MovieUniqueId select m).SingleOrDefault();

            if (check != null)
            {
                XtraMessageBox.Show(string.Format("{0} already exists in set {1}", movie.Title, currentSet.SetName));
                return;
            }

            currentSet.AddMovie(movie);
            InvokeCurrentSetMoviesChanged(new EventArgs());
        }
예제 #26
0
        /// <summary>
        /// The add movie.
        /// </summary>
        /// <param name="movieModel">
        /// The movie model.
        /// </param>
        /// <param name="order">
        /// The order.
        /// </param>
        public void AddMovie(MovieModel movieModel, int? order = null)
        {
            int orderVal = 0;

            if (order == null)
            {
                orderVal = this.Movies.Count + 1;
            }
            else
            {
                orderVal = (int)order;
            }

            this.Movies.Add(new MovieSetObjectModel { MovieUniqueId = movieModel.MovieUniqueId, Order = orderVal });
        }
예제 #27
0
        /// <summary>
        /// Gets the order of movie in set.
        /// </summary>
        /// <param name="setName">The movie set model name.</param>
        /// <param name="movieModel">The movie model.</param>
        /// <returns>
        /// The order the movie falls in the set
        /// </returns>
        public static int? GetOrderOfMovieInSet(string setName, MovieModel movieModel)
        {
            MovieSetModel movieSetModel = (from s in database where s.SetName == setName select s).SingleOrDefault();

            if (movieSetModel == null)
            {
                return null;
            }

            var check = (from m in movieSetModel.Movies where m.MovieUniqueId == movieModel.MovieUniqueId select m.Order).ToList();

            if (check.Count() > 0)
            {
                return check[0];
            }

            return null;
        }
예제 #28
0
        private static bool GetOutResult(ScrapeFields scrapeFields, string scrapeGroup, MovieModel movie, string noneValue, MovieScraperGroupModel scraperGroup, bool outResult)
        {
            if (!string.IsNullOrEmpty(scrapeGroup) && scrapeGroup != noneValue)
            {
                bool result;
                ScrapeValues(movie, scrapeGroup, scrapeFields, out result);

                if (!result)
                {
                    outResult = false;
                }
            }
            return outResult;
        }
예제 #29
0
 /// <summary>
 /// Finds the sets containing movie.
 /// </summary>
 /// <param name="movie">The movie.</param>
 /// <returns>Collection of sets containing a movie</returns>
 public static List<string> GetSetsContainingMovie(MovieModel movie)
 {
     return GetSetsContainingMovie(movie.MovieUniqueId);
 }
예제 #30
0
        /// <summary>
        /// Fills a multi select moviemodel object with items that are the same from SelectedMovies collection
        /// </summary>
        /// <param name="movieModel">
        /// The movie Model.
        /// </param>
        private static void PopulateMultiSelectMovieModel(MovieModel movieModel)
        {
            bool scraperGroupIsSame = true;
            string scraperGroupBaseValue = string.Empty;

            bool yearGroupIsSame = true;
            int? yearGroupBaseValue = null;

            bool plotGroupIsSame = true;
            string plotGroupBaseValue = string.Empty;

            bool outlineGroupIsSame = true;
            string outlineGroupBaseValue = string.Empty;

            bool taglineGroupIsSame = true;
            string taglineGroupBaseValue = string.Empty;

            bool origionalTitleGroupIsSame;
            string origionalTitleGroupBaseValue = string.Empty;

            bool studioGroupIsSame = true;
            string studioGroupBaseValue = string.Empty;

            bool releasedGroupIsSame = true;
            var releasedGroupBaseValue = new DateTime?();

            bool directorsGroupIsSame = true;
            string directorsGroupBaseValue = string.Empty;

            bool writersGroupIsSame = true;
            string writersGroupBaseValue = string.Empty;

            bool genreGroupIsSame = true;
            string genreGroupBaseValue = string.Empty;

            bool languagesGroupIsSame = true;
            string languagesGroupBaseValue = string.Empty;

            bool countryGroupIsSame = true;
            string countryGroupBaseValue = string.Empty;

            bool runtimeGroupIsSame = true;
            string runtimeGroupBaseValue = string.Empty;

            bool ratingGroupIsSame = true;
            double? ratingGroupBaseValue = null;

            bool mpaaGroupIsSame = true;
            string mpaaGroupBaseValue = string.Empty;

            bool sourceGroupIsSame = true;
            string sourceGroupBaseValue = string.Empty;

            bool certGroupIsSame = true;
            string certGroupBaseValue = string.Empty;

            bool top250GroupIsSame = true;
            int? top250GroupBaseValue = null;

            foreach (MovieModel movie in MultiSelectedMovies)
            {
                scraperGroupBaseValue = CheckMultiSelectStringValue(
                    scraperGroupBaseValue, movie.ScraperGroup, out scraperGroupIsSame);
                yearGroupBaseValue = CheckMultiSelectIntValue(yearGroupBaseValue, movie.Year, out yearGroupIsSame);
                plotGroupBaseValue = CheckMultiSelectStringValue(plotGroupBaseValue, movie.Plot, out plotGroupIsSame);
                outlineGroupBaseValue = CheckMultiSelectStringValue(
                    outlineGroupBaseValue, movie.Outline, out outlineGroupIsSame);
                taglineGroupBaseValue = CheckMultiSelectStringValue(
                    taglineGroupBaseValue, movie.Tagline, out taglineGroupIsSame);
                origionalTitleGroupBaseValue = CheckMultiSelectStringValue(
                    origionalTitleGroupBaseValue, movie.OrigionalTitle, out origionalTitleGroupIsSame);
                studioGroupBaseValue = CheckMultiSelectStringValue(
                    studioGroupBaseValue, movie.SetStudio, out studioGroupIsSame);
                releasedGroupBaseValue = CheckMultiSelectDateValue(
                    releasedGroupBaseValue, movie.ReleaseDate, out releasedGroupIsSame);
                directorsGroupBaseValue = CheckMultiSelectStringValue(
                    directorsGroupBaseValue, movie.DirectorAsString, out directorsGroupIsSame);
                writersGroupBaseValue = CheckMultiSelectStringValue(
                    writersGroupBaseValue, movie.WritersAsString, out writersGroupIsSame);
                genreGroupBaseValue = CheckMultiSelectStringValue(
                    genreGroupBaseValue, movie.GenreAsString, out genreGroupIsSame);
                languagesGroupBaseValue = CheckMultiSelectStringValue(
                    languagesGroupBaseValue, movie.LanguageAsString, out languagesGroupIsSame);
                countryGroupBaseValue = CheckMultiSelectStringValue(
                    countryGroupBaseValue, movie.CountryAsString, out countryGroupIsSame);
                runtimeGroupBaseValue = CheckMultiSelectStringValue(
                    runtimeGroupBaseValue, movie.RuntimeInHourMin, out runtimeGroupIsSame);
                ratingGroupBaseValue = CheckMultiSelectDoubleValue(
                    ratingGroupBaseValue, movie.Rating, out ratingGroupIsSame);
                mpaaGroupBaseValue = CheckMultiSelectStringValue(mpaaGroupBaseValue, movie.Mpaa, out mpaaGroupIsSame);
                sourceGroupBaseValue = CheckMultiSelectStringValue(
                    sourceGroupBaseValue, movie.VideoSource, out sourceGroupIsSame);
                certGroupBaseValue = CheckMultiSelectStringValue(
                    sourceGroupBaseValue, movie.Certification, out certGroupIsSame);
                top250GroupBaseValue = CheckMultiSelectIntValue(
                    top250GroupBaseValue, movie.Top250, out top250GroupIsSame);
            }

            if (scraperGroupIsSame)
            {
                movieModel.ScraperGroup = scraperGroupBaseValue;
            }

            if (yearGroupIsSame)
            {
                movieModel.Year = yearGroupBaseValue;
            }

            if (plotGroupIsSame)
            {
                movieModel.Plot = plotGroupBaseValue;
            }

            if (outlineGroupIsSame)
            {
                movieModel.Outline = outlineGroupBaseValue;
            }

            if (taglineGroupIsSame)
            {
                movieModel.Tagline = taglineGroupBaseValue;
            }

            if (studioGroupIsSame)
            {
                movieModel.SetStudio = studioGroupBaseValue;
            }

            if (releasedGroupIsSame)
            {
                movieModel.ReleaseDate = releasedGroupBaseValue;
            }

            if (directorsGroupIsSame)
            {
                movieModel.DirectorAsString = directorsGroupBaseValue;
            }

            if (writersGroupIsSame)
            {
                movieModel.WritersAsString = writersGroupBaseValue;
            }

            if (genreGroupIsSame)
            {
                movieModel.GenreAsString = genreGroupBaseValue;
            }

            if (languagesGroupIsSame)
            {
                movieModel.LanguageAsString = languagesGroupBaseValue;
            }

            if (countryGroupIsSame)
            {
                movieModel.CountryAsString = countryGroupBaseValue;
            }

            if (runtimeGroupIsSame)
            {
                movieModel.RuntimeInHourMin = runtimeGroupBaseValue;
            }

            if (ratingGroupIsSame)
            {
                movieModel.Rating = ratingGroupBaseValue;
            }

            if (mpaaGroupIsSame)
            {
                movieModel.Mpaa = mpaaGroupBaseValue;
            }

            if (sourceGroupIsSame)
            {
                movieModel.VideoSource = sourceGroupBaseValue;
            }

            if (certGroupIsSame)
            {
                movieModel.Certification = certGroupBaseValue;
            }

            if (top250GroupIsSame)
            {
                movieModel.Top250 = top250GroupBaseValue;
            }
        }