mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-16 07:06:18 +00:00
support sync for live tv recordings
This commit is contained in:
@@ -188,7 +188,22 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
return new Tuple<IEnumerable<string>, IEnumerable<string>>(result1.Items, result2.Items);
|
||||
}
|
||||
|
||||
private void FillSyncInfo(BaseItemDto dto, BaseItem item, DtoOptions options, User user)
|
||||
public void FillSyncInfo(IEnumerable<IHasSyncInfo> dtos, DtoOptions options, User user)
|
||||
{
|
||||
if (options.Fields.Contains(ItemFields.SyncInfo))
|
||||
{
|
||||
var tuple = GetItemIdsWithSyncJobs(options);
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(dto.Id);
|
||||
|
||||
FillSyncInfo(dto, item, tuple.Item1, tuple.Item2, options, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, DtoOptions options, User user)
|
||||
{
|
||||
if (options.Fields.Contains(ItemFields.SyncInfo))
|
||||
{
|
||||
@@ -202,10 +217,20 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
dto.HasSyncJob = tuple.Item1.Contains(dto.Id, StringComparer.OrdinalIgnoreCase);
|
||||
dto.IsSynced = tuple.Item2.Contains(dto.Id, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
if (dto.IsSynced.Value)
|
||||
{
|
||||
dto.SyncStatus = SyncJobItemStatus.Synced;
|
||||
}
|
||||
|
||||
else if (dto.HasSyncJob.Value)
|
||||
{
|
||||
dto.SyncStatus = SyncJobItemStatus.Queued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FillSyncInfo(BaseItemDto dto, BaseItem item, IEnumerable<string> itemIdsWithPendingSyncJobs, IEnumerable<string> syncedItemIds, DtoOptions options, User user)
|
||||
private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, IEnumerable<string> itemIdsWithPendingSyncJobs, IEnumerable<string> syncedItemIds, DtoOptions options, User user)
|
||||
{
|
||||
if (options.Fields.Contains(ItemFields.SyncInfo))
|
||||
{
|
||||
@@ -217,6 +242,16 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
dto.HasSyncJob = itemIdsWithPendingSyncJobs.Contains(dto.Id, StringComparer.OrdinalIgnoreCase);
|
||||
dto.IsSynced = syncedItemIds.Contains(dto.Id, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
if (dto.IsSynced.Value)
|
||||
{
|
||||
dto.SyncStatus = SyncJobItemStatus.Synced;
|
||||
}
|
||||
|
||||
else if (dto.HasSyncJob.Value)
|
||||
{
|
||||
dto.SyncStatus = SyncJobItemStatus.Queued;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
|
||||
@@ -1148,7 +1148,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
RefreshIfNeeded(programs.Take(500));
|
||||
|
||||
// Load these now which will prefetch metadata
|
||||
await GetRecordings(new RecordingQuery(), cancellationToken).ConfigureAwait(false);
|
||||
var dtoOptions = new DtoOptions();
|
||||
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
|
||||
await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false);
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
@@ -1322,7 +1324,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<QueryResult<RecordingInfoDto>> GetRecordings(RecordingQuery query, CancellationToken cancellationToken)
|
||||
public async Task<QueryResult<RecordingInfoDto>> GetRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -1338,6 +1340,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
_dtoService.FillSyncInfo(returnArray, new DtoOptions(), user);
|
||||
}
|
||||
|
||||
return new QueryResult<RecordingInfoDto>
|
||||
{
|
||||
Items = returnArray,
|
||||
@@ -1410,7 +1417,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
public async Task DeleteRecording(string recordingId)
|
||||
{
|
||||
var recording = await GetRecording(recordingId, CancellationToken.None).ConfigureAwait(false);
|
||||
var dtoOptions = new DtoOptions();
|
||||
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
|
||||
|
||||
var recording = await GetRecording(recordingId, dtoOptions, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
if (recording == null)
|
||||
{
|
||||
@@ -1450,14 +1460,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<RecordingInfoDto> GetRecording(string id, CancellationToken cancellationToken, User user = null)
|
||||
public async Task<RecordingInfoDto> GetRecording(string id, DtoOptions options, CancellationToken cancellationToken, User user = null)
|
||||
{
|
||||
var results = await GetRecordings(new RecordingQuery
|
||||
{
|
||||
UserId = user == null ? null : user.Id.ToString("N"),
|
||||
Id = id
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}, options, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return results.Items.FirstOrDefault();
|
||||
}
|
||||
@@ -1737,11 +1747,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
public async Task<QueryResult<RecordingGroupDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var dtoOptions = new DtoOptions();
|
||||
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
|
||||
|
||||
var recordingResult = await GetRecordings(new RecordingQuery
|
||||
{
|
||||
UserId = query.UserId
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}, dtoOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var recordings = recordingResult.Items;
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
|
||||
protected abstract Task<List<BaseItem>> GetItemsWithImages(IHasImages item);
|
||||
|
||||
private const string Version = "27";
|
||||
private const string Version = "29";
|
||||
protected string GetConfigurationCacheKey(List<BaseItem> items, string itemName)
|
||||
{
|
||||
var parts = Version + "_" + (itemName ?? string.Empty) + "_" +
|
||||
|
||||
Reference in New Issue
Block a user