public static string GetAsString(this VideoSortType videoSortType) { switch (videoSortType) { case VideoSortType.VideoCount: return("videoCount"); case VideoSortType.ViewCount: return("viewCount"); default: return(videoSortType.ToString().ToLower()); } }
public async Task <MaybeResult <YouTubeSearchDto, StreamProviderError> > SearchGamingVideos( string query, VideoEventType eventType, VideoSortType order, int pageSize, string pageToken) { return(await BuildRequest("/youtube/v3/search") .SetQueryParam("part", "snippet") .SetQueryParam("eventType", eventType.GetAsString()) .SetQueryParam("q", query) .SetQueryParam("type", "video") .SetQueryParam("videoCategoryId", 20) .SetQueryParam("maxResults", pageSize) .SetQueryParam("pageToken", pageToken) .SetQueryParam("order", order.GetAsString()) .GetAsync() .GetOrError <YouTubeSearchDto>()); }
public void 動画を並び替える(VideoSortType sortType, int expectedID) { var video1 = new NonBindableListVideoInfo() { Id = new Reactive.Bindings.ReactiveProperty <int>(1), Title = new Reactive.Bindings.ReactiveProperty <string>("3"), NiconicoId = new Reactive.Bindings.ReactiveProperty <string>("3") }; var video2 = new NonBindableListVideoInfo() { Id = new Reactive.Bindings.ReactiveProperty <int>(2), Title = new Reactive.Bindings.ReactiveProperty <string>("2"), NiconicoId = new Reactive.Bindings.ReactiveProperty <string>("2") }; var video3 = new NonBindableListVideoInfo() { Id = new Reactive.Bindings.ReactiveProperty <int>(3), Title = new Reactive.Bindings.ReactiveProperty <string>("1"), NiconicoId = new Reactive.Bindings.ReactiveProperty <string>("1") }; this.videoListContainer !.AddRange(new IListVideoInfo[] { video1, video2, video3 }); this.videoListContainer !.Sort(sortType, false); Assert.That(this.videoListContainer !.Videos.First().Id.Value, Is.EqualTo(expectedID)); }
public async Task <IList <Models.Video> > GetVideos(int gameId, int pageId = 1, int showcount = 10, VideoSortType sortType = VideoSortType.hot, VideoGalleryType videoGalleryType = VideoGalleryType.instructional) { Uri url = new Uri(baseUrl, string.Format("/api/videos?objectid={0}&objecttype=thing&pageid={1}&showcount={2}&sort={3}&gallery={4}&nosession=1", gameId, pageId, showcount, sortType.ToString(), videoGalleryType.ToString())); var response = await _httpClient.GetAsync(url); if (response.StatusCode != HttpStatusCode.OK) { return(null); } var videoResponse = JsonConvert.DeserializeObject <VideoResponse>(await response.Content.ReadAsStringAsync()); List <Models.Video> videos = new List <Models.Video>(); foreach (var r in videoResponse.videos) { int.TryParse(r.objectid, out int id); videos.Add(new Models.Video() { Category = r.gallery, Id = id, Title = r.title, Username = r.user.username, UserId = r.userid, Link = string.Format("https://youtube.com/watch?v={0}", r.extvideoid) }); } return(videos); }
public IAttemptResult Sort(VideoSortType sortType, bool isDescending, List <int>?customSortSequence = null) { return(AttemptResult.Succeeded()); }