Пример #1
0
        public ActionResult <QueryResult <RemovedItem> > GetRemovedItemsQuery(
            [FromRoute] Guid checkpointID,
            [FromQuery] string?includeItemTypes,
            [FromQuery] int?startIndex,
            [FromQuery] int?limit)
        {
            var request = new GetRemovedItemsQuery
            {
                CheckpointID     = checkpointID,
                IncludeItemTypes = includeItemTypes,
                StartIndex       = startIndex,
                Limit            = limit
            };

            try
            {
                return(_service.Get(request));
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
            catch (ResourceNotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
Пример #2
0
        public QueryResult <RemovedItem> Get(GetRemovedItemsQuery request)
        {
            _logger.LogDebug($"InfuseSync: Removed items requested for CheckpointID '{request.CheckpointID}'");

            var checkpoint = Plugin.Instance.Db.GetCheckpoint(request.CheckpointID);

            if (checkpoint == null)
            {
                throw new ResourceNotFoundException($"Checkpoint with ID '{request.CheckpointID}' not found.");
            }
            if (checkpoint.SyncTimestamp == null)
            {
                throw new ArgumentException($"Sync session should be started before using the checkpoint.");
            }

            var includeTypes = request.IncludeItemTypes?.Split(',');

            var itemsRemoved = Plugin.Instance.Db.GetItems(
                checkpoint.Timestamp,
                checkpoint.SyncTimestamp.Value,
                ItemStatus.Removed,
                includeTypes,
                request.StartIndex ?? 0,
                request.Limit ?? int.MaxValue
                );

            var totalCount = Plugin.Instance.Db.ItemsCount(
                checkpoint.Timestamp,
                checkpoint.SyncTimestamp.Value,
                ItemStatus.Removed,
                includeTypes
                );

            var removedItems = itemsRemoved.Select(x => new RemovedItem {
#if EMBY
                ItemId   = x.ItemId,
                SeriesId = x.SeriesId?.ToString(),
#else
                ItemId   = x.Guid,
                SeriesId = x.SeriesId,
#endif
                Season = x.Season
            }).ToArray();

            return(new QueryResult <RemovedItem> {
                Items = removedItems,
#if JELLYFIN
                StartIndex = request.StartIndex ?? 0,
#endif
                TotalRecordCount = totalCount
            });
        }