public ReadOnlyCollection <Video> Search(string query, VideoSort sort, bool isHd = false, bool isAdult = false, VideoFilters filters = null, bool isSearchOwn = false, int?count = null, int?offset = null) { var parameters = new VideoSearchParams { Query = query, Sort = sort, Hd = isHd, Adult = isAdult, Filters = filters, SearchOwn = isSearchOwn, Offset = offset, Count = count }; return(Search(parameters).ToReadOnlyCollection()); }
public ReadOnlyCollection <Video> Search(string query, VideoSort sort, bool isHd = false, bool isAdult = false, VideoFilters filters = null, bool isSearchOwn = false, int?count = null, int?offset = null) { VkErrors.ThrowIfNullOrEmpty(() => query); VkErrors.ThrowIfNumberIsNegative(() => count); VkErrors.ThrowIfNumberIsNegative(() => offset); var parameters = new VkParameters { { "q", query }, { "sort", sort }, { "hd", isHd }, { "adult", isAdult }, { "filters", filters }, { "search_own", isSearchOwn }, { "offset", offset }, { "count", count } }; VkResponseArray response = _vk.Call("video.search", parameters); return(response.ToReadOnlyCollectionOf <Video>(x => x)); }
protected virtual bool AllowSortMethod(VideoSort.SortMethod method) { return true; }
public ReadOnlyCollection<Video> Search(string query, VideoSort sort, bool isHd = false, bool isAdult = false, VideoFilters filters = null, bool isSearchOwn = false, int? count = null, int? offset = null) { VkErrors.ThrowIfNullOrEmpty(() => query); VkErrors.ThrowIfNumberIsNegative(() => count); VkErrors.ThrowIfNumberIsNegative(() => offset); var parameters = new VkParameters { {"q", query}, {"sort", sort}, {"hd", isHd}, {"adult", isAdult}, {"filters", filters}, {"search_own", isSearchOwn}, {"offset", offset}, {"count", count} }; VkResponseArray response = _vk.Call("video.search", parameters); return response.ToReadOnlyCollectionOf<Video>(x => x); }
public ReadOnlyCollection<Video> Search(string query, VideoSort sort, bool isHd = false, bool isAdult = false, VideoFilters filters = null, bool isSearchOwn = false, int? count = null, int? offset = null) { var parameters = new VideoSearchParams { Query = query, Sort = sort, Hd = isHd, Adult = isAdult, Filters = filters, SearchOwn = isSearchOwn, Offset = offset, Count = count }; return Search(parameters); }
public Task <Models.Helix.Videos.GetVideos.GetVideosResponse> GetVideoAsync(List <string> videoIds = null, string userId = null, string gameId = null, string after = null, string before = null, int first = 20, string language = null, Period period = Period.All, VideoSort sort = VideoSort.Time, VideoType type = VideoType.All) { if ((videoIds == null || videoIds.Count == 0) && userId == null && gameId == null) { throw new BadParameterException("VideoIds, userId, and gameId cannot all be null/empty."); } if (videoIds != null && videoIds.Count > 0 && userId != null || videoIds != null && videoIds.Count > 0 && gameId != null || userId != null && gameId != null) { throw new BadParameterException("If videoIds are present, you may not use userid or gameid. If gameid is present, you may not use videoIds or userid. If userid is present, you may not use videoids or gameids."); } var getParams = new List <KeyValuePair <string, string> >(); if (videoIds != null && videoIds.Count > 0) { foreach (var videoId in videoIds) { getParams.Add(new KeyValuePair <string, string>("id", videoId)); } } if (userId != null) { getParams.Add(new KeyValuePair <string, string>("user_id", userId)); } if (gameId != null) { getParams.Add(new KeyValuePair <string, string>("game_id", gameId)); } if (userId != null || gameId != null) { if (after != null) { getParams.Add(new KeyValuePair <string, string>("after", after)); } if (before != null) { getParams.Add(new KeyValuePair <string, string>("before", before)); } getParams.Add(new KeyValuePair <string, string>("first", first.ToString())); if (language != null) { getParams.Add(new KeyValuePair <string, string>("language", language)); } switch (period) { case Period.All: getParams.Add(new KeyValuePair <string, string>("period", "all")); break; case Period.Day: getParams.Add(new KeyValuePair <string, string>("period", "day")); break; case Period.Month: getParams.Add(new KeyValuePair <string, string>("period", "month")); break; case Period.Week: getParams.Add(new KeyValuePair <string, string>("period", "week")); break; default: throw new ArgumentOutOfRangeException(nameof(period), period, null); } switch (sort) { case VideoSort.Time: getParams.Add(new KeyValuePair <string, string>("sort", "time")); break; case VideoSort.Trending: getParams.Add(new KeyValuePair <string, string>("sort", "trending")); break; case VideoSort.Views: getParams.Add(new KeyValuePair <string, string>("sort", "views")); break; default: throw new ArgumentOutOfRangeException(nameof(sort), sort, null); } switch (type) { case VideoType.All: getParams.Add(new KeyValuePair <string, string>("type", "all")); break; case VideoType.Highlight: getParams.Add(new KeyValuePair <string, string>("type", "highlight")); break; case VideoType.Archive: getParams.Add(new KeyValuePair <string, string>("type", "archive")); break; case VideoType.Upload: getParams.Add(new KeyValuePair <string, string>("type", "upload")); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } return(Api.TwitchGetGenericAsync <Models.Helix.Videos.GetVideos.GetVideosResponse>("/videos", ApiVersion.Helix, getParams)); }
public ReadOnlyCollection<Video> SearchAll(string query, VideoSort sort, bool isHd = false, bool isAdult = false, VideoFilters filters = null, bool isSearchOwn = false) { const int count = 200; var i = 0; var result = new List<Video>(); do { var currentItems = _video.Search(query, sort, isHd, isAdult, filters, isSearchOwn, count, i * count); if (currentItems != null) result.AddRange(currentItems); } while ((++i * count < (_vk.CountFromLastResponse ?? 0)) && (i * count < 1000)); return result.ToReadOnlyCollection(); }