/// <summary> /// 現在放送中の番組の情報を取得する /// </summary> /// <param name="server"></param> /// <param name="channel"></param> /// <returns></returns> public static async Task <Stream> GetStreamAsync(IDataServer server, string channel) { //var url = "https://api.twitch.tv/kraken/streams/" + channel; //var headers = new Dictionary<string, string> //{ // {"client-id","jzkbprff40iqj646a697cyrvl0zt2m6" },//固定値 // {"Accept","application/vnd.twitchtv.v3+json" }, //}; //var s = await server.GetAsync(url, headers); var url = "https://api.twitch.tv/helix/streams?user_login="******"client-id", "jzkbprff40iqj646a697cyrvl0zt2m6" },//固定値 //{"Accept","application/vnd.twitchtv.v3+json" }, }; var s = await server.GetAsync(url, headers); //配信していないとき //{"data":[],"pagination":{}} var lowObject = Tools.Deserialize <Low.Streams.RootObject>(s); if (lowObject.Data.Length > 0) { var ret = new Stream(lowObject.Data[0]); return(ret); } else { return(null); } }
public static async Task <IChannelInfo> GetChannelInfo(IDataServer server, string channelId) { var headers = new Dictionary <string, string> { { "client-id", "jzkbprff40iqj646a697cyrvl0zt2m6" },//固定値 }; var s = await server.GetAsync($"https://api.twitch.tv/kraken/channels/" + channelId, headers); var low = Tools.Deserialize <LowObject.ChannelInfo.RootObject>(s); return(low); }
// public static async Task <Product[]> GetChannelProducts(IDataServer server, string channelName) { var url = "https://api.twitch.tv/api/channels/" + channelName + "/product"; var headers = new Dictionary <string, string> { { "client-id", "jzkbprff40iqj646a697cyrvl0zt2m6" },//固定値 }; var s = await server.GetAsync(url, headers); var obj = Tools.Deserialize <Low.ChannelProduct.RootObject>(s); return(Tools.CreateProducts(obj)); }
/// <summary> /// ユーザの表示名からID等を取れる /// TwitchではUser=Channel(多分)。他のAPIでは表示名ではなくChannelIDが必要なため、このAPIで先にIDを取得する /// </summary> /// <param name="server"></param> /// <param name="username"></param> /// <returns></returns> public static async Task <IUserInfo> GetChannelInfoByName(IDataServer server, string username) { var headers = new Dictionary <string, string> { { "client-id", "jzkbprff40iqj646a697cyrvl0zt2m6" },//固定値 { "Accept", "application/vnd.twitchtv.v5+json" }, }; var s = await server.GetAsync($"https://api.twitch.tv/kraken/users?login=" + username, headers); var low = Tools.Deserialize <LowObject.UserInfo.RootObject>(s); return(low.Users[0]); }