Search in sources :

Example 1 with TwitchEmoteV3

use of com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV3 in project ChatGameFontificator by GlitchCog.

the class EmojiParser method parseTwitchEmoteJsonV3.

/**
     * Parses emotes loaded using Twitch's emote API version 3. It parses emotes into two different maps, one of all
     * emoji, and one that are accessible via set ID.
     * 
     * Twitch V3 API retired on February 14, 2017
     * 
     * @param manager
     * @param jsonData
     * @param jsonMapData
     * @throws IOException
     */
@Deprecated
private void parseTwitchEmoteJsonV3(EmojiManager manager, String jsonData, String jsonMapData) throws IOException {
    logger.trace(jsonData.substring(0, Math.min(jsonData.length(), 512)));
    TypedEmojiMap emoji = manager.getEmojiByType(EmojiType.TWITCH_V3);
    Gson gson = new Gson();
    // Handle actual emotes
    JsonElement emoteElement = new JsonParser().parse(jsonData).getAsJsonObject().get("emoticons");
    Type emoteType = new TypeToken<TwitchEmoteV3[]>() {
    }.getType();
    TwitchEmoteV3[] jsonEmoteObjects = gson.fromJson(emoteElement, emoteType);
    int eMultiCount = 0;
    for (TwitchEmoteV3 e : jsonEmoteObjects) {
        LazyLoadEmoji lle = new LazyLoadEmoji(e.getRegex(), e.getImages()[0].getUrl(), e.getImages()[0].getWidth(), e.getImages()[0].getHeight(), EmojiType.TWITCH_V3);
        if (e.getImages().length > 1) {
            eMultiCount++;
        }
        emoji.put(e.getRegex(), lle);
    }
    logBox.log(jsonEmoteObjects.length + " Twitch emote" + (jsonEmoteObjects.length == 1 ? "" : "s") + " loaded (" + eMultiCount + " multi-image emote" + (eMultiCount == 1 ? "" : "s") + ")");
}
Also used : TypedEmojiMap(com.glitchcog.fontificator.emoji.TypedEmojiMap) LazyLoadEmoji(com.glitchcog.fontificator.emoji.LazyLoadEmoji) EmojiType(com.glitchcog.fontificator.emoji.EmojiType) UserType(com.glitchcog.fontificator.bot.UserType) Type(java.lang.reflect.Type) JsonElement(com.google.gson.JsonElement) Gson(com.google.gson.Gson) TwitchEmoteV3(com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV3) JsonParser(com.google.gson.JsonParser)

Aggregations

UserType (com.glitchcog.fontificator.bot.UserType)1 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)1 LazyLoadEmoji (com.glitchcog.fontificator.emoji.LazyLoadEmoji)1 TypedEmojiMap (com.glitchcog.fontificator.emoji.TypedEmojiMap)1 TwitchEmoteV3 (com.glitchcog.fontificator.emoji.loader.twitch.TwitchEmoteV3)1 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 Type (java.lang.reflect.Type)1