aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Channels/IChannelManager.cs16
-rw-r--r--MediaBrowser.Controller/Entities/BasePluginFolder.cs2
-rw-r--r--MediaBrowser.Controller/Entities/UserView.cs31
-rw-r--r--MediaBrowser.Controller/Library/TVUtils.cs89
4 files changed, 129 insertions, 9 deletions
diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs
index 744eab96e..252e2aee5 100644
--- a/MediaBrowser.Controller/Channels/IChannelManager.cs
+++ b/MediaBrowser.Controller/Channels/IChannelManager.cs
@@ -44,6 +44,14 @@ namespace MediaBrowser.Controller.Channels
Channel GetChannel(string id);
/// <summary>
+ /// Gets the channels internal.
+ /// </summary>
+ /// <param name="query">The query.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;QueryResult&lt;Channel&gt;&gt;.</returns>
+ Task<QueryResult<Channel>> GetChannelsInternal(ChannelQuery query, CancellationToken cancellationToken);
+
+ /// <summary>
/// Gets the channels.
/// </summary>
/// <param name="query">The query.</param>
@@ -76,6 +84,14 @@ namespace MediaBrowser.Controller.Channels
Task<QueryResult<BaseItemDto>> GetChannelItems(ChannelItemQuery query, CancellationToken cancellationToken);
/// <summary>
+ /// Gets the channel items internal.
+ /// </summary>
+ /// <param name="query">The query.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;QueryResult&lt;BaseItem&gt;&gt;.</returns>
+ Task<QueryResult<BaseItem>> GetChannelItemsInternal(ChannelItemQuery query, CancellationToken cancellationToken);
+
+ /// <summary>
/// Gets the cached channel item media sources.
/// </summary>
/// <param name="id">The identifier.</param>
diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.cs
index e1383923f..fa2b49a60 100644
--- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs
+++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities
public virtual string CollectionType
{
- get { return Model.Entities.CollectionType.BoxSets; }
+ get { return null; }
}
}
}
diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs
index 619a497f5..be426d99e 100644
--- a/MediaBrowser.Controller/Entities/UserView.cs
+++ b/MediaBrowser.Controller/Entities/UserView.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
+using MoreLinq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -29,6 +30,10 @@ namespace MediaBrowser.Controller.Entities
case CollectionType.Trailers:
return mediaFolders.SelectMany(i => i.GetRecursiveChildren(user, includeLinkedChildren))
.OfType<Trailer>();
+ case CollectionType.Movies:
+ return mediaFolders.SelectMany(i => i.GetRecursiveChildren(user, includeLinkedChildren))
+ .Where(i => i is Movie || i is BoxSet)
+ .DistinctBy(i => i.Id);
default:
return mediaFolders.SelectMany(i => i.GetChildren(user, includeLinkedChildren));
}
@@ -70,4 +75,30 @@ namespace MediaBrowser.Controller.Entities
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
}
}
+
+ public class SpecialFolder : Folder
+ {
+ public SpecialFolderType SpecialFolderType { get; set; }
+ public string ItemTypeName { get; set; }
+ public string ParentId { get; set; }
+
+ public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
+ {
+ var parent = (Folder)LibraryManager.GetItemById(new Guid(ParentId));
+
+ if (SpecialFolderType == SpecialFolderType.ItemsByType)
+ {
+ var items = parent.GetRecursiveChildren(user, includeLinkedChildren);
+
+ return items.Where(i => string.Equals(i.GetType().Name, ItemTypeName, StringComparison.OrdinalIgnoreCase));
+ }
+
+ return new List<BaseItem>();
+ }
+ }
+
+ public enum SpecialFolderType
+ {
+ ItemsByType = 1
+ }
}
diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs
index 86699272e..6ef1fb6f7 100644
--- a/MediaBrowser.Controller/Library/TVUtils.cs
+++ b/MediaBrowser.Controller/Library/TVUtils.cs
@@ -8,6 +8,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Library
{
@@ -136,6 +137,16 @@ namespace MediaBrowser.Controller.Library
return val;
}
+ if (filename.StartsWith("s", StringComparison.OrdinalIgnoreCase))
+ {
+ var testFilename = filename.Substring(1);
+
+ if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
+ {
+ return val;
+ }
+ }
+
// Look for one of the season folder names
foreach (var name in SeasonFolderNames)
{
@@ -182,7 +193,7 @@ namespace MediaBrowser.Controller.Library
return null;
}
- return int.Parse(path.Substring(numericStart, length));
+ return int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture);
}
/// <summary>
@@ -194,21 +205,59 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
private static bool IsSeasonFolder(string path, IDirectoryService directoryService, IFileSystem fileSystem)
{
+ var seasonNumber = GetSeasonNumberFromPath(path);
+ var hasSeasonNumber = seasonNumber != null;
+
+ if (!hasSeasonNumber)
+ {
+ return false;
+ }
+
// It's a season folder if it's named as such and does not contain any audio files, apart from theme.mp3
- return GetSeasonNumberFromPath(path) != null &&
- !directoryService.GetFiles(path)
- .Any(i => EntityResolutionHelper.IsAudioFile(i.FullName) && !string.Equals(fileSystem.GetFileNameWithoutExtension(i), BaseItem.ThemeSongFilename));
+ foreach (var fileSystemInfo in directoryService.GetFileSystemEntries(path))
+ {
+ var attributes = fileSystemInfo.Attributes;
+
+ if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
+ {
+ continue;
+ }
+
+ if ((attributes & FileAttributes.System) == FileAttributes.System)
+ {
+ continue;
+ }
+
+ if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ {
+ //if (IsBadFolder(fileSystemInfo.Name))
+ //{
+ // return false;
+ //}
+ }
+ else
+ {
+ if (EntityResolutionHelper.IsAudioFile(fileSystemInfo.FullName) &&
+ !string.Equals(fileSystem.GetFileNameWithoutExtension(fileSystemInfo), BaseItem.ThemeSongFilename))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
}
/// <summary>
/// Determines whether [is series folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
- /// <param name="considerSeasonlessSeries">if set to <c>true</c> [consider seasonless series].</param>
+ /// <param name="considerSeasonlessEntries">if set to <c>true</c> [consider seasonless entries].</param>
/// <param name="fileSystemChildren">The file system children.</param>
/// <param name="directoryService">The directory service.</param>
+ /// <param name="fileSystem">The file system.</param>
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
- public static bool IsSeriesFolder(string path, bool considerSeasonlessSeries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem)
+ public static bool IsSeriesFolder(string path, bool considerSeasonlessEntries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger)
{
// A folder with more than 3 non-season folders in will not becounted as a series
var nonSeriesFolders = 0;
@@ -231,15 +280,20 @@ namespace MediaBrowser.Controller.Library
{
if (IsSeasonFolder(child.FullName, directoryService, fileSystem))
{
+ logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
return true;
}
- if (!EntityResolutionHelper.IgnoreFolders.Contains(child.Name, StringComparer.OrdinalIgnoreCase))
+
+ if (IsBadFolder(child.Name))
{
+ logger.Debug("Invalid folder under series: {0}", child.FullName);
+
nonSeriesFolders++;
}
if (nonSeriesFolders >= 3)
{
+ logger.Debug("{0} not a series due to 3 or more invalid folders.", path);
return false;
}
}
@@ -249,7 +303,7 @@ namespace MediaBrowser.Controller.Library
if (EntityResolutionHelper.IsVideoFile(fullName) || EntityResolutionHelper.IsVideoPlaceHolder(fullName))
{
- if (GetEpisodeNumberFromFile(fullName, considerSeasonlessSeries).HasValue)
+ if (GetEpisodeNumberFromFile(fullName, considerSeasonlessEntries).HasValue)
{
return true;
}
@@ -257,9 +311,28 @@ namespace MediaBrowser.Controller.Library
}
}
+ logger.Debug("{0} is not a series folder.", path);
return false;
}
+ private static bool IsBadFolder(string name)
+ {
+ if (string.Equals(name, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (string.Equals(name, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (string.Equals(name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return !EntityResolutionHelper.IgnoreFolders.Contains(name, StringComparer.OrdinalIgnoreCase);
+ }
+
/// <summary>
/// Episodes the number from file.
/// </summary>