/// <summary> /// Resolves the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="type">The type.</param> /// <returns>VideoFileInfo.</returns> /// <exception cref="System.ArgumentNullException">path</exception> public VideoFileInfo Resolve(string path, FileInfoType type) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } var isStub = false; string container = null; string stubType = null; if (type == FileInfoType.File) { 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 extraResult = new ExtraTypeParser(_options, _logger).GetExtraInfo(path); var name = type == FileInfoType.File ? Path.GetFileNameWithoutExtension(path) : Path.GetFileName(path); var cleanDateTimeResult = CleanDateTime(name); name = cleanDateTimeResult.Name; name = CleanString(name).Name; return(new VideoFileInfo { Path = path, Container = container, IsStub = isStub, Name = name, Year = cleanDateTimeResult.Year, StubType = stubType, Is3D = format3DResult.Is3D, Format3D = format3DResult.Format3D, ExtraType = extraResult.ExtraType }); }
public EpisodeInfo Resolve(string path, bool isFolder, bool fillExtendedInfo = true) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } var isStub = false; string container = null; string stubType = null; if (!isFolder) { 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, isFolder, 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, 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); } }
/// <summary> /// Resolves the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="isFolder">if set to <c>true</c> [is folder].</param> /// <returns>VideoFileInfo.</returns> /// <exception cref="System.ArgumentNullException">path</exception> public VideoFileInfo Resolve(string path, bool isFolder) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } var isStub = false; string container = null; string stubType = null; if (!isFolder) { 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 extraResult = new ExtraResolver(_options, _logger, _regexProvider).GetExtraInfo(path); var name = !isFolder ? Path.GetFileNameWithoutExtension(path) : Path.GetFileName(path); var cleanDateTimeResult = CleanDateTime(name); if (string.IsNullOrWhiteSpace(extraResult.ExtraType)) { name = cleanDateTimeResult.Name; name = CleanString(name).Name; } return new VideoFileInfo { Path = path, Container = container, IsStub = isStub, Name = name, Year = cleanDateTimeResult.Year, StubType = stubType, Is3D = format3DResult.Is3D, Format3D = format3DResult.Format3D, ExtraType = extraResult.ExtraType, IsFolder = isFolder, ExtraRule = extraResult.Rule }; }