Ejemplo n.º 1
0
        private void ProcessStorageLocationScanResult(StorageLocation sl, MovieScanResult[] newMovieList)
        {
            var previousMoviesAtStorages = sl.MovieSources.ToList();

            foreach (var newMovie in newMovieList.Where(nm => !previousMoviesAtStorages.Any(el => el.RelativePath == nm.Path)))
            {
                Movie movie = null;
                if (newMovie.ImdbId != null)
                    movie = _movieSystemService.TryGetMovieByImdbId(newMovie.ImdbId);

                if (movie == null)
                {
                    movie = CreateMovie(newMovie);
                    _movieSystemService.AddMovie(movie);
                    _log.Info("Adding movie: (Id {0}) {1} ({2})", movie.Id, movie.Title, movie.ImdbId);
                }

                movie.AddStorageLocation(sl, newMovie.Path, newMovie.SamplePath, newMovie.CleanedName);
                _log.Info("Movie at storage added: {0} @ {1} path: {2}", movie.Title, sl.Name, newMovie.Path);
                _movieSystemService.Save();
            }

            var hasPaths = new HashSet<string>(from nm in newMovieList select nm.Path);
            foreach (var oldMovieAtStorage in previousMoviesAtStorages)
            {
                if (!hasPaths.Contains(oldMovieAtStorage.RelativePath))
                {
                    oldMovieAtStorage.Movie.RemoveStorageLocation(sl.Id);
                    _log.Info("Location {0} no longer has {1}", sl.Name, oldMovieAtStorage.CleanedName);
                }
            }

            _movieSystemService.Save();
        }
Ejemplo n.º 2
0
        private static MovieScanResult MakeMovieResult(FileResult movie, bool isSingleMovieInParentFolder, FileResult sample, bool tryFindImdbData)
        {
            var msr = new MovieScanResult()
            {
                Path = movie.Path,
                ImdbId = tryFindImdbData ? TryFindImdbId(movie) : null,
                SamplePath = sample != null ? sample.Path : null,
            };
            short? year;

            msr.CleanedName = CleanName(movie, isSingleMovieInParentFolder, out year);
            msr.Year = year;

            SetSeriesData(msr, movie);
            return msr;
        }
Ejemplo n.º 3
0
        private static void SetSeriesData(MovieScanResult msr, FileResult movie)
        {
            var m = _rexSeriesSeasonEpisode1.Match(movie.Name);
            if (!m.Success)
                m = _rexSeriesSeasonEpisode2.Match(movie.Name);

            if (m.Success)
            {
                msr.SeriesSeason = short.Parse(m.Groups[1].Value);
                msr.SeriesEpisode = short.Parse(m.Groups[2].Value);
            }
            else
            {
                m = _rexSeriesEpisode1.Match(movie.Name);
                if (m.Success)
                    msr.SeriesEpisode = short.Parse(m.Groups[1].Value);
            }
        }
Ejemplo n.º 4
0
 private static Movie CreateMovie(MovieScanResult newMovie)
 {
     return Movie.Create(newMovie.CleanedName, newMovie.ImdbId, newMovie.Year, newMovie.SeriesSeason, newMovie.SeriesEpisode);
 }