public async Task Delete(UserAction action)
 {
     var item = await GetItemInternal(x => x.Id == action.Id);
     if (item != null)
     {
         _items.Remove(item);
         await SaveItems();
     }
 }
Esempio n. 2
0
        private Task ReportOfflinePlayedItem(UserAction action)
        {
            var item = _libraryManager.GetItemById(action.ItemId);
            var userData = _userDataManager.GetUserData(new Guid(action.UserId), item.GetUserDataKey());

            userData.LastPlayedDate = action.Date;
            _userDataManager.UpdatePlayState(item, userData, action.PositionTicks);

            return _userDataManager.SaveUserData(new Guid(action.UserId), item, userData, UserDataSaveReason.Import, CancellationToken.None);
        }
Esempio n. 3
0
 public Task ReportOfflineAction(UserAction action)
 {
     switch (action.Type)
     {
         case UserActionType.PlayedItem:
             return ReportOfflinePlayedItem(action);
         default:
             throw new ArgumentException("Unexpected action type");
     }
 }
 /// <summary>
 /// Deletes the specified action.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <returns>Task.</returns>
 public Task Delete(UserAction action)
 {
     return _userActionRepository.Delete(action);
 }
        /// <summary>
        /// Records the user action.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <returns>Task.</returns>
        public Task RecordUserAction(UserAction action)
        {
            action.Id = Guid.NewGuid().ToString("N");

            return _userActionRepository.Create(action);
        }
 public Task Create(UserAction action)
 {
     return GetItemInternal(x => x.Id == action.Id);
 }
        /// <summary>
        /// Reports playback progress
        /// </summary>
        /// <param name="info">The information.</param>
        /// <param name="streamInfo">The stream information.</param>
        /// <param name="serverId">The server identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="isOffline">if set to <c>true</c> [is offline].</param>
        /// <param name="apiClient">The current apiClient. It can be null if offline</param>
        /// <returns>Task.</returns>
        public async Task ReportPlaybackStopped(PlaybackStopInfo info, StreamInfo streamInfo, string serverId, string userId, bool isOffline, IApiClient apiClient)
        {
            if (isOffline)
            {
                var action = new UserAction
                {
                    Date = DateTime.UtcNow,
                    ItemId = info.ItemId,
                    PositionTicks = info.PositionTicks,
                    ServerId = serverId,
                    Type = UserActionType.PlayedItem,
                    UserId = userId
                };

                await _localAssetManager.RecordUserAction(action).ConfigureAwait(false);
                return;
            }

            if (streamInfo != null)
            {
                info.PlaySessionId = streamInfo.PlaySessionId;

                if (streamInfo.MediaSource != null)
                {
                    info.LiveStreamId = streamInfo.MediaSource.LiveStreamId;
                }
            }

            // Put a try/catch here because we need to stop transcoding regardless
            try
            {
                await apiClient.ReportPlaybackStoppedAsync(info).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error in ReportPlaybackStoppedAsync", ex);
            }
        }
 public Task Delete(UserAction action)
 {
     return Task.FromResult(true);
 }
 public Task RecordUserAction(UserAction action)
 {
     return Task.FromResult(true);
 }