get dynamic media sources
This commit is contained in:
parent
de01c956af
commit
43f0a1bbfe
|
@ -20,6 +20,11 @@ namespace MediaBrowser.Model.Sync
|
|||
/// <value>The job identifier.</value>
|
||||
public string JobId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the item identifier.
|
||||
/// </summary>
|
||||
/// <value>The item identifier.</value>
|
||||
public string ItemId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the target identifier.
|
||||
/// </summary>
|
||||
/// <value>The target identifier.</value>
|
||||
|
|
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.MediaEncoding;
|
|||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -21,13 +22,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
private readonly IChannelManager _channelManager;
|
||||
|
||||
private IMediaSourceProvider[] _providers;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, IChannelManager channelManager)
|
||||
public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, IChannelManager channelManager, ILogger logger)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
_channelManager = channelManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void AddParts(IEnumerable<IMediaSourceProvider> providers)
|
||||
|
@ -127,6 +130,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
var item = _libraryManager.GetItemById(id);
|
||||
IEnumerable<MediaSourceInfo> mediaSources;
|
||||
|
||||
var hasMediaSources = (IHasMediaSources)item;
|
||||
var channelItem = item as IChannelMediaItem;
|
||||
|
||||
if (channelItem != null)
|
||||
|
@ -136,8 +140,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
}
|
||||
else
|
||||
{
|
||||
var hasMediaSources = (IHasMediaSources)item;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userId))
|
||||
{
|
||||
mediaSources = hasMediaSources.GetMediaSources(true);
|
||||
|
@ -149,7 +151,35 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
}
|
||||
}
|
||||
|
||||
return mediaSources;
|
||||
var dynamicMediaSources = await GetDynamicMediaSources(hasMediaSources, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var list = new List<MediaSourceInfo>();
|
||||
|
||||
list.AddRange(mediaSources);
|
||||
list.AddRange(dynamicMediaSources);
|
||||
|
||||
return SortMediaSources(list);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<MediaSourceInfo>> GetDynamicMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = _providers.Select(i => GetDynamicMediaSources(item, i, cancellationToken));
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
return results.SelectMany(i => i.ToList());
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<MediaSourceInfo>> GetDynamicMediaSources(IHasMediaSources item, IMediaSourceProvider provider, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await provider.GetMediaSources(item, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting media sources", ex);
|
||||
return new List<MediaSourceInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IEnumerable<MediaSourceInfo>> GetPlayackMediaSources(string id, CancellationToken cancellationToken)
|
||||
|
|
|
@ -539,6 +539,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
whereClauses.Add("JobId=@JobId");
|
||||
cmd.Parameters.Add(cmd, "@JobId", DbType.String).Value = query.JobId;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(query.ItemId))
|
||||
{
|
||||
whereClauses.Add("ItemId=@ItemId");
|
||||
cmd.Parameters.Add(cmd, "@ItemId", DbType.String).Value = query.ItemId;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(query.TargetId))
|
||||
{
|
||||
whereClauses.Add("TargetId=@TargetId");
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Sync;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Sync;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -9,8 +12,26 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
public class SyncedMediaSourceProvider : IMediaSourceProvider
|
||||
{
|
||||
private readonly ISyncManager _syncManager;
|
||||
|
||||
public SyncedMediaSourceProvider(ISyncManager syncManager)
|
||||
{
|
||||
_syncManager = syncManager;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MediaSourceInfo>> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
|
||||
{
|
||||
var jobItemResult = _syncManager.GetJobItems(new SyncJobItemQuery
|
||||
{
|
||||
AddMetadata = false,
|
||||
Statuses = new List<SyncJobItemStatus> { SyncJobItemStatus.Synced },
|
||||
ItemId = item.Id.ToString("N")
|
||||
});
|
||||
|
||||
var jobItems = jobItemResult
|
||||
.Items
|
||||
.Where(i => true);
|
||||
|
||||
return new List<MediaSourceInfo>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,7 +450,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager);
|
||||
RegisterSingleInstance(SyncManager);
|
||||
|
||||
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager);
|
||||
DtoService = new DtoService(LogManager.GetLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager, () => MediaSourceManager);
|
||||
RegisterSingleInstance(DtoService);
|
||||
|
||||
var encryptionManager = new EncryptionManager();
|
||||
|
@ -459,10 +459,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager);
|
||||
RegisterSingleInstance(ConnectManager);
|
||||
|
||||
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger, FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
|
||||
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
|
||||
RegisterSingleInstance(DeviceManager);
|
||||
|
||||
SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
RegisterSingleInstance(SessionManager);
|
||||
|
||||
var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
|
||||
|
@ -473,10 +473,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
|
||||
progress.Report(15);
|
||||
|
||||
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient);
|
||||
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient);
|
||||
RegisterSingleInstance(ChannelManager);
|
||||
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, ChannelManager);
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, ChannelManager, LogManager.GetLogger("MediaSourceManager"));
|
||||
RegisterSingleInstance(MediaSourceManager);
|
||||
|
||||
var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger);
|
||||
|
|
Loading…
Reference in New Issue
Block a user