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); }
public async Task <IMusicLevelGetResponse> GetMusicLevelAsync(IMusicLevelGetRequest request) { if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.MusicLevel) { await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.MusicLevel); } { var document = WebBrowserNavigator.WebBrowser.Document; var content = document.GetElementById("inner"); var form = content.GetElementsByTagName("form").OfType <HtmlElement>().FirstOrDefault(); var select = form.GetElementsByTagName("select").OfType <HtmlElement>().FirstOrDefault(); select.SetAttribute("value", request.Level.ToString()); var raiseEvent = RaiseEventAsync(); select.RaiseEvent("onChange"); await raiseEvent; } var response = new MusicLevelGetResponse(WebBrowserNavigator.WebBrowser); if (response.Success) { var musicLevelParser = new MusicLevelParser(); response.MusicLevel = musicLevelParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText); } return(response); }
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 ChunithmNetWebBrowserConnector(WebBrowser webBrowser) { WebBrowser = webBrowser ?? throw new ArgumentNullException(nameof(webBrowser)); WebBrowserNavigator = new WebBrowserNavigator(WebBrowser); WebBrowser.DocumentCompleted += WebBrowser_DocumentCompleted; WebBrowser.Navigate(ChunithmNetUrl.Top); }
public async Task <IWorldsEndMusicGetResponse> GetWorldsEndMusicAsync(IWorldsEndMusicGetRequest request) { if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.WorldsEndMusic) { await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.WorldsEndMusic); } var response = new WorldsEndMusicGetResponse(WebBrowserNavigator.WebBrowser); if (response.Success) { var worldsEndMusicParser = new WorldsEndMusicParser(); response.WorldsEndMusic = worldsEndMusicParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText); } return(response); }
public async Task <IPlaylogGetResponse> GetPlaylogAsync(IPlaylogGetRequest requestData) { if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.Playlog) { await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.Playlog); } var response = new PlaylogGetResponse(WebBrowserNavigator.WebBrowser); if (response.Success) { var playlogParser = new PlaylogParser(); response.Playlog = playlogParser.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); }
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); }
public void Dispose() { WebBrowserNavigator.Dispose(); WebBrowserNavigator = null; WebBrowser = null; }