mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
support channels with dlna
This commit is contained in:
@@ -59,14 +59,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
var isMusicMediaFolder = string.Equals(collectionType, CollectionType.Music,
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// If there's a collection type and it's not music, don't allow it.
|
||||
if (!string.IsNullOrEmpty(collectionType) &&
|
||||
!string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
|
||||
if (!isMusicMediaFolder)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return IsMusicAlbum(args) ? new MusicAlbum() : null;
|
||||
return IsMusicAlbum(args, isMusicMediaFolder) ? new MusicAlbum() : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,27 +76,29 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// Determine if the supplied file data points to a music album
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsMusicAlbum(string path, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
public static bool IsMusicAlbum(string path, bool isMusicMediaFolder, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, logger, fileSystem);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), isMusicMediaFolder, true, directoryService, logger, fileSystem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the supplied resolve args should be considered a music album
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <returns><c>true</c> if [is music album] [the specified args]; otherwise, <c>false</c>.</returns>
|
||||
private bool IsMusicAlbum(ItemResolveArgs args)
|
||||
private bool IsMusicAlbum(ItemResolveArgs args, bool isMusicMediaFolder)
|
||||
{
|
||||
// Args points to an album if parent is an Artist folder or it directly contains music
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem)) return true;
|
||||
if (ContainsMusic(args.FileSystemChildren, isMusicMediaFolder, true, args.DirectoryService, _logger, _fileSystem)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -104,12 +108,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
/// Determine if the supplied list contains what we should consider music
|
||||
/// </summary>
|
||||
/// <param name="list">The list.</param>
|
||||
/// <param name="isMusicMediaFolder">if set to <c>true</c> [is music media folder].</param>
|
||||
/// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list, bool allowSubfolders, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list,
|
||||
bool isMusicMediaFolder,
|
||||
bool allowSubfolders,
|
||||
IDirectoryService directoryService,
|
||||
ILogger logger,
|
||||
IFileSystem fileSystem)
|
||||
{
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
@@ -120,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService, logger, fileSystem))
|
||||
if (isMusicMediaFolder && allowSubfolders && IsAlbumSubfolder(fileSystemInfo, true, directoryService, logger, fileSystem))
|
||||
{
|
||||
discSubfolderCount++;
|
||||
}
|
||||
@@ -135,27 +145,27 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
if (EntityResolutionHelper.IsAudioFile(fullName))
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(fileSystem.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(fullName))
|
||||
if (string.Equals(fileSystem.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foundAudio++;
|
||||
}
|
||||
else if (EntityResolutionHelper.IsVideoFile(fullName)) return false;
|
||||
else if (EntityResolutionHelper.IsVideoPlaceHolder(fullName)) return false;
|
||||
|
||||
if (foundAudio >= 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (EntityResolutionHelper.IsVideoFile(fullName)) return false;
|
||||
if (EntityResolutionHelper.IsVideoPlaceHolder(fullName)) return false;
|
||||
}
|
||||
|
||||
// or a single audio file and no video files
|
||||
return foundAudio > 0 || discSubfolderCount > 0;
|
||||
}
|
||||
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
private static bool IsAlbumSubfolder(FileSystemInfo directory, bool isMusicMediaFolder, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
var path = directory.FullName;
|
||||
|
||||
@@ -163,7 +173,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
logger.Debug("Found multi-disc folder: " + path);
|
||||
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), isMusicMediaFolder, false, directoryService, logger, fileSystem);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -171,7 +181,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
private static bool IsMultiDiscFolder(string path)
|
||||
{
|
||||
return EntityResolutionHelper.IsMultiPartFolder(path);
|
||||
return false;
|
||||
//return EntityResolutionHelper.IsMultiPartFolder(path);
|
||||
}
|
||||
|
||||
private static bool IsAdditionalSubfolderAllowed(FileSystemInfo directory)
|
||||
|
||||
@@ -62,9 +62,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
var isMusicMediaFolder = string.Equals(collectionType, CollectionType.Music,
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// If there's a collection type and it's not music, it can't be a series
|
||||
if (!string.IsNullOrEmpty(collectionType) &&
|
||||
!string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
|
||||
if (!isMusicMediaFolder)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -72,7 +74,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
var directoryService = args.DirectoryService;
|
||||
|
||||
// If we contain an album assume we are an artist folder
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService, _logger, _fileSystem)) ? new MusicArtist() : null;
|
||||
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, isMusicMediaFolder, directoryService, _logger, _fileSystem)) ? new MusicArtist() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
@@ -16,10 +17,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
public class SeriesResolver : FolderResolver<Series>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SeriesResolver(IFileSystem fileSystem)
|
||||
public SeriesResolver(IFileSystem fileSystem, ILogger logger)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,19 +67,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// It's a Series if any of the following conditions are met:
|
||||
// series.xml exists
|
||||
// [tvdbid= is present in the path
|
||||
// TVUtils.IsSeriesFolder returns true
|
||||
var filename = Path.GetFileName(args.Path);
|
||||
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (TVUtils.IsSeriesFolder(args.Path, collectionType == CollectionType.TvShows, args.FileSystemChildren, args.DirectoryService, _fileSystem))
|
||||
if (TVUtils.IsSeriesFolder(args.Path, string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase), args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger))
|
||||
{
|
||||
return new Series();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using System.IO;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -16,6 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Server.Implementations.Configuration;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
@@ -28,8 +32,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
|
||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IFileSystem fileSystem, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager)
|
||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IFileSystem fileSystem, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerApplicationPaths appPaths)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_localizationManager = localizationManager;
|
||||
@@ -37,6 +42,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
_userManager = userManager;
|
||||
_channelManager = channelManager;
|
||||
_liveTvManager = liveTvManager;
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken)
|
||||
@@ -124,5 +130,37 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<SpecialFolder> GetSpecialFolder(string name, SpecialFolderType type, string itemType, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = Path.Combine(_appPaths.ItemsByNamePath,
|
||||
"specialfolders",
|
||||
_fileSystem.GetValidFilename(name));
|
||||
|
||||
var id = (path + "_specialfolder_" + name).GetMBId(typeof(SpecialFolder));
|
||||
|
||||
var item = _libraryManager.GetItemById(id) as SpecialFolder;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
item = new SpecialFolder
|
||||
{
|
||||
Path = path,
|
||||
Id = id,
|
||||
DateCreated = DateTime.UtcNow,
|
||||
Name = name,
|
||||
SpecialFolderType = type,
|
||||
ItemTypeName = itemType
|
||||
};
|
||||
|
||||
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user