Пример #1
0
        public async Task <ILoginResponse> LoginAsync(ILoginRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.Top)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.Top);
            }

            {
                var document      = WebBrowserNavigator.WebBrowser.Document;
                var inputs        = document.GetElementsByTagName("input");
                var segaIdInput   = inputs.GetElementsByName("segaId").OfType <HtmlElement>().FirstOrDefault();
                var passwordInput = inputs.GetElementsByName("password").OfType <HtmlElement>().FirstOrDefault();
                segaIdInput.SetAttribute("value", request.SegaId);
                passwordInput.SetAttribute("value", request.Password);
            }

            var   login = WebBrowserNavigator.InvokeScriptAsync("formSubmit", new[] { "sega_login" });
            await login;

            var response = new LoginResponse(WebBrowserNavigator.WebBrowser);

            if (response.Success)
            {
                var aimeListParser = new AimeListParser();
                response.AimeList = aimeListParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText);
            }
            return(response);
        }
Пример #2
0
        public async Task <IMusicGenreGetResponse> GetMusicGenreAsync(IMusicGenreGetRequest request)
        {
            if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.MusicGenre)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.MusicGenre);
            }

            {
                var documente      = WebBrowserNavigator.WebBrowser.Document;
                var musicGenreForm = documente.GetElementById("music_genre");
                var genre          = musicGenreForm.GetElementsByTagName("select").OfType <HtmlElement>().FirstOrDefault();
                genre.SetAttribute("value", request.GenreCode.ToString());
            }

            var   musicGenre = WebBrowserNavigator.InvokeScriptAsync("formSubmitAddParam", new[] { "music_genre", ToDifficultyParam(request.Difficulty) });
            await musicGenre;

            var response = new MusicGenreGetResponse(WebBrowserNavigator.WebBrowser);

            if (response.Success)
            {
                var musicGenreParser = new MusicGenreParser();
                response.MusicGenre = musicGenreParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText);
            }
            return(response);
        }
        public async Task <IAimeSelectResponse> SelectAimeAsync(IAimeSelectRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.AimeList)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.AimeList);
            }

            var   select = WebBrowserNavigator.InvokeScriptAsync("formSubmit", new[] { $"aime_login_{request.AimeIndex}" });
            await select;

            var response = new AimeSelectResponse(WebBrowserNavigator.WebBrowser);

            return(response);
        }
        public async Task <IWorldsEndMusicDetailGetResponse> GetWorldsEndMusicDetailAsync(IWorldsEndMusicDetailGetRequest request)
        {
            if (WebBrowserNavigator.WebBrowser.Url?.AbsolutePath != ChunithmNetUrl.WorldsEndMusic)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.WorldsEndMusic);
            }

            var   worldsEndMusicDetail = WebBrowserNavigator.InvokeScriptAsync("formSubmitAddParam", new[] { "music_detail", $"musicId_{request.Id}" });
            await worldsEndMusicDetail;

            var response = new WorldsEndMusicDetailGetResponse(WebBrowserNavigator.WebBrowser);

            if (response.Success)
            {
                var worldsEndMusicDetailParser = new WorldsEndMusicDetailParser();
                response.WorldsEndMusicDetail = worldsEndMusicDetailParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText);
            }
            return(response);
        }
        public async Task <IPlaylogDetailGetResponse> GetPlaylogDetailAsync(IPlaylogDetailGetRequest request)
        {
            if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.Playlog)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.Playlog);
            }

            var   playlogDetail = WebBrowserNavigator.InvokeScriptAsync("pageMove", new object[] { "PlaylogDetail", request.Index });
            await playlogDetail;

            var response = new PlaylogDetailGetResponse(WebBrowserNavigator.WebBrowser);

            if (response.Success)
            {
                var playlogDetailParser = new PlaylogDetailParser();
                response.PlaylogDetail = playlogDetailParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText);
            }

            return(response);
        }
Пример #6
0
        public async Task <IMusicDetailGetResponse> GetMusicDetailAsync(IMusicDetailGetRequest request)
        {
            if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.MusicGenre)
            {
                await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.MusicGenre);
            }

            var   musicGenre = WebBrowserNavigator.InvokeScriptAsync("formSubmitAddParam", new[] { "music_genre", "level_master" });
            await musicGenre;

            var   musicDetail = WebBrowserNavigator.InvokeScriptAsync("formSubmitAddParam", new[] { "music_detail", $"musicId_{request.Id}" });
            await musicDetail;

            var response = new MusicDetailGetResponse(WebBrowserNavigator.WebBrowser);

            if (response.Success)
            {
                var musicDetailParser = new MusicDetailParser();
                response.MusicDetail = musicDetailParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText);
            }
            return(response);
        }