コード例 #1
0
            public async static Task <Models.API.v3.Videos.TopVideosResponse> GetTopVideosAsync(int limit = 25, int offset = 0, string game = null, Enums.Period period = Enums.Period.Week)
            {
                string paramsStr = $"?limit={limit}&offset={offset}";

                if (game != null)
                {
                    paramsStr += $"&game={game}";
                }
                switch (period)
                {
                case Enums.Period.Week:
                    paramsStr += "&period=week";
                    break;

                case Enums.Period.Month:
                    paramsStr += "&period=month";
                    break;

                case Enums.Period.All:
                    paramsStr += "&period=all";
                    break;
                }

                return(await Requests.GetGenericAsync <Models.API.v3.Videos.TopVideosResponse>($"https://api.twitch.tv/kraken/videos/top{paramsStr}", null, Requests.API.v3));
            }
コード例 #2
0
ファイル: TwitchAPI.cs プロジェクト: foxredfox/TwitchLib
        internal static async Task <Models.API.Clip.ClipsResponse> GetTopClips(List <string> channels = null, List <string> games = null, int limit = 10, string cursor = null, Enums.Period period = Enums.Period.Day, bool trending = false)
        {
            string channelsStr = (channels != null) ? $"channel={string.Join(",", channels)}" : null;
            string gamesStr    = (games != null) ? $"game={string.Join(",", games)}" : null;
            string limitStr    = $"limit={limit}";
            string cursorStr   = (cursor != null) ? $"cursor={cursor}" : null;
            string periodStr   = "";

            switch (period)
            {
            case Enums.Period.All:
                periodStr = "period=all";
                break;

            case Enums.Period.Day:
                periodStr = "period=day";
                break;

            case Enums.Period.Month:
                periodStr = "period=month";
                break;

            case Enums.Period.Week:
                periodStr = "period=week";
                break;
            }
            string trendingStr = (trending) ? "trending=true" : "trending=false";
            string url         = $"https://api.twitch.tv/kraken/clips/top?{limitStr}&{periodStr}";

            if (channels != null)
            {
                url = $"{url}&{channelsStr}";
            }
            if (games != null)
            {
                url = $"{url}&{gamesStr}";
            }
            if (cursor != null)
            {
                url = $"{url}&{cursorStr}";
            }
            return(new Models.API.Clip.ClipsResponse(JObject.Parse(await Requests.MakeGetRequest(url, null, 4))));
        }
コード例 #3
0
ファイル: Videos.cs プロジェクト: Xynal/TwitchLib
            public async Task <Models.API.v3.Videos.TopVideosResponse> GetTopVideosAsync(int limit = 25, int offset = 0, string game = null, Enums.Period period = Enums.Period.Week)
            {
                List <KeyValuePair <string, string> > getParams = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("limit", limit.ToString()), new KeyValuePair <string, string>("offset", offset.ToString())
                };

                if (game != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("game", game));
                }
                switch (period)
                {
                case Enums.Period.Week:
                    getParams.Add(new KeyValuePair <string, string>("period", "week"));
                    break;

                case Enums.Period.Month:
                    getParams.Add(new KeyValuePair <string, string>("period", "month"));
                    break;

                case Enums.Period.All:
                    getParams.Add(new KeyValuePair <string, string>("period", "all"));
                    break;
                }

                return(await Api.GetGenericAsync <Models.API.v3.Videos.TopVideosResponse>($"https://api.twitch.tv/kraken/videos/top", getParams, null, ApiVersion.v3).ConfigureAwait(false));
            }