Esempio n. 1
0
        protected override void DoAuthenticate()
        {
            if (string.IsNullOrEmpty(_username))
            {
                Logger.LogTrace("OsdbSession: Attempt to anonymously login to OSDB server ...");
                _username = string.Empty;
                _password = string.Empty;
            }
            else
            {
                Logger.LogTrace("OsdbSession: Attempt to login to OSDB server with username {0} ...", _username);
            }

            string lang      = _culture.TwoLetterISOLanguageName;
            string userAgent = string.Format("{0} v{1}", ProTONEConstants.PlayerUserAgent, SuiteVersion.Version);

            OsdbLoginResponse rsp = _client.Login(_username, _password, lang, userAgent);

            if (!rsp.IsOK())
            {
                // Login failed.
                throw new SubtitleDownloadException("Login to OSDB server has failed", rsp.status);
            }

            // Get the session token
            _sessionToken = rsp.token;

            Logger.LogTrace("OsdbSession: Succesfully logged in.");
        }