public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, Series series)
        {
            var episodes    = _episodeService.GetEpisodesByFileId(episodeFile.Id);
            var newFileName = _buildFileNames.BuildFileName(episodes, series, episodeFile);
            var filePath    = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.RelativePath));

            _logger.Debug("Renaming episode file: {0} to {1}", episodeFile, filePath);

            return(TransferFile(episodeFile, series, episodes, filePath, false));
        }
        public MovieFile MoveMovieFile(MovieFile movieFile, Movie movie)
        {
            var newFileName = _buildFileNames.BuildFileName(movie, movieFile);
            var filePath    = _buildFileNames.BuildFilePath(movie, newFileName, Path.GetExtension(movieFile.RelativePath));

            EnsureMovieFolder(movieFile, movie, filePath);

            _logger.Debug("Renaming movie file: {0} to {1}", movieFile, filePath);

            return(TransferFile(movieFile, movie, filePath, TransferMode.Move));
        }
Example #3
0
 private string BuildSample(List <Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec)
 {
     try
     {
         return(_buildFileNames.BuildFileName(episodes, series, episodeFile, nameSpec));
     }
     catch (NamingFormatException)
     {
         return(string.Empty);
     }
 }
Example #4
0
        private IEnumerable <RenameEpisodeFilePreview> GetPreviews(Series series, List <Episode> episodes, List <EpisodeFile> files)
        {
            foreach (var f in files)
            {
                var file            = f;
                var episodesInFile  = episodes.Where(e => e.EpisodeFileId == file.Id).ToList();
                var episodeFilePath = Path.Combine(series.Path, file.RelativePath);

                if (!episodesInFile.Any())
                {
                    _logger.Warn("File ({0}) is not linked to any episodes", episodeFilePath);
                    continue;
                }

                var seasonNumber = episodesInFile.First().SeasonNumber;
                var newName      = _filenameBuilder.BuildFileName(episodesInFile, series, file);
                var newPath      = _filenameBuilder.BuildFilePath(series, seasonNumber, newName, Path.GetExtension(episodeFilePath));

                if (!episodeFilePath.PathEquals(newPath))
                {
                    yield return(new RenameEpisodeFilePreview
                    {
                        SeriesId = series.Id,
                        SeasonNumber = seasonNumber,
                        EpisodeNumbers = episodesInFile.Select(e => e.EpisodeNumber).ToList(),
                        EpisodeFileId = file.Id,
                        ExistingPath = file.RelativePath,
                        NewPath = series.Path.GetRelativePath(newPath)
                    });
                }
            }
        }
Example #5
0
 private string BuildSample(Movie movie, MovieFile movieFile, NamingConfig nameSpec)
 {
     try
     {
         return(_buildFileNames.BuildFileName(movie, movieFile, nameSpec));
     }
     catch (NamingFormatException)
     {
         return(string.Empty);
     }
 }
Example #6
0
        private IEnumerable <ImageFileResult> ProcessMovieImages(Movie movie, MovieFile movieFile)
        {
            if (movie.Images != null && movie.Images.Any())
            {
                foreach (var image in movie.Images)
                {
                    var source      = _mediaCoverService.GetCoverPath(movie.Id, image.CoverType);
                    var destination = GetMovieImageFilename(_buildFileNames.BuildFileName(movie, movieFile), image.CoverType);

                    yield return(new ImageFileResult(destination.ToString(), source));
                }
            }
        }
Example #7
0
        private IEnumerable <RenameMovieFilePreview> GetPreviews(Movie movie, List <MovieFile> files)
        {
            foreach (var file in files)
            {
                var movieFilePath = Path.Combine(movie.Path, file.RelativePath);

                var newName = _filenameBuilder.BuildFileName(movie, file);
                var newPath = _filenameBuilder.BuildFilePath(movie, newName, Path.GetExtension(movieFilePath));

                if (!movieFilePath.PathEquals(newPath, StringComparison.Ordinal))
                {
                    yield return(new RenameMovieFilePreview
                    {
                        MovieId = movie.Id,
                        MovieFileId = file.Id,
                        ExistingPath = movieFilePath,
                        //NewPath = movie.Path.GetRelativePath(newPath)
                        NewPath = newPath
                    });
                }
            }
        }