Example #1
0
        public void AuthorizeUser()
        {
            try
            {
                ITraktAuthorization      authorization           = _traktClient.GetAuthorization(PinCode);
                ITraktUserSettings       traktUserSettings       = _traktClient.GetTraktUserSettings();
                ITraktSyncLastActivities traktSyncLastActivities = _traktClient.GetLastActivities();

                string traktUserHomePath = _mediaPortalServices.GetTraktUserHomePath();
                if (!_fileOperations.DirectoryExists(traktUserHomePath))
                {
                    _fileOperations.CreateDirectory(traktUserHomePath);
                }

                SaveTraktAuthorization(authorization, traktUserHomePath);
                SaveTraktUserSettings(traktUserSettings, traktUserHomePath);
                SaveLastSyncActivities(traktSyncLastActivities, traktUserHomePath);

                TestStatus       = "[Trakt.AuthorizationSucceed]";
                IsUserAuthorized = true;
            }
            catch (Exception ex)
            {
                TestStatus = "[Trakt.AuthorizationFailed]";
                _mediaPortalServices.GetLogger().Error(ex);
                IsUserAuthorized = false;
            }
        }