Esempio n. 1
0
        void UserDataSaved(object sender, UserDataSaveEventArgs e)
        {
            if (e.SaveReason == UserDataSaveReason.PlaybackProgress)
            {
                return;
            }

            var message = $"InfuseSync received user data for item '{e.Item.Name}' of type '{e.Item.GetClientTypeName()}' Guid '{e.Item.Id}'";

#if EMBY
            message += $" ItemID '{e.Item.GetClientId()}'";
#endif
            _logger.LogDebug(message);

            lock (_syncLock)
            {
                if (e.Item != null)
                {
                    if (!Shared.ShouldSyncUpdatedItem(e.Item))
                    {
                        return;
                    }

                    if (UpdateTimer == null)
                    {
                        UpdateTimer = new Timer(
                            TimerCallback,
                            null,
                            UpdateDuration,
                            Timeout.Infinite
                            );
                    }
                    else
                    {
                        UpdateTimer.Change(UpdateDuration, Timeout.Infinite);
                    }
#if EMBY
                    var userId = e.User.Id;
#else
                    var userId = e.UserId;
#endif
                    if (!_changedItems.TryGetValue(userId, out var keys))
                    {
                        keys = new List <BaseItem>();
                        _changedItems[userId] = keys;
                    }

                    keys.Add(e.Item);

                    _logger.LogDebug($"InfuseSync will save user data for item {e.Item.Id} user {userId}");
                }
            }
        }
Esempio n. 2
0
        void ItemUpdated(object sender, ItemChangeEventArgs e)
        {
            var message = $"InfuseSync received updated item '{e.Item.Name}' of type '{e.Item.GetClientTypeName()}' Guid '{e.Item.Id}'";

#if EMBY
            message += $" ItemID '{e.Item.GetClientId()}'";
#endif
            _logger.LogDebug(message);

            if (!Shared.ShouldSyncUpdatedItem(e.Item))
            {
                return;
            }

            if (!Plugin.Instance.Db.HasCheckpoints())
            {
                return;
            }

            ItemUpdated(e.Item);
        }
Esempio n. 3
0
        public CheckpointId Post(CreateCheckpoint request)
        {
            _logger.LogDebug($"InfuseSync: Create checkpoint request for DeviceID '{request.DeviceID}' UserID '{request.UserID}'");

            var newCheckpoint = Plugin.Instance.Db.CreateCheckpoint(request.DeviceID, request.UserID);

            return(new CheckpointId {
                Id = newCheckpoint.Guid
            });
        }