diff --git a/src/main/java/xyz/r2turntrue/chzzk4j/Chzzk.java b/src/main/java/xyz/r2turntrue/chzzk4j/Chzzk.java index ac1db0b..ef93dcc 100644 --- a/src/main/java/xyz/r2turntrue/chzzk4j/Chzzk.java +++ b/src/main/java/xyz/r2turntrue/chzzk4j/Chzzk.java @@ -12,13 +12,14 @@ import xyz.r2turntrue.chzzk4j.types.ChzzkFollowingStatusResponse; import xyz.r2turntrue.chzzk4j.types.ChzzkUser; import xyz.r2turntrue.chzzk4j.types.channel.ChzzkChannel; +import xyz.r2turntrue.chzzk4j.types.channel.emoticon.ChzzkChannelEmotePackData; import xyz.r2turntrue.chzzk4j.types.channel.ChzzkChannelFollowingData; import xyz.r2turntrue.chzzk4j.types.channel.ChzzkChannelRules; import xyz.r2turntrue.chzzk4j.types.channel.recommendation.ChzzkRecommendationChannels; import xyz.r2turntrue.chzzk4j.util.RawApiUtils; import java.io.IOException; -import java.util.concurrent.TimeUnit; +import java.util.List; public class Chzzk { public static String API_URL = "https://api.chzzk.naver.com"; @@ -101,7 +102,6 @@ public ChzzkChannel getChannel(String channelId) throws IOException, ChannelNotE ChzzkChannel channel = gson.fromJson( contentJson, ChzzkChannel.class); - if (channel.getChannelId() == null) { throw new ChannelNotExistsException("The channel does not exists!"); } @@ -134,6 +134,24 @@ public ChzzkChannelRules getChannelChatRules(String channelId) throws IOExceptio return rules; } + public ChzzkChannelEmotePackData getChannelEmotePackData(String channelId) throws IOException { + JsonElement contentJson = RawApiUtils.getContentJson( + httpClient, + RawApiUtils.httpGetRequest(API_URL + "/service/v1/channels/" + channelId + "/emoji-packs").build(), + isDebug); + ChzzkChannelEmotePackData emoticons = null; + List emoteElements = contentJson.getAsJsonObject().asMap().get("subscriptionEmojiPacks").getAsJsonArray().asList(); + for (JsonElement emoteElement : emoteElements) { + if (emoteElement.getAsJsonObject().asMap().get("emojiPackId").getAsString().equals("\""+channelId+ "\"")) { + continue; + } + emoticons= gson.fromJson( + emoteElement, + ChzzkChannelEmotePackData.class); + } + return emoticons; + } + /** * Get following status about channel. * diff --git a/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/ChzzkPartialChannel.java b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/ChzzkPartialChannel.java index cf7b66b..64a7349 100644 --- a/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/ChzzkPartialChannel.java +++ b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/ChzzkPartialChannel.java @@ -3,6 +3,7 @@ import org.jetbrains.annotations.Nullable; import xyz.r2turntrue.chzzk4j.Chzzk; import xyz.r2turntrue.chzzk4j.exception.NotExistsException; +import xyz.r2turntrue.chzzk4j.types.channel.emoticon.ChzzkChannelEmotePackData; import java.io.IOException; @@ -12,6 +13,7 @@ public class ChzzkPartialChannel { private String channelImageUrl; private boolean verifiedMark; private ChzzkChannelPersonalData personalData; + private ChzzkChannelEmotePackData emotePackData; ChzzkPartialChannel() {} @@ -64,6 +66,13 @@ public ChzzkChannelPersonalData getPersonalData() { return personalData; } + /** + * Get the emoticon pack data of the channel. + */ + @Nullable + public ChzzkChannelEmotePackData getEmotePackData() { + return emotePackData; + } @Override public String toString() { return "ChzzkPartialChannel{" + diff --git a/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmotePackData.java b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmotePackData.java new file mode 100644 index 0000000..d204338 --- /dev/null +++ b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmotePackData.java @@ -0,0 +1,42 @@ +package xyz.r2turntrue.chzzk4j.types.channel.emoticon; + +import java.util.List; + +public class ChzzkChannelEmotePackData { + private String emojiPackId; + private String emojiPackName; + private String emojiPackImageUrl; + private boolean emojiPackLocked; + private List emojis; + + private ChzzkChannelEmotePackData() {} + + /** + * Get the pack's id. + */ + public String getPackId() { + return emojiPackId; + } + + /** + * Get the name of the pack. + */ + public String getPackName() { + return emojiPackName; + } + + /** + * Get url of the pack's image. + */ + public String getPackImageUrl() { + return emojiPackImageUrl; + } + + /** + * Get the emoticons data of the pack. + */ + + public List getEmojis() { + return emojis; + } +} diff --git a/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmoticonData.java b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmoticonData.java new file mode 100644 index 0000000..8c1731f --- /dev/null +++ b/src/main/java/xyz/r2turntrue/chzzk4j/types/channel/emoticon/ChzzkChannelEmoticonData.java @@ -0,0 +1,22 @@ +package xyz.r2turntrue.chzzk4j.types.channel.emoticon; + +public class ChzzkChannelEmoticonData { + private String emojiId; + private String imageUrl; + + private ChzzkChannelEmoticonData() {} + + /** + * Get the emoticon's id. + */ + public String getEmoticonId() { + return emojiId; + } + + /** + * Get url of the emoticon's image. + */ + public String getEmoticonImageUrl() { + return imageUrl; + } +}