aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/ItemUpdateService.cs37
-rw-r--r--MediaBrowser.Controller/Library/ILibraryManager.cs4
-rw-r--r--MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs1
-rw-r--r--MediaBrowser.Model/Configuration/ServerConfiguration.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs49
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs4
6 files changed, 82 insertions, 19 deletions
diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs
index 953f7b3bb..020908ddd 100644
--- a/MediaBrowser.Api/ItemUpdateService.cs
+++ b/MediaBrowser.Api/ItemUpdateService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -46,12 +47,14 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IProviderManager _providerManager;
private readonly ILocalizationManager _localizationManager;
+ private readonly IServerConfigurationManager _config;
- public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager)
+ public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager, IServerConfigurationManager config)
{
_libraryManager = libraryManager;
_providerManager = providerManager;
_localizationManager = localizationManager;
+ _config = config;
}
public object Get(GetMetadataEditorInfo request)
@@ -70,11 +73,14 @@ namespace MediaBrowser.Api
if (locationType == LocationType.FileSystem ||
locationType == LocationType.Offline)
{
- var collectionType = _libraryManager.GetInheritedContentType(item);
- if (string.IsNullOrWhiteSpace(collectionType))
+ if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder))
{
- info.ContentTypeOptions = GetContentTypeOptions(true);
- info.ContentType = _libraryManager.GetContentType(item);
+ var collectionType = _libraryManager.GetInheritedContentType(item);
+ if (string.IsNullOrWhiteSpace(collectionType))
+ {
+ info.ContentTypeOptions = GetContentTypeOptions(true);
+ info.ContentType = _libraryManager.GetContentType(item);
+ }
}
}
@@ -83,7 +89,24 @@ namespace MediaBrowser.Api
public void Post(UpdateItemContentType request)
{
-
+ var item = _libraryManager.GetItemById(request.ItemId);
+ var path = item.ContainingFolderPath;
+
+ var types = _config.Configuration.ContentTypes
+ .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase))
+ .ToList();
+
+ if (!string.IsNullOrWhiteSpace(request.ContentType))
+ {
+ types.Add(new NameValuePair
+ {
+ Name = path,
+ Value = request.ContentType
+ });
+ }
+
+ _config.Configuration.ContentTypes = types.ToArray();
+ _config.SaveConfiguration();
}
private List<NameValuePair> GetContentTypeOptions(bool isForItem)
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index 7cdfb7788..8573f32e0 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -23,11 +23,9 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="fileInfo">The file information.</param>
/// <param name="parent">The parent.</param>
- /// <param name="collectionType">Type of the collection.</param>
/// <returns>BaseItem.</returns>
BaseItem ResolvePath(FileSystemInfo fileInfo,
- Folder parent = null,
- string collectionType = null);
+ Folder parent = null);
/// <summary>
/// Resolves a set of files into a list of BaseItem
diff --git a/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs b/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs
index bd20713de..764a7222f 100644
--- a/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs
@@ -19,6 +19,7 @@ namespace MediaBrowser.Model.Configuration
public CinemaModeConfiguration()
{
EnableIntrosParentalControl = true;
+ EnableIntrosFromSimilarMovies = true;
TrailerLimit = 2;
}
}
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index 0852e0a5c..730735499 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Configuration
{
@@ -165,6 +166,8 @@ namespace MediaBrowser.Model.Configuration
public bool SaveMetadataHidden { get; set; }
+ public NameValuePair[] ContentTypes { get; set; }
+
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary>
@@ -192,6 +195,7 @@ namespace MediaBrowser.Model.Configuration
FindInternetTrailers = true;
PathSubstitutions = new PathSubstitution[] { };
+ ContentTypes = new NameValuePair[] { };
PreferredMetadataLanguage = "en";
MetadataCountryCode = "US";
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index ab50c30fb..d52288f87 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -560,10 +560,9 @@ namespace MediaBrowser.Server.Implementations.Library
}
public BaseItem ResolvePath(FileSystemInfo fileInfo,
- Folder parent = null,
- string collectionType = null)
+ Folder parent = null)
{
- return ResolvePath(fileInfo, new DirectoryService(_logger), parent, collectionType);
+ return ResolvePath(fileInfo, new DirectoryService(_logger), parent);
}
private BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null, string collectionType = null)
@@ -573,10 +572,17 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentNullException("fileInfo");
}
+ var fullPath = fileInfo.FullName;
+
+ if (string.IsNullOrWhiteSpace(collectionType))
+ {
+ collectionType = GetConfiguredContentType(fullPath);
+ }
+
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService)
{
Parent = parent,
- Path = fileInfo.FullName,
+ Path = fullPath,
FileInfo = fileInfo,
CollectionType = collectionType
};
@@ -1548,12 +1554,43 @@ namespace MediaBrowser.Server.Implementations.Library
public string GetContentType(BaseItem item)
{
- return GetInheritedContentType(item);
+ // Types cannot be overridden, so go from the top down until we find a configured content type
+
+ var type = GetTopFolderContentType(item);
+
+ if (!string.IsNullOrWhiteSpace(type))
+ {
+ return type;
+ }
+
+ type = GetInheritedContentType(item);
+
+ if (!string.IsNullOrWhiteSpace(type))
+ {
+ return type;
+ }
+
+ return GetConfiguredContentType(item);
}
public string GetInheritedContentType(BaseItem item)
{
- return GetTopFolderContentType(item);
+ return item.Parents
+ .Select(GetConfiguredContentType)
+ .LastOrDefault(i => !string.IsNullOrWhiteSpace(i));
+ }
+
+ private string GetConfiguredContentType(BaseItem item)
+ {
+ return GetConfiguredContentType(item.ContainingFolderPath);
+ }
+
+ private string GetConfiguredContentType(string path)
+ {
+ var type = ConfigurationManager.Configuration.ContentTypes
+ .FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i.Name, path));
+
+ return type == null ? null : type.Value;
}
private string GetTopFolderContentType(BaseItem item)
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 58b5dbc6a..01dc4db8a 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -79,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return ResolveVideos<Video>(parent, files, directoryService, collectionType);
}
- return ResolveVideos<Movie>(parent, files, directoryService, collectionType);
+ return ResolveVideos<Video>(parent, files, directoryService, collectionType);
}
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
@@ -219,7 +219,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
}
else if (string.IsNullOrEmpty(collectionType))
{
- item = ResolveVideo<Movie>(args, false);
+ item = ResolveVideo<Video>(args, false);
}
if (item != null)