/// <summary> /// Resolve information about episode from path. /// </summary> /// <param name="path">Path.</param> /// <param name="isDirectory">Is path for a directory or file.</param> /// <param name="isNamed">Do we want to use IsNamed expressions.</param> /// <param name="isOptimistic">Do we want to use Optimistic expressions.</param> /// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param> /// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param> /// <returns>Returns null or <see cref="EpisodeInfo"/> object if successful.</returns> public EpisodeInfo?Resolve( string path, bool isDirectory, bool?isNamed = null, bool?isOptimistic = null, bool?supportsAbsoluteNumbers = null, bool fillExtendedInfo = true) { bool isStub = false; string?container = null; string?stubType = null; if (!isDirectory) { var extension = Path.GetExtension(path); // Check supported extensions if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) { // It's not supported. Check stub extensions if (!StubResolver.TryResolveFile(path, _options, out stubType)) { return(null); } isStub = true; } container = extension.TrimStart('.'); } var flags = new FlagParser(_options).GetFlags(path); var format3DResult = new Format3DParser(_options).Parse(flags); var parsingResult = new EpisodePathParser(_options) .Parse(path, isDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo); if (!parsingResult.Success && !isStub) { return(null); } return(new EpisodeInfo(path) { Container = container, IsStub = isStub, EndingEpisodeNumber = parsingResult.EndingEpisodeNumber, EpisodeNumber = parsingResult.EpisodeNumber, SeasonNumber = parsingResult.SeasonNumber, SeriesName = parsingResult.SeriesName, StubType = stubType, Is3D = format3DResult.Is3D, Format3D = format3DResult.Format3D, IsByDate = parsingResult.IsByDate, Day = parsingResult.Day, Month = parsingResult.Month, Year = parsingResult.Year }); }
protected void Set3DFormat(Video video) { var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); var resolver = new Format3DParser(namingOptions, new Naming.Logging.NullLogger()); var result = resolver.Parse(video.Path); Set3DFormat(video, result.Is3D, result.Format3D); }
public EpisodeInfo Resolve(string path, bool IsDirectory, bool fillExtendedInfo = true) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } var isStub = false; string container = null; string stubType = null; if (!IsDirectory) { var extension = Path.GetExtension(path) ?? string.Empty; // Check supported extensions if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) { var stubResult = new StubResolver(_options, _logger).ResolveFile(path); isStub = stubResult.IsStub; // It's not supported. Check stub extensions if (!isStub) { return(null); } stubType = stubResult.StubType; } container = extension.TrimStart('.'); } var flags = new FlagParser(_options).GetFlags(path); var format3DResult = new Format3DParser(_options, _logger).Parse(flags); var parsingResult = new EpisodePathParser(_options, _iRegexProvider) .Parse(path, IsDirectory, fillExtendedInfo); return(new EpisodeInfo { Path = path, Container = container, IsStub = isStub, EndingEpsiodeNumber = parsingResult.EndingEpsiodeNumber, EpisodeNumber = parsingResult.EpisodeNumber, SeasonNumber = parsingResult.SeasonNumber, SeriesName = parsingResult.SeriesName, StubType = stubType, Is3D = format3DResult.Is3D, Format3D = format3DResult.Format3D, IsByDate = parsingResult.IsByDate, Day = parsingResult.Day, Month = parsingResult.Month, Year = parsingResult.Year }); }
private void Test(string input, bool is3D, string?format3D) { var result = Format3DParser.Parse(input, _namingOptions); Assert.Equal(is3D, result.Is3D); if (format3D == null) { Assert.Null(result?.Format3D); } else { Assert.Equal(format3D, result.Format3D, true); } }
private void Test(string input, bool is3D, string format3D, NamingOptions options) { var parser = new Format3DParser(options, new NullLogger()); var result = parser.Parse(input); Assert.AreEqual(is3D, result.Is3D); if (format3D == null) { Assert.IsNull(result.Format3D); } else { Assert.AreEqual(format3D, result.Format3D, true, CultureInfo.InvariantCulture); } }
private void Test(string input, bool is3D, string format3D, NamingOptions options) { var parser = new Format3DParser(options); var result = parser.Parse(input); Assert.Equal(is3D, result.Is3D); if (format3D == null) { Assert.Null(result.Format3D); } else { Assert.Equal(format3D, result.Format3D, true); } }
protected void Set3DFormat(Video video) { var result = Format3DParser.Parse(video.Path, NamingOptions); Set3DFormat(video, result.Is3D, result.Format3D); }
protected void Set3DFormat(Video video) { var result = Format3DParser.Parse(video.Path, LibraryManager.GetNamingOptions()); Set3DFormat(video, result.Is3D, result.Format3D); }