mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
support channels with dlna
This commit is contained in:
@@ -43,6 +43,14 @@ namespace MediaBrowser.Controller.Channels
|
||||
/// <returns>Channel.</returns>
|
||||
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<QueryResult<Channel>>.</returns>
|
||||
Task<QueryResult<Channel>> GetChannelsInternal(ChannelQuery query, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channels.
|
||||
/// </summary>
|
||||
@@ -75,6 +83,14 @@ namespace MediaBrowser.Controller.Channels
|
||||
/// <returns>Task{QueryResult{BaseItemDto}}.</returns>
|
||||
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<QueryResult<BaseItem>>.</returns>
|
||||
Task<QueryResult<BaseItem>> GetChannelItemsInternal(ChannelItemQuery query, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cached channel item media sources.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public virtual string CollectionType
|
||||
{
|
||||
get { return Model.Entities.CollectionType.BoxSets; }
|
||||
get { return null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user