Exemplo n.º 1
0
        private async Task SendEpisodePlaystateUpdates(
            bool seen,
            TraktUser traktUser,
            List <Episode> playedEpisodes,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.Info("Episodes to set " + (seen ? string.Empty : "un") + "watched: " + playedEpisodes.Count);
            if (playedEpisodes.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await _traktApi.SendEpisodePlaystateUpdates(playedEpisodes, traktUser, false, seen, cancellationToken).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var con in dataContracts)
                        {
                            LogTraktResponseDataContract(con);
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Error updating episode play states", e);
                }

                progress.Report(100);
            }
        }
        private async Task SendMoviePlaystateUpdates(
            bool seen,
            TraktUser traktUser,
            List <Movie> playedMovies,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.LogInformation("Movies to set " + (seen ? string.Empty : "un") + "watched: " + playedMovies.Count);
            if (playedMovies.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await _traktApi.SendMoviePlaystateUpdates(playedMovies, traktUser, seen, cancellationToken).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var traktSyncResponse in dataContracts)
                        {
                            LogTraktResponseDataContract(traktSyncResponse);
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Error updating movie play states");
                }

                progress.Report(100);
            }
        }
Exemplo n.º 3
0
        private async Task SendEpisodeCollectionUpdates(
            bool collected,
            TraktUser traktUser,
            List <Episode> collectedEpisodes,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.Info("Episodes to add to Collection: " + collectedEpisodes.Count);
            if (collectedEpisodes.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await
                        _traktApi.SendLibraryUpdateAsync(
                            collectedEpisodes,
                            traktUser,
                            cancellationToken,
                            collected?EventType.Add : EventType.Remove).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var traktSyncResponse in dataContracts)
                        {
                            LogTraktResponseDataContract(traktSyncResponse);
                        }
                    }
                }
                catch (ArgumentNullException argNullEx)
                {
                    _logger.ErrorException("ArgumentNullException handled sending episodes to trakt.tv", argNullEx);
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Exception handled sending episodes to trakt.tv", e);
                }

                progress.Report(100);
            }
        }
        private async Task SendMovieCollectionUpdates(
            bool collected,
            TraktUser traktUser,
            List <Movie> movies,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.LogInformation("Movies to " + (collected ? "add to" : "remove from") + " Collection: " + movies.Count);
            if (movies.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await
                        _traktApi.SendLibraryUpdateAsync(
                            movies,
                            traktUser,
                            cancellationToken,
                            collected?EventType.Add : EventType.Remove).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var traktSyncResponse in dataContracts)
                        {
                            LogTraktResponseDataContract(traktSyncResponse);
                        }
                    }
                }
                catch (ArgumentNullException argNullEx)
                {
                    _logger.LogError(argNullEx, "ArgumentNullException handled sending movies to trakt.tv");
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Exception handled sending movies to trakt.tv");
                }

                progress.Report(100);
            }
        }
Exemplo n.º 5
0
        private async Task SendEpisodeCollectionRemovals(
            TraktUser traktUser,
            List <Api.DataContracts.Sync.Collection.TraktShowCollected> uncollectedEpisodes,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.Info("Episodes to remove from Collection: " + uncollectedEpisodes.Count);
            if (uncollectedEpisodes.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await
                        _traktApi.SendLibraryRemovalsAsync(
                            uncollectedEpisodes,
                            traktUser,
                            cancellationToken).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var traktSyncResponse in dataContracts)
                        {
                            LogTraktResponseDataContract(traktSyncResponse);
                        }
                    }
                }
                catch (ArgumentNullException argNullEx)
                {
                    _logger.ErrorException("ArgumentNullException handled sending episodes to trakt.tv", argNullEx);
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Exception handled sending episodes to trakt.tv", e);
                }

                progress.Report(100);
            }
        }
Exemplo n.º 6
0
        private async Task SendMovieCollectionRemoves(
            TraktUser traktUser,
            List <TraktMovieCollected> movies,
            ISplittableProgress <double> progress,
            CancellationToken cancellationToken)
        {
            _logger.Info("Movies to remove from collection: " + movies.Count);
            if (movies.Count > 0)
            {
                try
                {
                    var dataContracts =
                        await
                        _traktApi.SendCollectionRemovalsAsync(
                            movies.Select(m => m.movie).ToList(),
                            traktUser,
                            cancellationToken).ConfigureAwait(false);

                    if (dataContracts != null)
                    {
                        foreach (var traktSyncResponse in dataContracts)
                        {
                            LogTraktResponseDataContract(traktSyncResponse);
                        }
                    }
                }
                catch (ArgumentNullException argNullEx)
                {
                    _logger.ErrorException("ArgumentNullException handled sending movies to trakt.tv", argNullEx);
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Exception handled sending movies to trakt.tv", e);
                }

                progress.Report(100);
            }
        }