mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
implement modular media sources
This commit is contained in:
@@ -75,17 +75,23 @@ namespace MediaBrowser.Controller.Channels
|
||||
|
||||
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
||||
{
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
var sources = ChannelManager.GetChannelItemMediaSources(Id.ToString("N"), false, CancellationToken.None)
|
||||
.Result.ToList();
|
||||
var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
|
||||
.Result.ToList();
|
||||
|
||||
if (sources.Count > 0)
|
||||
{
|
||||
return sources;
|
||||
}
|
||||
|
||||
list.InsertRange(0, sources);
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
foreach (var mediaSource in list)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mediaSource.Path))
|
||||
{
|
||||
mediaSource.Type = MediaSourceType.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -90,17 +90,23 @@ namespace MediaBrowser.Controller.Channels
|
||||
|
||||
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
||||
{
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
var sources = ChannelManager.GetChannelItemMediaSources(Id.ToString("N"), false, CancellationToken.None)
|
||||
.Result.ToList();
|
||||
var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
|
||||
.Result.ToList();
|
||||
|
||||
if (sources.Count > 0)
|
||||
{
|
||||
return sources;
|
||||
}
|
||||
|
||||
list.InsertRange(0, sources);
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
foreach (var mediaSource in list)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mediaSource.Path))
|
||||
{
|
||||
mediaSource.Type = MediaSourceType.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ namespace MediaBrowser.Controller.Channels
|
||||
/// <summary>
|
||||
/// Gets the channel item media sources.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="includeDynamicSources">if set to <c>true</c> [include dynamic sources].</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="includeCachedVersions">if set to <c>true</c> [include cached versions].</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
|
||||
Task<IEnumerable<MediaSourceInfo>> GetChannelItemMediaSources(string id, bool includeDynamicSources, CancellationToken cancellationToken);
|
||||
Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(IChannelMediaItem item, bool includeCachedVersions, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel folder.
|
||||
|
||||
@@ -64,6 +64,14 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <returns>IEnumerable<MediaSourceInfo>.</returns>
|
||||
IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the static media sources.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param>
|
||||
/// <returns>IEnumerable<MediaSourceInfo>.</returns>
|
||||
IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the static media source.
|
||||
/// </summary>
|
||||
@@ -72,5 +80,21 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param>
|
||||
/// <returns>MediaSourceInfo.</returns>
|
||||
MediaSourceInfo GetStaticMediaSource(IHasMediaSources item, string mediaSourceId, bool enablePathSubstitution);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the media source.
|
||||
/// </summary>
|
||||
/// <param name="openKey">The open key.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task<MediaSourceInfo>.</returns>
|
||||
Task<MediaSourceInfo> OpenMediaSource(string openKey, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Closes the media source.
|
||||
/// </summary>
|
||||
/// <param name="closeKey">The close key.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task CloseMediaSource(string closeKey, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,21 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task<IEnumerable<MediaSourceInfo>>.</returns>
|
||||
Task<IEnumerable<MediaSourceInfo>> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the media source.
|
||||
/// </summary>
|
||||
/// <param name="openKey">The open key.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task<MediaSourceInfo>.</returns>
|
||||
Task<MediaSourceInfo> OpenMediaSource(string openKey, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Closes the media source.
|
||||
/// </summary>
|
||||
/// <param name="closeKey">The close key.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task CloseMediaSource(string closeKey, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
public interface ILiveTvItem
|
||||
{
|
||||
Guid Id { get; }
|
||||
string ServiceName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Users;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
@@ -99,5 +101,20 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
||||
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
||||
{
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
foreach (var mediaSource in list)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mediaSource.Path))
|
||||
{
|
||||
mediaSource.Type = MediaSourceType.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
Name = Name,
|
||||
Path = Path,
|
||||
RunTimeTicks = RunTimeTicks,
|
||||
Type = MediaSourceType.Default
|
||||
Type = MediaSourceType.Placeholder
|
||||
};
|
||||
|
||||
list.Add(info);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Users;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
@@ -97,5 +99,20 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
||||
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
||||
{
|
||||
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
||||
|
||||
foreach (var mediaSource in list)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mediaSource.Path))
|
||||
{
|
||||
mediaSource.Type = MediaSourceType.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user