mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Compare commits
7 Commits
1.8.9-Rele
...
develop-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
437335f784 | ||
|
|
84b0a3aaf4 | ||
|
|
14bf9c8c9b | ||
|
|
2dc3001e7b | ||
|
|
29a81f4cd6 | ||
|
|
70fd174a95 | ||
|
|
3e23e5b939 |
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>API</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>4.28.3</version>
|
||||
<version>4.26.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -51,7 +51,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeMavenTypes>direct</includeMavenTypes>
|
||||
<protocVersion>4.28.3</protocVersion>
|
||||
<protocVersion>4.26.1</protocVersion>
|
||||
<inputDirectories>
|
||||
<include>src/main/proto</include>
|
||||
</inputDirectories>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class Picture {
|
||||
@@ -85,8 +86,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,8 +97,25 @@ 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 + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
return o == this || o instanceof Picture picture && picture.link != null && picture.link.equals(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(link);
|
||||
}
|
||||
}
|
||||
@@ -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,16 +22,7 @@
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>4.28.3</version>
|
||||
<version>4.26.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -225,7 +225,7 @@ public class TikTokLiveHttpClient implements LiveHttpClient
|
||||
if (clientSettings.getApiKey() != null)
|
||||
builder.withParam("apiKey", clientSettings.getApiKey());
|
||||
|
||||
var result = builder.build().toResponse();
|
||||
var result = builder.build().toHttpResponse(HttpResponse.BodyHandlers.ofByteArray());
|
||||
|
||||
if (result.isFailure())
|
||||
throw new TikTokSignServerException("Unable to get websocket connection credentials - "+result);
|
||||
|
||||
@@ -42,11 +42,11 @@ public class HttpClient {
|
||||
protected final String url;
|
||||
private final Pattern pattern = Pattern.compile("charset=(.*?)(?=&|$)");
|
||||
|
||||
public ActionResult<HttpResponse<byte[]>> toResponse() {
|
||||
public <T> ActionResult<HttpResponse<T>> toHttpResponse(HttpResponse.BodyHandler<T> handler) {
|
||||
var client = prepareClient();
|
||||
var request = prepareGetRequest();
|
||||
try {
|
||||
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
|
||||
var response = client.send(request, handler);
|
||||
var result = ActionResult.of(response);
|
||||
return switch (response.statusCode()) {
|
||||
case 420 -> result.message("HttpResponse Code:", response.statusCode(), "| IP Cloudflare Blocked.").failure();
|
||||
@@ -68,8 +68,12 @@ public class HttpClient {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> ActionResult<T> toResponse(HttpResponse.BodyHandler<T> handler) {
|
||||
return toHttpResponse(handler).map(HttpResponse::body);
|
||||
}
|
||||
|
||||
public ActionResult<String> toJsonResponse() {
|
||||
return toResponse().map(content -> new String(content.body(), charsetFrom(content.headers())));
|
||||
return toResponse(HttpResponse.BodyHandlers.ofString());
|
||||
}
|
||||
|
||||
private Charset charsetFrom(HttpHeaders headers) {
|
||||
@@ -87,7 +91,7 @@ public class HttpClient {
|
||||
}
|
||||
|
||||
public ActionResult<byte[]> toBinaryResponse() {
|
||||
return toResponse().map(HttpResponse::body);
|
||||
return toResponse(HttpResponse.BodyHandlers.ofByteArray());
|
||||
}
|
||||
|
||||
public URI toUri() {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class HttpProxyClient extends HttpClient {
|
||||
throw new TikTokProxyRequestException(e);
|
||||
} catch (IOException e) {
|
||||
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
||||
return super.toResponse();
|
||||
return super.toHttpResponse(HttpResponse.BodyHandlers.ofByteArray());
|
||||
throw new TikTokProxyRequestException(e);
|
||||
} catch (Exception e) {
|
||||
throw new TikTokLiveRequestException(e);
|
||||
@@ -122,7 +122,7 @@ public class HttpProxyClient extends HttpClient {
|
||||
return ActionResult.success(response);
|
||||
} catch (IOException e) {
|
||||
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
||||
return super.toResponse();
|
||||
return super.toHttpResponse(HttpResponse.BodyHandlers.ofByteArray());
|
||||
if (proxySettings.isAutoDiscard())
|
||||
proxySettings.remove();
|
||||
throw new TikTokProxyRequestException(e);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<parent>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>4.28.3</version>
|
||||
<version>4.26.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
@@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<artifactId>API</artifactId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>extension-recorder</artifactId>
|
||||
|
||||
@@ -34,6 +34,6 @@ public class DownloadData {
|
||||
private String sessionId;
|
||||
|
||||
public String getFullUrl() {
|
||||
return downloadLiveUrl + (downloadLiveUrl.contains("?") ? "&" : "?") + "_webnoredir=1&session_id=" + sessionId;
|
||||
return downloadLiveUrl + (downloadLiveUrl.contains("?") ? "&" : "?") + "_webnoredir=1&_session_id=" + sessionId;
|
||||
}
|
||||
}
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
<modules>
|
||||
<module>API</module>
|
||||
<module>Client</module>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>TikTokLiveJava</artifactId>
|
||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||
<version>1.8.8-Release</version>
|
||||
<version>1.8.10-Release</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user