private async Task DownloadFrankerFaceZEmotes(string channelName = null) { try { using (AdvancedHttpClient client = new AdvancedHttpClient()) { JObject jobj = await client.GetJObjectAsync((!string.IsNullOrEmpty(channelName))? "https://api.frankerfacez.com/v1/room/" + channelName : "https://api.frankerfacez.com/v1/set/global"); if (jobj != null && jobj.ContainsKey("sets")) { JObject setsJObj = (JObject)jobj["sets"]; foreach (var kvp in setsJObj) { JObject setJObj = (JObject)kvp.Value; if (setJObj != null && setJObj.ContainsKey("emoticons")) { JArray emoticonsJArray = (JArray)setJObj["emoticons"]; foreach (FrankerFaceZEmoteModel emote in emoticonsJArray.ToTypedArray <FrankerFaceZEmoteModel>()) { this.frankerFaceZEmotes[emote.name] = emote; } } } } } } catch (Exception ex) { Logger.Log(ex); } }
/// <summary> /// Performs a GET REST request using the provided request URI. /// </summary> /// <param name="requestUri">The request URI to use</param> /// <returns>A JObject of the contents of the response</returns> protected async Task <JObject> GetJObjectAsync(string requestUri) { using (AdvancedHttpClient client = await this.GetHttpClient()) { try { client.RateLimitUpdateOccurred += Client_RateLimitUpdateOccurred; return(await client.GetJObjectAsync(requestUri)); } finally { client.RateLimitUpdateOccurred -= Client_RateLimitUpdateOccurred; } } }
private async Task DownloadBetterTTVEmotes(string channelName = null) { try { using (AdvancedHttpClient client = new AdvancedHttpClient()) { JObject jobj = await client.GetJObjectAsync((!string.IsNullOrEmpty(channelName))? "https://api.betterttv.net/2/channels/" + channelName : "https://api.betterttv.net/2/emotes"); if (jobj != null && jobj.ContainsKey("emotes")) { JArray array = (JArray)jobj["emotes"]; foreach (BetterTTVEmoteModel emote in array.ToTypedArray <BetterTTVEmoteModel>()) { this.betterTTVEmotes[emote.code] = emote; } } } } catch (Exception ex) { Logger.Log(ex); } }