stub out mock sync provider
This commit is contained in:
parent
12a0a02515
commit
d56fa09ccc
|
@ -3,6 +3,7 @@ using MediaBrowser.Controller.Sync;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Sync
|
namespace MediaBrowser.Api.Sync
|
||||||
|
@ -50,9 +51,11 @@ namespace MediaBrowser.Api.Sync
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Sync/Schedules", "POST", Summary = "Gets sync schedules.")]
|
[Route("/Sync/Targets", "GET", Summary = "Gets a list of available sync targets.")]
|
||||||
public class CreateSyncSchedule : SyncScheduleRequest
|
public class GetSyncTarget : IReturn<List<SyncTarget>>
|
||||||
{
|
{
|
||||||
|
[ApiMember(Name = "UserId", Description = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public string UserId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authenticated]
|
[Authenticated]
|
||||||
|
@ -65,6 +68,13 @@ namespace MediaBrowser.Api.Sync
|
||||||
_syncManager = syncManager;
|
_syncManager = syncManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Get(GetSyncTarget request)
|
||||||
|
{
|
||||||
|
var result = _syncManager.GetSyncTargets(request.UserId);
|
||||||
|
|
||||||
|
return ToOptimizedResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
public object Get(GetSyncJobs request)
|
public object Get(GetSyncJobs request)
|
||||||
{
|
{
|
||||||
var result = _syncManager.GetJobs(new SyncJobQuery
|
var result = _syncManager.GetJobs(new SyncJobQuery
|
||||||
|
@ -119,12 +129,5 @@ namespace MediaBrowser.Api.Sync
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(CreateSyncSchedule request)
|
|
||||||
{
|
|
||||||
var task = _syncManager.CreateSchedule(request);
|
|
||||||
|
|
||||||
Task.WaitAll(task);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -14,13 +15,6 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task<List<SyncJob>> CreateJob(SyncJobRequest request);
|
Task<List<SyncJob>> CreateJob(SyncJobRequest request);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the schedule.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The request.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
Task<SyncSchedule> CreateSchedule(SyncScheduleRequest request);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the jobs.
|
/// Gets the jobs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -69,7 +63,13 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the synchronize targets.
|
/// Gets the synchronize targets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IEnumerable<SyncTarget>.</returns>
|
IEnumerable<SyncTarget> GetSyncTargets(string userId);
|
||||||
IEnumerable<SyncTarget> GetSyncTargets();
|
|
||||||
|
/// <summary>
|
||||||
|
/// Supportses the synchronize.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
|
bool SupportsSync(BaseItem item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,10 +86,18 @@ namespace MediaBrowser.Dlna.Channels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var device = await Device.CreateuPnpDeviceAsync(new Uri(location), _httpClient, _config, _logger).ConfigureAwait(false);
|
var device = await Device.CreateuPnpDeviceAsync(new Uri(location), _httpClient, _config, _logger)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (!_servers.Any(i => string.Equals(i.Properties.UUID, device.Properties.UUID, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
_servers.Add(device);
|
_servers.Add(device);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_syncLock.Release();
|
_syncLock.Release();
|
||||||
|
|
|
@ -757,13 +757,17 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||||
|
|
||||||
var deviceProperties = new DeviceInfo();
|
var deviceProperties = new DeviceInfo();
|
||||||
|
|
||||||
var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault();
|
var friendlyNames = new List<string>();
|
||||||
if (name != null)
|
|
||||||
deviceProperties.Name = name.Value;
|
|
||||||
|
|
||||||
var name2 = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault();
|
var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault();
|
||||||
if (name2 != null)
|
if (name != null && !string.IsNullOrWhiteSpace(name.Value))
|
||||||
deviceProperties.Name = name2.Value;
|
friendlyNames.Add(name.Value);
|
||||||
|
|
||||||
|
var room = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault();
|
||||||
|
if (room != null && !string.IsNullOrWhiteSpace(room.Value))
|
||||||
|
friendlyNames.Add(room.Value);
|
||||||
|
|
||||||
|
deviceProperties.Name = string.Join(" ", friendlyNames.ToArray());
|
||||||
|
|
||||||
var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
|
var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
|
||||||
if (model != null)
|
if (model != null)
|
||||||
|
|
|
@ -7,7 +7,6 @@ using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Dlna.Ssdp;
|
using MediaBrowser.Dlna.Ssdp;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
using System;
|
using System;
|
||||||
|
|
|
@ -866,9 +866,6 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleQuery.cs">
|
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleQuery.cs">
|
||||||
<Link>Sync\SyncScheduleQuery.cs</Link>
|
<Link>Sync\SyncScheduleQuery.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleRequest.cs">
|
|
||||||
<Link>Sync\SyncScheduleRequest.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncTarget.cs">
|
<Compile Include="..\MediaBrowser.Model\Sync\SyncTarget.cs">
|
||||||
<Link>Sync\SyncTarget.cs</Link>
|
<Link>Sync\SyncTarget.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -823,9 +823,6 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleQuery.cs">
|
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleQuery.cs">
|
||||||
<Link>Sync\SyncScheduleQuery.cs</Link>
|
<Link>Sync\SyncScheduleQuery.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncScheduleRequest.cs">
|
|
||||||
<Link>Sync\SyncScheduleRequest.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\MediaBrowser.Model\Sync\SyncTarget.cs">
|
<Compile Include="..\MediaBrowser.Model\Sync\SyncTarget.cs">
|
||||||
<Link>Sync\SyncTarget.cs</Link>
|
<Link>Sync\SyncTarget.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace MediaBrowser.Model.Dto
|
||||||
|
|
||||||
public int? AnimeSeriesIndex { get; set; }
|
public int? AnimeSeriesIndex { get; set; }
|
||||||
|
|
||||||
|
public bool? SupportsSync { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the DVD season number.
|
/// Gets or sets the DVD season number.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -303,7 +303,6 @@
|
||||||
<Compile Include="Sync\SyncQuality.cs" />
|
<Compile Include="Sync\SyncQuality.cs" />
|
||||||
<Compile Include="Sync\SyncSchedule.cs" />
|
<Compile Include="Sync\SyncSchedule.cs" />
|
||||||
<Compile Include="Sync\SyncScheduleQuery.cs" />
|
<Compile Include="Sync\SyncScheduleQuery.cs" />
|
||||||
<Compile Include="Sync\SyncScheduleRequest.cs" />
|
|
||||||
<Compile Include="Sync\SyncTarget.cs" />
|
<Compile Include="Sync\SyncTarget.cs" />
|
||||||
<Compile Include="System\LogFile.cs" />
|
<Compile Include="System\LogFile.cs" />
|
||||||
<Compile Include="Themes\AppTheme.cs" />
|
<Compile Include="Themes\AppTheme.cs" />
|
||||||
|
|
|
@ -156,6 +156,11 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Studios,
|
Studios,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The synchronize information
|
||||||
|
/// </summary>
|
||||||
|
SyncInfo,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The taglines of the item
|
/// The taglines of the item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -43,5 +43,10 @@ namespace MediaBrowser.Model.Sync
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The transcoded path.</value>
|
/// <value>The transcoded path.</value>
|
||||||
public string TranscodedPath { get; set; }
|
public string TranscodedPath { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,25 @@ namespace MediaBrowser.Model.Sync
|
||||||
/// <value>The device identifier.</value>
|
/// <value>The device identifier.</value>
|
||||||
public List<string> TargetIds { get; set; }
|
public List<string> TargetIds { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the item identifier.
|
/// Gets or sets the item ids.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The item identifier.</value>
|
/// <value>The item ids.</value>
|
||||||
public string ItemId { get; set; }
|
public List<string> ItemIds { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the quality.
|
/// Gets or sets the quality.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The quality.</value>
|
/// <value>The quality.</value>
|
||||||
public SyncQuality Quality { get; set; }
|
public SyncQuality Quality { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
public SyncJobRequest()
|
public SyncJobRequest()
|
||||||
{
|
{
|
||||||
TargetIds = new List<string>();
|
TargetIds = new List<string>();
|
||||||
|
ItemIds = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Sync
|
|
||||||
{
|
|
||||||
public class SyncScheduleRequest
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the device identifier.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The device identifier.</value>
|
|
||||||
public List<string> TargetIds { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the quality.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The quality.</value>
|
|
||||||
public SyncQuality Quality { get; set; }
|
|
||||||
|
|
||||||
public SyncScheduleRequest()
|
|
||||||
{
|
|
||||||
TargetIds = new List<string>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,6 +12,7 @@ using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Controller.Sync;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -38,8 +39,9 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
private readonly IProviderManager _providerManager;
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
private readonly Func<IChannelManager> _channelManagerFactory;
|
private readonly Func<IChannelManager> _channelManagerFactory;
|
||||||
|
private readonly ISyncManager _syncManager;
|
||||||
|
|
||||||
public DtoService(ILogger logger, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager, Func<IChannelManager> channelManagerFactory)
|
public DtoService(ILogger logger, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager, Func<IChannelManager> channelManagerFactory, ISyncManager syncManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
|
@ -50,6 +52,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_providerManager = providerManager;
|
_providerManager = providerManager;
|
||||||
_channelManagerFactory = channelManagerFactory;
|
_channelManagerFactory = channelManagerFactory;
|
||||||
|
_syncManager = syncManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -146,6 +149,11 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
AttachBasicFields(dto, item, owner, fields);
|
AttachBasicFields(dto, item, owner, fields);
|
||||||
|
|
||||||
|
if (fields.Contains(ItemFields.SyncInfo))
|
||||||
|
{
|
||||||
|
dto.SupportsSync = _syncManager.SupportsSync(item);
|
||||||
|
}
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.SoundtrackIds))
|
if (fields.Contains(ItemFields.SoundtrackIds))
|
||||||
{
|
{
|
||||||
var hasSoundtracks = item as IHasSoundtracks;
|
var hasSoundtracks = item as IHasSoundtracks;
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First());
|
HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First());
|
||||||
|
|
||||||
_listener = NativeWebSocket.IsSupported
|
_listener = NativeWebSocket.IsSupported
|
||||||
? _listener = new WebSocketSharpListener(_logger, _threadPoolManager)
|
? _listener = new HttpListenerServer(_logger, _threadPoolManager)
|
||||||
: _listener = new WebSocketSharpListener(_logger, _threadPoolManager);
|
: _listener = new WebSocketSharpListener(_logger, _threadPoolManager);
|
||||||
|
|
||||||
_listener.WebSocketHandler = WebSocketHandler;
|
_listener.WebSocketHandler = WebSocketHandler;
|
||||||
|
|
|
@ -272,6 +272,7 @@
|
||||||
<Compile Include="Sorting\VideoBitRateComparer.cs" />
|
<Compile Include="Sorting\VideoBitRateComparer.cs" />
|
||||||
<Compile Include="Sync\AppSyncProvider.cs" />
|
<Compile Include="Sync\AppSyncProvider.cs" />
|
||||||
<Compile Include="Sync\CloudSyncProvider.cs" />
|
<Compile Include="Sync\CloudSyncProvider.cs" />
|
||||||
|
<Compile Include="Sync\MockSyncProvider.cs" />
|
||||||
<Compile Include="Sync\SyncManager.cs" />
|
<Compile Include="Sync\SyncManager.cs" />
|
||||||
<Compile Include="Themes\AppThemeManager.cs" />
|
<Compile Include="Themes\AppThemeManager.cs" />
|
||||||
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
|
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
|
||||||
|
|
|
@ -10,12 +10,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
public IEnumerable<SyncTarget> GetSyncTargets()
|
public IEnumerable<SyncTarget> GetSyncTargets()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new List<SyncTarget>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new DeviceProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
|
|
@ -19,12 +19,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
public IEnumerable<SyncTarget> GetSyncTargets()
|
public IEnumerable<SyncTarget> GetSyncTargets()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new List<SyncTarget>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return new DeviceProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
|
33
MediaBrowser.Server.Implementations/Sync/MockSyncProvider.cs
Normal file
33
MediaBrowser.Server.Implementations/Sync/MockSyncProvider.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Controller.Sync;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
|
using MediaBrowser.Model.Sync;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
{
|
||||||
|
public class MockSyncProvider : ISyncProvider
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "Dummy Sync"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SyncTarget> GetSyncTargets()
|
||||||
|
{
|
||||||
|
return new List<SyncTarget>
|
||||||
|
{
|
||||||
|
new SyncTarget
|
||||||
|
{
|
||||||
|
Id = "mock".GetMD5().ToString("N"),
|
||||||
|
Name = "Mock Sync"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceProfile GetDeviceProfile(SyncTarget target)
|
||||||
|
{
|
||||||
|
return new DeviceProfile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
using MediaBrowser.Controller.Sync;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Sync;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
using System;
|
using System;
|
||||||
|
@ -10,7 +13,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
public class SyncManager : ISyncManager
|
public class SyncManager : ISyncManager
|
||||||
{
|
{
|
||||||
private ISyncProvider[] _providers = new ISyncProvider[]{};
|
private ISyncProvider[] _providers = new ISyncProvider[] { };
|
||||||
|
|
||||||
public void AddParts(IEnumerable<ISyncProvider> providers)
|
public void AddParts(IEnumerable<ISyncProvider> providers)
|
||||||
{
|
{
|
||||||
|
@ -22,11 +25,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<SyncSchedule> CreateSchedule(SyncScheduleRequest request)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryResult<SyncJob> GetJobs(SyncJobQuery query)
|
public QueryResult<SyncJob> GetJobs(SyncJobQuery query)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -57,9 +55,70 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<SyncTarget> GetSyncTargets()
|
public IEnumerable<SyncTarget> GetSyncTargets(string userId)
|
||||||
{
|
{
|
||||||
return _providers.SelectMany(i => i.GetSyncTargets());
|
return _providers
|
||||||
|
.SelectMany(GetSyncTargets)
|
||||||
|
.OrderBy(i => i.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<SyncTarget> GetSyncTargets(ISyncProvider provider)
|
||||||
|
{
|
||||||
|
var providerId = GetSyncProviderId(provider);
|
||||||
|
|
||||||
|
return provider.GetSyncTargets().Select(i => new SyncTarget
|
||||||
|
{
|
||||||
|
Name = i.Name,
|
||||||
|
Id = providerId + "-" + i.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISyncProvider GetSyncProvider(SyncTarget target)
|
||||||
|
{
|
||||||
|
var providerId = target.Id.Split(new[] { '-' }, 2).First();
|
||||||
|
|
||||||
|
return _providers.First(i => string.Equals(providerId, GetSyncProviderId(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetSyncProviderId(ISyncProvider provider)
|
||||||
|
{
|
||||||
|
return (provider.GetType().Name + provider.Name).GetMD5().ToString("N");
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SupportsSync(BaseItem item)
|
||||||
|
{
|
||||||
|
if (item.LocationType == LocationType.Virtual)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (item.RunTimeTicks.HasValue)
|
||||||
|
{
|
||||||
|
var video = item as Video;
|
||||||
|
|
||||||
|
if (video != null)
|
||||||
|
{
|
||||||
|
if (video.VideoType != VideoType.VideoFile)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (video.IsMultiPart)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,7 +561,10 @@ namespace MediaBrowser.ServerApplication
|
||||||
ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
|
ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
|
||||||
RegisterSingleInstance(ImageProcessor);
|
RegisterSingleInstance(ImageProcessor);
|
||||||
|
|
||||||
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager);
|
SyncManager = new SyncManager();
|
||||||
|
RegisterSingleInstance(SyncManager);
|
||||||
|
|
||||||
|
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager);
|
||||||
RegisterSingleInstance(DtoService);
|
RegisterSingleInstance(DtoService);
|
||||||
|
|
||||||
SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository);
|
SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository);
|
||||||
|
@ -614,9 +617,6 @@ namespace MediaBrowser.ServerApplication
|
||||||
MediaEncoder, ChapterManager);
|
MediaEncoder, ChapterManager);
|
||||||
RegisterSingleInstance(EncodingManager);
|
RegisterSingleInstance(EncodingManager);
|
||||||
|
|
||||||
SyncManager = new SyncManager();
|
|
||||||
RegisterSingleInstance(SyncManager);
|
|
||||||
|
|
||||||
var authContext = new AuthorizationContext();
|
var authContext = new AuthorizationContext();
|
||||||
RegisterSingleInstance<IAuthorizationContext>(authContext);
|
RegisterSingleInstance<IAuthorizationContext>(authContext);
|
||||||
RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
|
RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
|
||||||
|
|
|
@ -43,37 +43,25 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||||
{
|
{
|
||||||
var album = (MusicAlbum)item;
|
var album = (MusicAlbum)item;
|
||||||
|
|
||||||
var tracks = album.Tracks
|
foreach (var artist in album.Artists)
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var artists = tracks
|
|
||||||
.SelectMany(i =>
|
|
||||||
{
|
|
||||||
var list = new List<string>();
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(i.AlbumArtist))
|
|
||||||
{
|
|
||||||
list.Add(i.AlbumArtist);
|
|
||||||
}
|
|
||||||
list.AddRange(i.Artists);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
})
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
foreach (var artist in artists)
|
|
||||||
{
|
{
|
||||||
writer.WriteElementString("artist", artist);
|
writer.WriteElementString("artist", artist);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTracks(tracks, writer);
|
foreach (var artist in album.AlbumArtists)
|
||||||
|
{
|
||||||
|
writer.WriteElementString("albumartist", artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTracks(album.Tracks, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
private void AddTracks(IEnumerable<Audio> tracks, XmlWriter writer)
|
private void AddTracks(IEnumerable<Audio> tracks, XmlWriter writer)
|
||||||
{
|
{
|
||||||
foreach (var track in tracks.OrderBy(i => i.ParentIndexNumber ?? 0).ThenBy(i => i.IndexNumber ?? 0))
|
foreach (var track in tracks.OrderBy(i => i.ParentIndexNumber ?? 0)
|
||||||
|
.ThenBy(i => i.IndexNumber ?? 0))
|
||||||
{
|
{
|
||||||
writer.WriteStartElement("track");
|
writer.WriteStartElement("track");
|
||||||
|
|
||||||
|
@ -103,7 +91,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||||
var list = new List<string>
|
var list = new List<string>
|
||||||
{
|
{
|
||||||
"track",
|
"track",
|
||||||
"artist"
|
"artist",
|
||||||
|
"albumartist"
|
||||||
};
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user