Fixed bugs:

- addListeners() was throwing exception
  - 404 response code was return while connecting to tiktok for some users
  - configure.setRoomId() method for people that want to set roomId manually
  - client.roomInfo().isAgeRestricted() check if live has age restriction
This commit is contained in:
JW
2023-09-19 02:53:04 +02:00
parent a2da5169db
commit 84bbfa97e9
13 changed files with 105 additions and 47 deletions

View File

@@ -0,0 +1,30 @@
package io.github.jwdeveloper.tiktok.mappers;
import com.google.gson.JsonObject;
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
public class LiveRoomMetaMapper implements Mapper<JsonObject, LiveRoomMeta>
{
@Override
public LiveRoomMeta mapFrom(JsonObject input) {
var liveRoomMeta = new LiveRoomMeta();
if (!input.has("data")) {
return liveRoomMeta;
}
var data = input.getAsJsonObject("data");
if (data.has("status")) {
var status = data.get("status");
liveRoomMeta.setStatus(status.getAsInt());
}
if(data.has("age_restricted"))
{
var element = data.getAsJsonObject("age_restricted");
var restricted= element.get("restricted").getAsBoolean();
liveRoomMeta.setAgeRestricted(restricted);
}
return liveRoomMeta;
}
}