|
@@ -556,7 +556,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
return ResolvePath(fileInfo, new DirectoryService(_logger, _fileSystem), null, parent);
|
|
|
}
|
|
|
|
|
|
- private BaseItem ResolvePath(FileSystemMetadata fileInfo, IDirectoryService directoryService, IItemResolver[] resolvers, Folder parent = null, string collectionType = null)
|
|
|
+ private BaseItem ResolvePath(FileSystemMetadata fileInfo,
|
|
|
+ IDirectoryService directoryService,
|
|
|
+ IItemResolver[] resolvers,
|
|
|
+ Folder parent = null,
|
|
|
+ string collectionType = null,
|
|
|
+ LibraryOptions libraryOptions = null)
|
|
|
{
|
|
|
if (fileInfo == null)
|
|
|
{
|
|
@@ -575,7 +580,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
Parent = parent,
|
|
|
Path = fullPath,
|
|
|
FileInfo = fileInfo,
|
|
|
- CollectionType = collectionType
|
|
|
+ CollectionType = collectionType,
|
|
|
+ LibraryOptions = libraryOptions
|
|
|
};
|
|
|
|
|
|
// Return null if ignore rules deem that we should do so
|
|
@@ -653,12 +659,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
return !args.ContainsFileSystemEntryByName(".ignore");
|
|
|
}
|
|
|
|
|
|
- public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType)
|
|
|
+ public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, string collectionType)
|
|
|
{
|
|
|
- return ResolvePaths(files, directoryService, parent, collectionType, EntityResolvers);
|
|
|
+ return ResolvePaths(files, directoryService, parent, libraryOptions, collectionType, EntityResolvers);
|
|
|
}
|
|
|
|
|
|
- public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers)
|
|
|
+ public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files,
|
|
|
+ IDirectoryService directoryService,
|
|
|
+ Folder parent,
|
|
|
+ LibraryOptions libraryOptions,
|
|
|
+ string collectionType,
|
|
|
+ IItemResolver[] resolvers)
|
|
|
{
|
|
|
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
|
|
|
|
|
@@ -679,22 +690,27 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
{
|
|
|
ResolverHelper.SetInitialItemValues(item, parent, _fileSystem, this, directoryService);
|
|
|
}
|
|
|
- items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers));
|
|
|
+ items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers, libraryOptions));
|
|
|
return items;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers);
|
|
|
+ return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers, libraryOptions);
|
|
|
}
|
|
|
|
|
|
- private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers)
|
|
|
+ private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList,
|
|
|
+ IDirectoryService directoryService,
|
|
|
+ Folder parent,
|
|
|
+ string collectionType,
|
|
|
+ IItemResolver[] resolvers,
|
|
|
+ LibraryOptions libraryOptions)
|
|
|
{
|
|
|
return fileList.Select(f =>
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- return ResolvePath(f, directoryService, resolvers, parent, collectionType);
|
|
|
+ return ResolvePath(f, directoryService, resolvers, parent, collectionType, libraryOptions);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -1891,6 +1907,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase));
|
|
|
}
|
|
|
|
|
|
+ public LibraryOptions GetLibraryOptions(BaseItem item)
|
|
|
+ {
|
|
|
+ var collectionFolder = GetCollectionFolders(item)
|
|
|
+ .OfType<CollectionFolder>()
|
|
|
+ .FirstOrDefault();
|
|
|
+
|
|
|
+ return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
|
|
|
+ }
|
|
|
+
|
|
|
public string GetContentType(BaseItem item)
|
|
|
{
|
|
|
string configuredContentType = GetConfiguredContentType(item, false);
|
|
@@ -2242,18 +2267,28 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
- public bool IsVideoFile(string path)
|
|
|
+ public bool IsVideoFile(string path, LibraryOptions libraryOptions)
|
|
|
{
|
|
|
- var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger());
|
|
|
+ var resolver = new VideoResolver(GetNamingOptions(libraryOptions), new PatternsLogger());
|
|
|
return resolver.IsVideoFile(path);
|
|
|
}
|
|
|
|
|
|
- public bool IsAudioFile(string path)
|
|
|
+ public bool IsVideoFile(string path)
|
|
|
+ {
|
|
|
+ return IsVideoFile(path, new LibraryOptions());
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsAudioFile(string path, LibraryOptions libraryOptions)
|
|
|
{
|
|
|
- var parser = new AudioFileParser(GetNamingOptions());
|
|
|
+ var parser = new AudioFileParser(GetNamingOptions(libraryOptions));
|
|
|
return parser.IsAudioFile(path);
|
|
|
}
|
|
|
|
|
|
+ public bool IsAudioFile(string path)
|
|
|
+ {
|
|
|
+ return IsAudioFile(path, new LibraryOptions());
|
|
|
+ }
|
|
|
+
|
|
|
public int? GetSeasonNumberFromPath(string path)
|
|
|
{
|
|
|
return new SeasonPathParser(GetNamingOptions(), new RegexProvider()).Parse(path, true, true).SeasonNumber;
|
|
@@ -2379,6 +2414,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
}
|
|
|
|
|
|
public NamingOptions GetNamingOptions()
|
|
|
+ {
|
|
|
+ return GetNamingOptions(new LibraryOptions());
|
|
|
+ }
|
|
|
+
|
|
|
+ public NamingOptions GetNamingOptions(LibraryOptions libraryOptions)
|
|
|
{
|
|
|
var options = new ExtendedNamingOptions();
|
|
|
|
|
@@ -2386,13 +2426,13 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
options.AudioFileExtensions.Remove(".m3u");
|
|
|
options.AudioFileExtensions.Remove(".wpl");
|
|
|
|
|
|
- if (!ConfigurationManager.Configuration.EnableAudioArchiveFiles)
|
|
|
+ if (!libraryOptions.EnableAudioArchiveFiles)
|
|
|
{
|
|
|
options.AudioFileExtensions.Remove(".rar");
|
|
|
options.AudioFileExtensions.Remove(".zip");
|
|
|
}
|
|
|
|
|
|
- if (!ConfigurationManager.Configuration.EnableVideoArchiveFiles)
|
|
|
+ if (!libraryOptions.EnableVideoArchiveFiles)
|
|
|
{
|
|
|
options.VideoFileExtensions.Remove(".rar");
|
|
|
options.VideoFileExtensions.Remove(".zip");
|
|
@@ -2443,7 +2483,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
new GenericVideoResolver<Trailer>(this)
|
|
|
};
|
|
|
|
|
|
- return ResolvePaths(files, directoryService, null, null, resolvers)
|
|
|
+ return ResolvePaths(files, directoryService, null, new LibraryOptions(), null, resolvers)
|
|
|
.OfType<Trailer>()
|
|
|
.Select(video =>
|
|
|
{
|
|
@@ -2487,7 +2527,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
files.AddRange(currentVideo.Extras.Where(i => !string.Equals(i.ExtraType, "trailer", StringComparison.OrdinalIgnoreCase)).Select(i => _fileSystem.GetFileInfo(i.Path)));
|
|
|
}
|
|
|
|
|
|
- return ResolvePaths(files, directoryService, null, null)
|
|
|
+ return ResolvePaths(files, directoryService, null, new LibraryOptions(), null)
|
|
|
.OfType<Video>()
|
|
|
.Select(video =>
|
|
|
{
|
|
@@ -2665,7 +2705,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
throw new InvalidOperationException();
|
|
|
}
|
|
|
|
|
|
- public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary)
|
|
|
+ public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, LibraryOptions options, bool refreshLibrary)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(name))
|
|
|
{
|
|
@@ -2708,6 +2748,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
|
|
|
+
|
|
|
if (mediaPaths != null)
|
|
|
{
|
|
|
foreach (var path in mediaPaths)
|