added content type selection
This commit is contained in:
parent
98ae564226
commit
498b58aad0
|
@ -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)
|
||||
|
@ -69,6 +72,8 @@ namespace MediaBrowser.Api
|
|||
var locationType = item.LocationType;
|
||||
if (locationType == LocationType.FileSystem ||
|
||||
locationType == LocationType.Offline)
|
||||
{
|
||||
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder))
|
||||
{
|
||||
var collectionType = _libraryManager.GetInheritedContentType(item);
|
||||
if (string.IsNullOrWhiteSpace(collectionType))
|
||||
|
@ -77,13 +82,31 @@ namespace MediaBrowser.Api
|
|||
info.ContentType = _libraryManager.GetContentType(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ToOptimizedResult(info);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace MediaBrowser.Model.Configuration
|
|||
public CinemaModeConfiguration()
|
||||
{
|
||||
EnableIntrosParentalControl = true;
|
||||
EnableIntrosFromSimilarMovies = true;
|
||||
TrailerLimit = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user