Esempio n. 1
0
        /// <summary>
        /// Resolves the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>Season.</returns>
        protected override Season Resolve(ItemResolveArgs args)
        {
            if (args.Parent is Series series && args.IsDirectory)
            {
                var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();

                var path = args.Path;

                var seasonParserResult = SeasonPathParser.Parse(path, true, true);

                var season = new Season
                {
                    IndexNumber = seasonParserResult.SeasonNumber,
                    SeriesId    = series.Id,
                    SeriesName  = series.Name
                };

                if (!season.IndexNumber.HasValue || !seasonParserResult.IsSeasonFolder)
                {
                    var resolver = new Naming.TV.EpisodeResolver(namingOptions);

                    var folderName = System.IO.Path.GetFileName(path);
                    var testPath   = "\\\\test\\" + folderName;

                    var episodeInfo = resolver.Resolve(testPath, true);

                    if (episodeInfo != null)
                    {
                        if (episodeInfo.EpisodeNumber.HasValue && episodeInfo.SeasonNumber.HasValue)
                        {
                            _logger.LogDebug(
                                "Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",
                                path,
                                episodeInfo.SeasonNumber.Value,
                                episodeInfo.EpisodeNumber.Value);

                            return(null);
                        }
                    }
                }

                if (season.IndexNumber.HasValue)
                {
                    var seasonNumber = season.IndexNumber.Value;

                    season.Name = seasonNumber == 0 ?
                                  args.LibraryOptions.SeasonZeroDisplayName :
                                  string.Format(
                        CultureInfo.InvariantCulture,
                        _localization.GetLocalizedString("NameSeasonNumber"),
                        seasonNumber,
                        args.GetLibraryOptions().PreferredMetadataLanguage);
                }

                return(season);
            }

            return(null);
        }
Esempio n. 2
0
        public void GetSeasonNumberFromPathTest(string path, int?seasonNumber, bool isSeasonDirectory)
        {
            var result = SeasonPathParser.Parse(path, true, true);

            Assert.Equal(result.SeasonNumber != null, result.Success);
            Assert.Equal(result.SeasonNumber, seasonNumber);
            Assert.Equal(isSeasonDirectory, result.IsSeasonFolder);
        }
Esempio n. 3
0
        public void GetSeasonNumberFromPathTest(string path, int?seasonNumber)
        {
            var result = SeasonPathParser.Parse(path, true, true);

            Assert.Equal(result.SeasonNumber, seasonNumber);
        }
Esempio n. 4
0
        /// <summary>
        /// Determines whether [is season folder] [the specified path].
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="isTvContentType">if set to <c>true</c> [is tv content type].</param>
        /// <param name="libraryManager">The library manager.</param>
        /// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
        private static bool IsSeasonFolder(string path, bool isTvContentType, ILibraryManager libraryManager)
        {
            var seasonNumber = SeasonPathParser.Parse(path, isTvContentType, isTvContentType).SeasonNumber;

            return(seasonNumber.HasValue);
        }
Esempio n. 5
0
        private int?GetSeasonNumberFromPath(string path)
        {
            var result = SeasonPathParser.Parse(path, true, true);

            return(result.SeasonNumber);
        }