Ejemplo n.º 1
0
        public async Task <ILoginResponse> LoginAsync(ILoginRequest request)
        {
            if (!IsLoggedIn())
            {
                await GetToken();
            }

            var loginContent = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "segaId", request.SegaId },
                { "password", request.Password },
                { "token", token },
            });

            var   postLogin = client.PostAsync(ChunithmNetUrl.CreateUrl("submit"), loginContent);
            await postLogin;

            var   getAimeList = client.GetAsync(ChunithmNetUrl.CreateUrl("aimeList"));
            await getAimeList;

            var response = new LoginResponse(getAimeList.Result);

            if (response.Success)
            {
                var aimeListParser = new AimeListParser();
                response.AimeList = aimeListParser.Parse(response.DocumentText);
                if (response.AimeList == null)
                {
                    response.OnInvalidAimeList();
                }
            }

            return(response);
        }