예제 #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();
        }
예제 #2
0
파일: Movie.cs 프로젝트: cocytus/epidaurus
        public MovieAtStorage AddStorageLocation(StorageLocation sl, string relativePath, string samplePath, string cleanedName)
        {
            if (!MovieAtStorages.Any())
                AddedAt = DateTime.Now;

            var mas = new MovieAtStorage()
            {
                RelativePath = relativePath,
                SampleRelativePath = samplePath,
                StorageLocation = sl,
                CleanedName = cleanedName
            };

            MovieAtStorages.Add(mas);
            return mas;
        }
예제 #3
0
 private MovieScanResult[] ScanStorageLocation(StorageLocation sl)
 {
     var scanner = _scannerFactory.CreateFromTypeId(sl.Type, sl.Data1, sl.Data2, sl.Rebase);
     var scanResult = scanner.Scan();
     var movieScanResults = MovieFinder.FindMovies(scanResult).ToArray();
     return movieScanResults;
 }
예제 #4
0
 private Task<Tuple<StorageLocation, MovieScanResult[]>> StartScanStorageLocation(StorageLocation sl)
 {
     return Task.Factory.StartNew(() =>
         {
             try
             {
                 return Tuple.Create(sl, ScanStorageLocation(sl));
             }
             catch(Exception ex)
             {
                 _log.Error("Failed to scan StorageLocation {0}: {1}", sl.Name, ex.Message);
                 throw;
             }
         });
 }
예제 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the StorageLocations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStorageLocations(StorageLocation storageLocation)
 {
     base.AddObject("StorageLocations", storageLocation);
 }
예제 #6
0
 /// <summary>
 /// Create a new StorageLocation object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 /// <param name="data1">Initial value of the Data1 property.</param>
 /// <param name="data2">Initial value of the Data2 property.</param>
 /// <param name="rebase">Initial value of the Rebase property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 public static StorageLocation CreateStorageLocation(global::System.Int32 id, global::System.String name, global::System.String type, global::System.String data1, global::System.String data2, global::System.String rebase, global::System.Boolean active)
 {
     StorageLocation storageLocation = new StorageLocation();
     storageLocation.Id = id;
     storageLocation.Name = name;
     storageLocation.Type = type;
     storageLocation.Data1 = data1;
     storageLocation.Data2 = data2;
     storageLocation.Rebase = rebase;
     storageLocation.Active = active;
     return storageLocation;
 }