private async void btn_login_Click(object sender, RoutedEventArgs e) { lbl_loginStatus.Content = "Logging in..."; grid_loginPanel.IsEnabled = false; if (await m_client.Login(input_user.Text, input_pass.Password)) { lbl_loginStatus.Content = "Logged in."; // lbl_loginStatus.Content = "You are logged in."; m_client.StartSession(); m_isLoggedIn = true; m_series.Clear(); lbl_loginStatus.Content = "Preparing animelist..."; m_series = await m_client.GetSeriesList("anime", null, 0, 0); grid_loginPanel.Visibility = Visibility.Collapsed; grid_userPanel.Visibility = Visibility.Visible; lbl_loginStatus.Content = "You are not logged in."; } else { lbl_loginStatus.Content = "Unable to login, invalid username or password."; m_isLoggedIn = false; } grid_loginPanel.IsEnabled = true; }
private async void Button_Click(object sender, RoutedEventArgs e) { // // Some initialization objects required, basically so you can more easily // keep track of the appstate and clientInfo.. yada yada.. // var appState = new ApplicationState(); var clientInfo = new ClientInformation(); // Hoozam! Our client! var crClient = new CrunchyrollClient(appState, clientInfo); if (await crClient.Login("my_username", "my_password")) { // And Hoozam! We are logged in.. :3 Lets start our session. crClient.StartSession(); // For the sake of it.. Lets grab some series and shizzle! // In this case: We are looking for anime, grabbing max 50 series, starting offset 0 var series = await crClient.GetSeriesList("anime", null, 0, 50); foreach (var serie in series) { // ... Do something fancy with them all! } // .. Or do something fancy with a specific one! var SOA = series.FirstOrDefault(s => s.Name.ToLower().StartsWith("sword art online")); if (SOA != null) { var episodes = await crClient.GetMediaList(null, SOA.SeriesId, null, null, null); foreach (var episode in episodes) { // ... FANCY THINGS! } // Or just one of em.. var firstEpisode = episodes.FirstOrDefault(); if (firstEpisode != null) { var streamData = await crClient.GetMediaStream(firstEpisode.MediaId); // .. from the streamData object you'll get a few video urls, // information about its bitrate, what language it is played in, etc. etc... // now its time for you to play the video :) ! var firstStream = streamData.Streams.FirstOrDefault(); if (firstStream != null) { var videoURL = firstStream.Url; // HAVE FUN! } } } } }