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.Path));

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

            return(MoveFile(episodeFile, series, episodes, filePath));
        }
示例#2
0
        public string 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.Path));

            MoveFile(episodeFile, filePath);

            return(filePath);
        }
示例#3
0
        private JsonResponse <NamingSampleResource> GetExamples(NamingConfigResource config)
        {
            var nameSpec = config.InjectTo <NamingConfig>();

            var series = new Core.Tv.Series
            {
                SeriesType = SeriesTypes.Standard,
                Title      = "Series Title"
            };

            var episode1 = new Episode
            {
                SeasonNumber  = 1,
                EpisodeNumber = 1,
                Title         = "Episode Title (1)"
            };

            var episode2 = new Episode
            {
                SeasonNumber  = 1,
                EpisodeNumber = 2,
                Title         = "Episode Title (2)"
            };

            var episodeFile = new EpisodeFile
            {
                Quality = new QualityModel(Quality.HDTV720p),
                Path    = @"C:\Test\Series.Title.S01E01.720p.HDTV.x264-EVOLVE.mkv"
            };

            var sampleResource = new NamingSampleResource();

            sampleResource.SingleEpisodeExample = _buildFileNames.BuildFilename(new List <Episode> {
                episode1
            },
                                                                                series,
                                                                                episodeFile,
                                                                                nameSpec);

            episodeFile.Path = @"C:\Test\Series.Title.S01E01-E02.720p.HDTV.x264-EVOLVE.mkv";

            sampleResource.MultiEpisodeExample = _buildFileNames.BuildFilename(new List <Episode> {
                episode1, episode2
            },
                                                                               series,
                                                                               episodeFile,
                                                                               nameSpec);

            return(sampleResource.AsResponse());
        }
        private IEnumerable <RenameEpisodeFilePreview> GetPreviews(Series series, List <Episode> episodes, List <EpisodeFile> files)
        {
            foreach (var file in files)
            {
                var episodesInFile = episodes.Where(e => e.EpisodeFileId == file.Id).ToList();

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

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

                if (!file.Path.PathEquals(newPath))
                {
                    yield return(new RenameEpisodeFilePreview
                    {
                        SeriesId = series.Id,
                        SeasonNumber = seasonNumber,
                        EpisodeNumbers = episodesInFile.Select(e => e.EpisodeNumber).ToList(),
                        EpisodeFileId = file.Id,
                        ExistingPath = GetRelativePath(series.Path, file.Path),
                        NewPath = GetRelativePath(series.Path, newPath)
                    });
                }
            }
        }
示例#5
0
 private string BuildSample(List <Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec)
 {
     try
     {
         return(_buildFileNames.BuildFilename(episodes, series, episodeFile, nameSpec));
     }
     catch (NamingFormatException ex)
     {
         return(String.Empty);
     }
 }