mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Removal of blank spaces and unused imports/dependencies
Optimize picture download memory usage and add option to convert to unsigned url Convert response data classes to final and add toString with `@Data` Made sending requests dynamic by allowing passing of BodyHandler to class
This commit is contained in:
@@ -28,8 +28,6 @@ import io.github.jwdeveloper.tiktok.data.events.common.TikTokUnhandledEvent;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
@EventMeta(eventType = EventType.Debug)
|
||||
public class TikTokWebsocketUnhandledMessageEvent extends TikTokUnhandledEvent<WebcastResponse.Message>
|
||||
@@ -42,4 +40,4 @@ public class TikTokWebsocketUnhandledMessageEvent extends TikTokUnhandledEvent<W
|
||||
{
|
||||
return this.getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,8 +85,7 @@ public class Picture {
|
||||
throw new TikTokLiveException("Unable map downloaded image", e);
|
||||
}
|
||||
|
||||
var bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
try {
|
||||
try (var bais = new ByteArrayInputStream(baos.toByteArray())) {
|
||||
return ImageIO.read(bais);
|
||||
} catch (IOException e) {
|
||||
throw new TikTokLiveException("Unable map downloaded image bytes to Image", e);
|
||||
@@ -97,6 +96,13 @@ public class Picture {
|
||||
return new Picture("");
|
||||
}
|
||||
|
||||
public Picture asUnsigned() {
|
||||
if (link == null || link.isEmpty())
|
||||
return this;
|
||||
// p16-sign-va.tiktokcdn.com -> p16-va.tiktokcdn.com || p16-sign.tiktokcdn.com -> p16.tiktokcdn.com
|
||||
return new Picture(link.replace("-sign-", "-").replace("-sign.", "."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Picture{link='" + link + "', image=" + image + "}";
|
||||
|
||||
@@ -29,11 +29,11 @@ import java.util.List;
|
||||
|
||||
public class GiftsData
|
||||
{
|
||||
@Getter
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static final class Response
|
||||
{
|
||||
private String json;
|
||||
private List<Gift> gifts;
|
||||
private final String json;
|
||||
private final List<Gift> gifts;
|
||||
}
|
||||
}
|
||||
@@ -28,20 +28,19 @@ import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
public class LiveConnectionData {
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class Request {
|
||||
private String roomId;
|
||||
private final String roomId;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Response {
|
||||
private String websocketCookies;
|
||||
private URI websocketUrl;
|
||||
private WebcastResponse webcastResponse;
|
||||
private final String websocketCookies;
|
||||
private final URI websocketUrl;
|
||||
private final WebcastResponse webcastResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class LiveData {
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class Request {
|
||||
private String roomId;
|
||||
private final String roomId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -46,11 +46,7 @@ public class LiveData {
|
||||
private boolean ageRestricted;
|
||||
private User host;
|
||||
private LiveType liveType;
|
||||
public Response() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Response() {}
|
||||
}
|
||||
|
||||
public enum LiveStatus {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LiveUserData {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Response {
|
||||
private final String json;
|
||||
|
||||
@@ -22,19 +22,10 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.dto.MessageMetaData;
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketMessageEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketResponseEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketUnhandledMessageEvent;
|
||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||
import io.github.jwdeveloper.tiktok.utils.Stopwatch;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public interface LiveMessagesHandler {
|
||||
void handle(LiveClient client, WebcastResponse webcastResponse);
|
||||
|
||||
void handleSingleMessage(LiveClient client, WebcastResponse.Message message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user