aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-09 20:38:01 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-09 20:38:01 -0500
commit0024aa44ee1f316dc2c9d7d41d9306dd168159ea (patch)
tree9f6c9a2499f6f588dbec4e87e946d175348525c1 /MediaBrowser.Server.Implementations/Library/LibraryManager.cs
parent064c9a02f7a12291d6c60962943a1a3be5c622e6 (diff)
update series resolving
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs57
1 files changed, 38 insertions, 19 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 37a68b52b..48bddd6a8 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -13,6 +13,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Naming.Audio;
@@ -200,7 +201,7 @@ namespace MediaBrowser.Server.Implementations.Library
MultiItemResolvers = EntityResolvers.OfType<IMultiItemResolver>().ToArray();
IntroProviders = introProviders.ToArray();
Comparers = itemComparers.ToArray();
-
+
PostscanTasks = postscanTasks.OrderBy(i =>
{
var hasOrder = i as IHasOrder;
@@ -578,7 +579,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (string.IsNullOrWhiteSpace(collectionType))
{
- collectionType = GetConfiguredContentType(fullPath);
+ collectionType = GetContentTypeOverride(fullPath, true);
}
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService)
@@ -1554,16 +1555,17 @@ namespace MediaBrowser.Server.Implementations.Library
public string GetContentType(BaseItem item)
{
- // Types cannot be overridden, so go from the top down until we find a configured content type
-
- var type = GetInheritedContentType(item);
-
- if (!string.IsNullOrWhiteSpace(type))
+ string configuredContentType = GetConfiguredContentType(item, false);
+ if (!string.IsNullOrWhiteSpace(configuredContentType))
{
- return type;
+ return configuredContentType;
}
-
- return GetConfiguredContentType(item);
+ configuredContentType = GetConfiguredContentType(item, true);
+ if (!string.IsNullOrWhiteSpace(configuredContentType))
+ {
+ return configuredContentType;
+ }
+ return GetInheritedContentType(item);
}
public string GetInheritedContentType(BaseItem item)
@@ -1580,19 +1582,36 @@ namespace MediaBrowser.Server.Implementations.Library
.LastOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
- private string GetConfiguredContentType(BaseItem item)
+ public string GetConfiguredContentType(BaseItem item)
{
- return GetConfiguredContentType(item.ContainingFolderPath);
+ return GetConfiguredContentType(item, false);
}
- private string GetConfiguredContentType(string path)
+ public string GetConfiguredContentType(string path)
{
- var type = ConfigurationManager.Configuration.ContentTypes
- .FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i.Name, path));
+ return GetContentTypeOverride(path, false);
+ }
- return type == null ? null : type.Value;
+ public string GetConfiguredContentType(BaseItem item, bool inheritConfiguredPath)
+ {
+ ICollectionFolder collectionFolder = item as ICollectionFolder;
+ if (collectionFolder != null)
+ {
+ return collectionFolder.CollectionType;
+ }
+ return GetContentTypeOverride(item.ContainingFolderPath, inheritConfiguredPath);
}
+ private string GetContentTypeOverride(string path, bool inherit)
+ {
+ var nameValuePair = ConfigurationManager.Configuration.ContentTypes.FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || (inherit && _fileSystem.ContainsSubPath(i.Name, path)));
+ if (nameValuePair != null)
+ {
+ return nameValuePair.Value;
+ }
+ return null;
+ }
+
private string GetTopFolderContentType(BaseItem item)
{
while (!(item.Parent is AggregateFolder) && item.Parent != null)
@@ -1747,7 +1766,7 @@ namespace MediaBrowser.Server.Implementations.Library
public int? GetSeasonNumberFromPath(string path)
{
- return new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, true).SeasonNumber;
+ return new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, true, true).SeasonNumber;
}
public bool FillMissingEpisodeNumbersFromPath(Episode episode)
@@ -1755,8 +1774,8 @@ namespace MediaBrowser.Server.Implementations.Library
var resolver = new EpisodeResolver(new ExtendedNamingOptions(),
new Naming.Logging.NullLogger());
- var fileType = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd || episode.VideoType == VideoType.HdDvd ?
- FileInfoType.Directory :
+ var fileType = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd || episode.VideoType == VideoType.HdDvd ?
+ FileInfoType.Directory :
FileInfoType.File;
var locationType = episode.LocationType;