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

@@ -6,6 +6,7 @@ import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
import io.github.jwdeveloper.tiktok.mappers.LiveRoomMetaMapper;
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
import io.github.jwdeveloper.tiktok.models.gifts.TikTokGiftInfo;
@@ -100,22 +101,10 @@ public class TikTokApiService {
logger.info("Fetch RoomInfo");
try {
var response = tiktokHttpClient.getJObjectFromWebcastAPI("room/info/", clientSettings.getClientParameters());
if (!response.has("data")) {
return new LiveRoomMeta();
}
var data = response.getAsJsonObject("data");
if (!data.has("status")) {
return new LiveRoomMeta();
}
var status = data.get("status");
var info = new LiveRoomMeta();
info.setStatus(status.getAsInt());
logger.info("RoomInfo status -> " + info.getStatus());
return info;
var mapper = new LiveRoomMetaMapper();
var liveRoomMeta = mapper.mapFrom(response);
logger.info("RoomInfo status -> " + liveRoomMeta.getStatus());
return liveRoomMeta;
} catch (Exception e) {
throw new TikTokLiveRequestException("Failed to fetch room info from WebCast, see stacktrace for more info.", e);
}