mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-28 19:38:26 +01:00
sync updates
This commit is contained in:
@@ -40,6 +40,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
VideoCodec = "h264,mpeg4",
|
||||
AudioCodec = mp4Audio,
|
||||
Type = DlnaProfileType.Video
|
||||
},
|
||||
new DirectPlayProfile
|
||||
{
|
||||
Container = "mp3",
|
||||
Type = DlnaProfileType.Audio
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -214,14 +214,14 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
}
|
||||
}
|
||||
|
||||
private string GetLocalId(string serverId, string itemId)
|
||||
internal static string GetLocalId(string serverId, string itemId)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(serverId + itemId);
|
||||
bytes = CreateMD5(bytes);
|
||||
bytes = CreateMd5(bytes);
|
||||
return BitConverter.ToString(bytes, 0, bytes.Length).Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
private byte[] CreateMD5(byte[] value)
|
||||
private static byte[] CreateMd5(byte[] value)
|
||||
{
|
||||
using (var provider = MD5.Create())
|
||||
{
|
||||
@@ -341,10 +341,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
{
|
||||
itemFile.Type = ItemFileType.Subtitles;
|
||||
}
|
||||
else if (!IsImageFile(file.Name))
|
||||
{
|
||||
itemFile.Type = ItemFileType.Media;
|
||||
}
|
||||
|
||||
itemFiles.Add(itemFile);
|
||||
}
|
||||
@@ -352,14 +348,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
return itemFiles;
|
||||
}
|
||||
|
||||
private static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".webp" };
|
||||
private bool IsImageFile(string path)
|
||||
{
|
||||
var ext = Path.GetExtension(path) ?? string.Empty;
|
||||
|
||||
return SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static readonly string[] SupportedSubtitleExtensions = { ".srt", ".vtt" };
|
||||
private bool IsSubtitleFile(string path)
|
||||
{
|
||||
|
||||
@@ -691,9 +691,8 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
|
||||
|
||||
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions);
|
||||
|
||||
var mediaSource = syncedItem.Item.MediaSources
|
||||
.FirstOrDefault(i => string.Equals(i.Id, jobItem.MediaSourceId));
|
||||
|
||||
var mediaSource = jobItem.MediaSource;
|
||||
|
||||
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Sync;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Sync;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -12,11 +14,13 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
{
|
||||
public class SyncedMediaSourceProvider : IMediaSourceProvider
|
||||
{
|
||||
private readonly ISyncManager _syncManager;
|
||||
private readonly SyncManager _syncManager;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
|
||||
public SyncedMediaSourceProvider(ISyncManager syncManager)
|
||||
public SyncedMediaSourceProvider(ISyncManager syncManager, IServerApplicationHost appHost)
|
||||
{
|
||||
_syncManager = syncManager;
|
||||
_appHost = appHost;
|
||||
_syncManager = (SyncManager)syncManager;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MediaSourceInfo>> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken)
|
||||
@@ -28,11 +32,36 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
ItemId = item.Id.ToString("N")
|
||||
});
|
||||
|
||||
var jobItems = jobItemResult
|
||||
.Items
|
||||
.Where(i => true);
|
||||
var list = new List<MediaSourceInfo>();
|
||||
|
||||
return new List<MediaSourceInfo>();
|
||||
if (jobItemResult.Items.Length > 0)
|
||||
{
|
||||
var targets = _syncManager.ServerSyncProviders
|
||||
.SelectMany(i => i.GetAllSyncTargets().Select(t => new Tuple<IServerSyncProvider, SyncTarget>(i, t)))
|
||||
.ToList();
|
||||
|
||||
foreach (var jobItem in jobItemResult.Items)
|
||||
{
|
||||
var targetTuple = targets.FirstOrDefault(i => string.Equals(i.Item2.Id, jobItem.TargetId, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (targetTuple != null)
|
||||
{
|
||||
var syncTarget = targetTuple.Item2;
|
||||
|
||||
var dataProvider = _syncManager.GetDataProvider(targetTuple.Item1, syncTarget);
|
||||
var localItemId = MediaSync.GetLocalId(_appHost.SystemId, item.Id.ToString("N"));
|
||||
|
||||
var localItem = await dataProvider.GetCachedItem(syncTarget, localItemId).ConfigureAwait(false);
|
||||
|
||||
if (localItem != null)
|
||||
{
|
||||
list.AddRange(localItem.Item.MediaSources);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user