Пример #1
0
        public ManualImportItem ReprocessItem(string path, string downloadId, int movieId, string releaseGroup, QualityModel quality, List <Language> languages)
        {
            var rootFolder = Path.GetDirectoryName(path);
            var movie      = _movieService.GetMovie(movieId);

            var downloadClientItem = GetTrackedDownload(downloadId)?.DownloadItem;

            var languageParse = LanguageParser.ParseLanguages(path);

            if (languageParse.Count <= 1 && languageParse.First() == Language.Unknown && movie != null)
            {
                languageParse = new List <Language> {
                    movie.OriginalLanguage
                };
                _logger.Debug("Language couldn't be parsed from release, fallback to movie original language: {0}", movie.OriginalLanguage.Name);
            }

            var localEpisode = new LocalMovie
            {
                Movie                   = movie,
                FileMovieInfo           = Parser.Parser.ParseMoviePath(path),
                DownloadClientMovieInfo = downloadClientItem == null ? null : Parser.Parser.ParseMovieTitle(downloadClientItem.Title),
                Path         = path,
                SceneSource  = SceneSource(movie, rootFolder),
                ExistingFile = movie.Path.IsParentPath(path),
                Size         = _diskProvider.GetFileSize(path),
                Languages    = (languages?.SingleOrDefault() ?? Language.Unknown) == Language.Unknown ? languageParse : languages,
                Quality      = quality.Quality == Quality.Unknown ? QualityParser.ParseQuality(path) : quality,
                ReleaseGroup = releaseGroup.IsNullOrWhiteSpace() ? Parser.Parser.ParseReleaseGroup(path) : releaseGroup,
            };

            return(MapItem(_importDecisionMaker.GetDecision(localEpisode, downloadClientItem), rootFolder, downloadId, null));
        }
Пример #2
0
        public ManualImportItem ReprocessItem(string path, string downloadId, int seriesId, int?seasonNumber, List <int> episodeIds, string releaseGroup, QualityModel quality, Language language)
        {
            var rootFolder = Path.GetDirectoryName(path);
            var series     = _seriesService.GetSeries(seriesId);

            if (episodeIds.Any())
            {
                var downloadClientItem = GetTrackedDownload(downloadId)?.DownloadItem;

                var localEpisode = new LocalEpisode
                {
                    Series                    = series,
                    Episodes                  = _episodeService.GetEpisodes(episodeIds),
                    FileEpisodeInfo           = Parser.Parser.ParsePath(path),
                    DownloadClientEpisodeInfo = downloadClientItem == null ? null : Parser.Parser.ParseTitle(downloadClientItem.Title),
                    Path         = path,
                    SceneSource  = SceneSource(series, rootFolder),
                    ExistingFile = series.Path.IsParentPath(path),
                    Size         = _diskProvider.GetFileSize(path),
                    ReleaseGroup = releaseGroup.IsNullOrWhiteSpace() ? Parser.Parser.ParseReleaseGroup(path) : releaseGroup,
                    Language     = language == Language.Unknown ? LanguageParser.ParseLanguage(path) : language,
                    Quality      = quality.Quality == Quality.Unknown ? QualityParser.ParseQuality(path) : quality
                };

                return(MapItem(_importDecisionMaker.GetDecision(localEpisode, downloadClientItem), rootFolder, downloadId, null));
            }

            // This case will happen if the user selected a season, but didn't select the episodes in the season then changed the language or quality.
            // Instead of overriding their season selection let it persist and reject it with an appropriate error.

            if (seasonNumber.HasValue)
            {
                var downloadClientItem = GetTrackedDownload(downloadId)?.DownloadItem;

                var localEpisode = new LocalEpisode
                {
                    Series                    = series,
                    Episodes                  = new List <Episode>(),
                    FileEpisodeInfo           = Parser.Parser.ParsePath(path),
                    DownloadClientEpisodeInfo = downloadClientItem == null
                                           ? null
                                           : Parser.Parser.ParseTitle(downloadClientItem.Title),
                    Path         = path,
                    SceneSource  = SceneSource(series, rootFolder),
                    ExistingFile = series.Path.IsParentPath(path),
                    Size         = _diskProvider.GetFileSize(path),
                    ReleaseGroup = releaseGroup.IsNullOrWhiteSpace() ? Parser.Parser.ParseReleaseGroup(path) : releaseGroup,
                    Language     = language == Language.Unknown ? LanguageParser.ParseLanguage(path) : language,
                    Quality      = quality.Quality == Quality.Unknown ? QualityParser.ParseQuality(path) : quality
                };

                return(MapItem(new ImportDecision(localEpisode, new Rejection("Episodes not selected")), rootFolder, downloadId, null));
            }

            return(ProcessFile(rootFolder, rootFolder, path, downloadId, series));
        }
Пример #3
0
        public ManualImportItem ReprocessItem(string path, string downloadId, int movieId, QualityModel quality, List <Language> languages)
        {
            var rootFolder = Path.GetDirectoryName(path);
            var movie      = _movieService.GetMovie(movieId);

            var downloadClientItem = GetTrackedDownload(downloadId)?.DownloadItem;

            var localEpisode = new LocalMovie
            {
                Movie                   = movie,
                FileMovieInfo           = Parser.Parser.ParseMoviePath(path),
                DownloadClientMovieInfo = downloadClientItem == null ? null : Parser.Parser.ParseMovieTitle(downloadClientItem.Title),
                Path         = path,
                SceneSource  = SceneSource(movie, rootFolder),
                ExistingFile = movie.Path.IsParentPath(path),
                Size         = _diskProvider.GetFileSize(path),
                Languages    = (languages?.SingleOrDefault() ?? Language.Unknown) == Language.Unknown ? LanguageParser.ParseLanguages(path) : languages,
                Quality      = quality.Quality == Quality.Unknown ? QualityParser.ParseQuality(path) : quality
            };

            return(MapItem(_importDecisionMaker.GetDecision(localEpisode, downloadClientItem), rootFolder, downloadId, null));
        }