update series resolving
This commit is contained in:
parent
064c9a02f7
commit
0024aa44ee
|
@ -76,11 +76,13 @@ namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
|
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
|
||||||
{
|
{
|
||||||
var collectionType = _libraryManager.GetInheritedContentType(item);
|
var inheritedContentType = _libraryManager.GetInheritedContentType(item);
|
||||||
if (string.IsNullOrWhiteSpace(collectionType))
|
var configuredContentType = _libraryManager.GetConfiguredContentType(item);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
|
||||||
{
|
{
|
||||||
info.ContentTypeOptions = GetContentTypeOptions(true);
|
info.ContentTypeOptions = GetContentTypeOptions(true);
|
||||||
info.ContentType = _libraryManager.GetContentType(item);
|
info.ContentType = configuredContentType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,20 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string GetInheritedContentType(BaseItem item);
|
string GetInheritedContentType(BaseItem item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the configured content.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetConfiguredContentType(BaseItem item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the configured content.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetConfiguredContentType(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normalizes the root path list.
|
/// Normalizes the root path list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -13,6 +13,7 @@ using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Naming.Audio;
|
using MediaBrowser.Naming.Audio;
|
||||||
|
@ -578,7 +579,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(collectionType))
|
if (string.IsNullOrWhiteSpace(collectionType))
|
||||||
{
|
{
|
||||||
collectionType = GetConfiguredContentType(fullPath);
|
collectionType = GetContentTypeOverride(fullPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService)
|
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService)
|
||||||
|
@ -1554,16 +1555,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
public string GetContentType(BaseItem item)
|
public string GetContentType(BaseItem item)
|
||||||
{
|
{
|
||||||
// Types cannot be overridden, so go from the top down until we find a configured content type
|
string configuredContentType = GetConfiguredContentType(item, false);
|
||||||
|
if (!string.IsNullOrWhiteSpace(configuredContentType))
|
||||||
var type = GetInheritedContentType(item);
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(type))
|
|
||||||
{
|
{
|
||||||
return type;
|
return configuredContentType;
|
||||||
}
|
}
|
||||||
|
configuredContentType = GetConfiguredContentType(item, true);
|
||||||
return GetConfiguredContentType(item);
|
if (!string.IsNullOrWhiteSpace(configuredContentType))
|
||||||
|
{
|
||||||
|
return configuredContentType;
|
||||||
|
}
|
||||||
|
return GetInheritedContentType(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetInheritedContentType(BaseItem item)
|
public string GetInheritedContentType(BaseItem item)
|
||||||
|
@ -1580,17 +1582,34 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
.LastOrDefault(i => !string.IsNullOrWhiteSpace(i));
|
.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
|
return GetContentTypeOverride(path, false);
|
||||||
.FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i.Name, path));
|
}
|
||||||
|
|
||||||
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)
|
private string GetTopFolderContentType(BaseItem item)
|
||||||
|
@ -1747,7 +1766,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
public int? GetSeasonNumberFromPath(string path)
|
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)
|
public bool FillMissingEpisodeNumbersFromPath(Episode episode)
|
||||||
|
|
|
@ -129,17 +129,26 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||||
{
|
{
|
||||||
var path = fileSystemInfo.FullName;
|
var path = fileSystemInfo.FullName;
|
||||||
var isMultiDisc = IsMultiDiscFolder(path);
|
var isMultiDisc = IsMultiDiscFolder(path);
|
||||||
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
|
||||||
|
|
||||||
if (isMultiDisc && hasMusic)
|
if (isMultiDisc)
|
||||||
{
|
{
|
||||||
logger.Debug("Found multi-disc folder: " + path);
|
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
||||||
discSubfolderCount++;
|
|
||||||
|
if (hasMusic)
|
||||||
|
{
|
||||||
|
logger.Debug("Found multi-disc folder: " + path);
|
||||||
|
discSubfolderCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (hasMusic)
|
else
|
||||||
{
|
{
|
||||||
// If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
|
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
||||||
notMultiDisc = true;
|
|
||||||
|
if (hasMusic)
|
||||||
|
{
|
||||||
|
// If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
|
||||||
|
notMultiDisc = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
{
|
{
|
||||||
var season = new Season
|
var season = new Season
|
||||||
{
|
{
|
||||||
IndexNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(args.Path, true).SeasonNumber
|
IndexNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(args.Path, true, true).SeasonNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
|
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Common.IO;
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Naming.Common;
|
||||||
|
using MediaBrowser.Naming.IO;
|
||||||
|
using MediaBrowser.Naming.TV;
|
||||||
|
using EpisodeInfo = MediaBrowser.Controller.Providers.EpisodeInfo;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
{
|
{
|
||||||
|
@ -12,6 +20,17 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SeriesResolver : FolderResolver<Series>
|
public class SeriesResolver : FolderResolver<Series>
|
||||||
{
|
{
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
|
public SeriesResolver(IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_logger = logger;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the priority.
|
/// Gets the priority.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -34,8 +53,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
if (args.IsDirectory)
|
if (args.IsDirectory)
|
||||||
{
|
{
|
||||||
var collectionType = args.GetCollectionType();
|
var collectionType = args.GetCollectionType();
|
||||||
|
|
||||||
// If there's a collection type and it's not tv, it can't be a series
|
|
||||||
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (args.HasParent<Series>())
|
if (args.HasParent<Series>())
|
||||||
|
@ -43,17 +60,132 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Series
|
var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path);
|
||||||
|
if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Path = args.Path,
|
return new Series
|
||||||
Name = Path.GetFileName(args.Path)
|
{
|
||||||
};
|
Path = args.Path,
|
||||||
|
Name = Path.GetFileName(args.Path)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.HasParent<Series>())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(collectionType))
|
||||||
|
{
|
||||||
|
if (args.Parent.IsRoot)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false))
|
||||||
|
{
|
||||||
|
return new Series
|
||||||
|
{
|
||||||
|
Path = args.Path,
|
||||||
|
Name = Path.GetFileName(args.Path)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsSeriesFolder(string path,
|
||||||
|
IEnumerable<FileSystemInfo> fileSystemChildren,
|
||||||
|
IDirectoryService directoryService,
|
||||||
|
IFileSystem fileSystem,
|
||||||
|
ILogger logger,
|
||||||
|
ILibraryManager libraryManager,
|
||||||
|
bool isTvContentType)
|
||||||
|
{
|
||||||
|
foreach (var child in fileSystemChildren)
|
||||||
|
{
|
||||||
|
var attributes = child.Attributes;
|
||||||
|
|
||||||
|
if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||||
|
{
|
||||||
|
//logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't enforce this because files saved by Bitcasa are always marked System
|
||||||
|
//if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||||
|
//{
|
||||||
|
// logger.Debug("Igoring series subfolder marked system: {0}", child.FullName);
|
||||||
|
// continue;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
|
{
|
||||||
|
if (IsSeasonFolder(child.FullName, isTvContentType))
|
||||||
|
{
|
||||||
|
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string fullName = child.FullName;
|
||||||
|
if (libraryManager.IsVideoFile(fullName))
|
||||||
|
{
|
||||||
|
if (isTvContentType)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var episodeResolver = new Naming.TV.EpisodeResolver(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
|
||||||
|
var episodeInfo = episodeResolver.Resolve(fullName, FileInfoType.File, false);
|
||||||
|
if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Debug("{0} is not a series folder.", path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether [is place holder] [the specified path].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException">path</exception>
|
||||||
|
private static bool IsVideoPlaceHolder(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("path");
|
||||||
|
}
|
||||||
|
|
||||||
|
var extension = Path.GetExtension(path);
|
||||||
|
|
||||||
|
return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether [is season folder] [the specified path].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <param name="isTvContentType">if set to <c>true</c> [is tv content type].</param>
|
||||||
|
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||||
|
private static bool IsSeasonFolder(string path, bool isTvContentType)
|
||||||
|
{
|
||||||
|
var seasonNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, isTvContentType, isTvContentType).SeasonNumber;
|
||||||
|
|
||||||
|
return seasonNumber.HasValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the initial item values.
|
/// Sets the initial item values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.25\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.27\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="MediaBrowser.Naming" version="1.0.0.25" targetFramework="net45" />
|
<package id="MediaBrowser.Naming" version="1.0.0.27" targetFramework="net45" />
|
||||||
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
|
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
|
||||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.0.*")]
|
[assembly: AssemblyVersion("3.0.*")]
|
||||||
//[assembly: AssemblyVersion("3.0.5482.1")]
|
//[assembly: AssemblyVersion("3.0.5482.3")]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user