/// <summary> /// Gets the top videos on Twitch /// </summary> /// <param name="game">The name of the game to get videos for</param> /// <param name="period">The time period you want to look in</param> /// <param name="offset">Object offset for pagination. Default is 0.</param> /// <param name="limit">How many videos to get at one time. Default is 10. Maximum is 100</param> /// <param name="version">Twitch API version</param> /// <returns>A list of videos</returns> public async Task <List <Video> > RetrieveTopVideos(string game = null, TwitchConstants.Period period = TwitchConstants.Period.Week, int offset = 0, int limit = 25, APIVersion version = APIVersion.None) { if (version == APIVersion.None) { version = DefaultVersion; } Url url = new Url(TwitchConstants.baseUrl).AppendPathSegments("videos", "top"); url.SetQueryParam("game", game); if (limit <= 100) { url.SetQueryParam("limit", limit); } else { url.SetQueryParam("limit", 100); } url.SetQueryParam("period", TwitchConstants.PeriodToString(period)); Uri uri = new Uri(url.ToString()); string responseString; try { responseString = await GetWebData(uri, version); } catch (TwitchException ex) { throw new TwixelException(TwitchConstants.twitchAPIErrorString, ex); } return(HelperMethods.LoadVideos(JObject.Parse(responseString), version)); }
async Task GetVideos(TwitchConstants.Period period) { videos.Clear(); videosCollection.Clear(); endOfList = false; currentlyPullingVideos = true; await AppConstants.SetText("fetching videos"); StatusBar statusBar = AppConstants.GetStatusBar(); statusBar.ProgressIndicator.ProgressValue = null; await statusBar.ProgressIndicator.ShowAsync(); weekRadioButton.IsEnabled = false; monthRadioButton.IsEnabled = false; allRadioButton.IsEnabled = false; videos = await AppConstants.twixel.RetrieveTopVideos(100, "", period); foreach (Video video in videos) { videosCollection.Add(new VideosGridViewBinding(video)); } currentlyPullingVideos = false; await AppConstants.SetText("Videos"); weekRadioButton.IsEnabled = true; monthRadioButton.IsEnabled = true; allRadioButton.IsEnabled = true; }
async Task GetVideos(TwitchConstants.Period period) { videos.Clear(); videosCollection.Clear(); endOfList = false; currentlyPullingVideos = true; loadingVideosStatusBar.Visibility = Windows.UI.Xaml.Visibility.Visible; weekRadioButton.IsEnabled = false; monthRadioButton.IsEnabled = false; allRadioButton.IsEnabled = false; videos = await AppConstants.twixel.RetrieveTopVideos(100, "", period); foreach (Video video in videos) { videosCollection.Add(new VideosGridViewBinding(video)); } currentlyPullingVideos = false; loadingVideosStatusBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; weekRadioButton.IsEnabled = true; monthRadioButton.IsEnabled = true; allRadioButton.IsEnabled = true; }