mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Compare commits
6 Commits
1.11.7-Rel
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
203d7f414d | ||
|
|
95e352908d | ||
|
|
3f00256634 | ||
|
|
089d8d6ed8 | ||
|
|
4be74c45ff | ||
|
|
db4d382e34 |
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
|
|||||||
@@ -39,11 +39,16 @@ public class TikTokGiftComboEvent extends TikTokGiftEvent {
|
|||||||
this.comboState = comboState;
|
this.comboState = comboState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TikTokGiftComboEvent(Gift gift, User host, User user, int combo, GiftComboStateType comboState) {
|
||||||
|
super(gift, user, host, combo);
|
||||||
|
this.comboState = comboState;
|
||||||
|
}
|
||||||
|
|
||||||
public static TikTokGiftComboEvent of(Gift gift, int combo, GiftComboStateType comboState) {
|
public static TikTokGiftComboEvent of(Gift gift, int combo, GiftComboStateType comboState) {
|
||||||
return new TikTokGiftComboEvent(
|
return new TikTokGiftComboEvent(gift, new User(0L, "Test", new Picture("")), WebcastGiftMessage.newBuilder().setComboCount(combo).build(), comboState);
|
||||||
gift,
|
}
|
||||||
new User(0L, "Test", new Picture("")),
|
|
||||||
WebcastGiftMessage.newBuilder().setComboCount(combo).build(),
|
public static TikTokGiftComboEvent of(Gift gift, User host, User user, int combo, GiftComboStateType comboState) {
|
||||||
comboState);
|
return new TikTokGiftComboEvent(gift, host, user, combo, comboState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,16 +50,24 @@ public class TikTokGiftEvent extends TikTokHeaderEvent {
|
|||||||
combo = msg.getComboCount();
|
combo = msg.getComboCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokGiftEvent(Gift gift) {
|
public TikTokGiftEvent(Gift gift, User user, User toUser, int combo) {
|
||||||
this.gift = gift;
|
this.gift = gift;
|
||||||
user = new User(0L, "sender", new Picture(""));
|
this.user = user;
|
||||||
toUser = new User(0L, "receiver", new Picture(""));
|
this.toUser = toUser;
|
||||||
combo = 1;
|
this.combo = combo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static TikTokGiftEvent of(Gift gift) {
|
public static TikTokGiftEvent of(Gift gift) {
|
||||||
return new TikTokGiftEvent(gift);
|
return new TikTokGiftEvent(
|
||||||
|
gift,
|
||||||
|
new User(0L, "sender", new Picture("")),
|
||||||
|
new User(0L, "reviever", new Picture("")),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TikTokGiftEvent of(Gift gift, User user, User toUser) {
|
||||||
|
return new TikTokGiftEvent(gift, user, toUser, 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TikTokGiftEvent of(String name, int id, int diamonds) {
|
public static TikTokGiftEvent of(String name, int id, int diamonds) {
|
||||||
|
|||||||
@@ -50,4 +50,14 @@ public class TikTokFollowEvent extends TikTokHeaderEvent {
|
|||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TikTokFollowEvent of(User user) {
|
||||||
|
return new TikTokFollowEvent(WebcastSocialMessage.newBuilder()
|
||||||
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
|
.setUsername(user.getName())
|
||||||
|
.setNickname(user.getProfileName() != null ? user.getProfileName() : user.getName())
|
||||||
|
.setId(user.getId())
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -48,8 +48,7 @@ public class TikTokJoinEvent extends TikTokHeaderEvent {
|
|||||||
totalUsers = msg.getMemberCount();
|
totalUsers = msg.getMemberCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TikTokJoinEvent of(String userName)
|
public static TikTokJoinEvent of(String userName) {
|
||||||
{
|
|
||||||
return new TikTokJoinEvent(WebcastMemberMessage.newBuilder()
|
return new TikTokJoinEvent(WebcastMemberMessage.newBuilder()
|
||||||
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
.setUsername(userName)
|
.setUsername(userName)
|
||||||
@@ -57,4 +56,14 @@ public class TikTokJoinEvent extends TikTokHeaderEvent {
|
|||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TikTokJoinEvent of(User user) {
|
||||||
|
return new TikTokJoinEvent(WebcastMemberMessage.newBuilder()
|
||||||
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
|
.setUsername(user.getName())
|
||||||
|
.setNickname(user.getProfileName())
|
||||||
|
.setId(user.getId())
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,7 @@ public class TikTokLikeEvent extends TikTokHeaderEvent
|
|||||||
totalLikes = msg.getTotal();
|
totalLikes = msg.getTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TikTokLikeEvent of(String userName, int likes)
|
public static TikTokLikeEvent of(String userName, int likes) {
|
||||||
{
|
|
||||||
return new TikTokLikeEvent(WebcastLikeMessage.newBuilder()
|
return new TikTokLikeEvent(WebcastLikeMessage.newBuilder()
|
||||||
.setCount(likes)
|
.setCount(likes)
|
||||||
.setTotal(likes)
|
.setTotal(likes)
|
||||||
@@ -67,4 +66,15 @@ public class TikTokLikeEvent extends TikTokHeaderEvent
|
|||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TikTokLikeEvent of(User user, int likes) {
|
||||||
|
return new TikTokLikeEvent(WebcastLikeMessage.newBuilder()
|
||||||
|
.setCount(likes)
|
||||||
|
.setTotal(likes)
|
||||||
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
|
.setUsername(user.getName())
|
||||||
|
.setNickname(user.getProfileName())
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -55,4 +55,13 @@ public class TikTokShareEvent extends TikTokHeaderEvent {
|
|||||||
.build())
|
.build())
|
||||||
.build(), shaders);
|
.build(), shaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TikTokShareEvent of(User user, int shaders) {
|
||||||
|
return new TikTokShareEvent(WebcastSocialMessage.newBuilder()
|
||||||
|
.setUser(io.github.jwdeveloper.tiktok.messages.data.User.newBuilder()
|
||||||
|
.setUsername(user.getName())
|
||||||
|
.setNickname(user.getProfileName())
|
||||||
|
.build())
|
||||||
|
.build(), shaders);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,9 @@ public class ProxyClientSettings implements Iterator<ProxyData>, Iterable<ProxyD
|
|||||||
public ProxyClientSettings clone() {
|
public ProxyClientSettings clone() {
|
||||||
ProxyClientSettings settings = new ProxyClientSettings();
|
ProxyClientSettings settings = new ProxyClientSettings();
|
||||||
settings.setEnabled(enabled);
|
settings.setEnabled(enabled);
|
||||||
|
settings.setAutoDiscard(autoDiscard);
|
||||||
|
settings.setFallback(fallback);
|
||||||
|
settings.setAllowWebsocket(allowWebsocket);
|
||||||
settings.setRotation(rotation);
|
settings.setRotation(rotation);
|
||||||
settings.setIndex(index);
|
settings.setIndex(index);
|
||||||
settings.setType(type);
|
settings.setType(type);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> ActionResult<T> toResponse(HttpResponse.BodyHandler<T> handler) {
|
protected <T> ActionResult<T> toResponse(HttpResponse.BodyHandler<T> handler) {
|
||||||
return toHttpResponse(handler).map(HttpResponse::body);
|
return toHttpResponse(handler).map(HttpResponse::body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ import java.io.IOException;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.net.http.*;
|
import java.net.http.*;
|
||||||
import java.net.http.HttpResponse.ResponseInfo;
|
import java.net.http.HttpResponse.ResponseInfo;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Flow;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class HttpProxyClient extends HttpClient {
|
public class HttpProxyClient extends HttpClient {
|
||||||
@@ -45,14 +47,14 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
this.proxySettings = httpClientSettings.getProxyClientSettings();
|
this.proxySettings = httpClientSettings.getProxyClientSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult<HttpResponse<byte[]>> toResponse() {
|
public <T> ActionResult<HttpResponse<T>> toHttpResponse(HttpResponse.BodyHandler<T> handler) {
|
||||||
return switch (proxySettings.getType()) {
|
return switch (proxySettings.getType()) {
|
||||||
case HTTP, DIRECT -> handleHttpProxyRequest();
|
case HTTP, DIRECT -> handleHttpProxyRequest(handler);
|
||||||
default -> handleSocksProxyRequest();
|
default -> handleSocksProxyRequest(handler);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult<HttpResponse<byte[]>> handleHttpProxyRequest() {
|
public <T> ActionResult<HttpResponse<T>> handleHttpProxyRequest(HttpResponse.BodyHandler<T> handler) {
|
||||||
var builder = java.net.http.HttpClient.newBuilder()
|
var builder = java.net.http.HttpClient.newBuilder()
|
||||||
.followRedirects(java.net.http.HttpClient.Redirect.NORMAL)
|
.followRedirects(java.net.http.HttpClient.Redirect.NORMAL)
|
||||||
.cookieHandler(new CookieManager())
|
.cookieHandler(new CookieManager())
|
||||||
@@ -67,7 +69,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
var client = builder.build();
|
var client = builder.build();
|
||||||
var request = prepareRequest();
|
var request = prepareRequest();
|
||||||
|
|
||||||
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
|
var response = client.send(request, handler);
|
||||||
if (response.statusCode() != 200)
|
if (response.statusCode() != 200)
|
||||||
continue;
|
continue;
|
||||||
return ActionResult.success(response);
|
return ActionResult.success(response);
|
||||||
@@ -77,7 +79,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
throw new TikTokProxyRequestException(e);
|
throw new TikTokProxyRequestException(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
||||||
return super.toHttpResponse(HttpResponse.BodyHandlers.ofByteArray());
|
return super.toHttpResponse(handler);
|
||||||
throw new TikTokProxyRequestException(e);
|
throw new TikTokProxyRequestException(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new TikTokLiveRequestException(e);
|
throw new TikTokLiveRequestException(e);
|
||||||
@@ -86,7 +88,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
throw new TikTokLiveRequestException("No more proxies available!");
|
throw new TikTokLiveRequestException("No more proxies available!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionResult<HttpResponse<byte[]>> handleSocksProxyRequest() {
|
private <T> ActionResult<HttpResponse<T>> handleSocksProxyRequest(HttpResponse.BodyHandler<T> handler) {
|
||||||
try {
|
try {
|
||||||
SSLContext sc = SSLContext.getInstance("SSL");
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
sc.init(null, new TrustManager[]{ new X509TrustManager() {
|
sc.init(null, new TrustManager[]{ new X509TrustManager() {
|
||||||
@@ -95,7 +97,8 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
public X509Certificate[] getAcceptedIssuers() { return null; }
|
public X509Certificate[] getAcceptedIssuers() { return null; }
|
||||||
}}, null);
|
}}, null);
|
||||||
|
|
||||||
URL url = toUri().toURL();
|
URI uri = toUri();
|
||||||
|
URL url = uri.toURL();
|
||||||
|
|
||||||
if (proxySettings.hasNext()) {
|
if (proxySettings.hasNext()) {
|
||||||
try {
|
try {
|
||||||
@@ -117,12 +120,22 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
|
|
||||||
var responseInfo = createResponseInfo(socksConnection.getResponseCode(), headers);
|
var responseInfo = createResponseInfo(socksConnection.getResponseCode(), headers);
|
||||||
|
|
||||||
var response = createHttpResponse(body, toUri(), responseInfo);
|
HttpResponse.BodySubscriber<T> subscriber = handler.apply(responseInfo);
|
||||||
|
|
||||||
|
subscriber.onSubscribe(new Flow.Subscription() {
|
||||||
|
@Override public void request(long n) {}
|
||||||
|
@Override public void cancel() {}
|
||||||
|
});
|
||||||
|
|
||||||
|
subscriber.onNext(List.of(ByteBuffer.wrap(body)));
|
||||||
|
subscriber.onComplete();
|
||||||
|
|
||||||
|
var response = createHttpResponse(subscriber.getBody().toCompletableFuture().join(), uri, responseInfo);
|
||||||
|
|
||||||
return ActionResult.success(response);
|
return ActionResult.success(response);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
if (e.getMessage().contains("503") && proxySettings.isFallback()) // Indicates proxy protocol is not supported
|
||||||
return super.toHttpResponse(HttpResponse.BodyHandlers.ofByteArray());
|
return super.toHttpResponse(handler);
|
||||||
if (proxySettings.isAutoDiscard())
|
if (proxySettings.isAutoDiscard())
|
||||||
proxySettings.remove();
|
proxySettings.remove();
|
||||||
throw new TikTokProxyRequestException(e);
|
throw new TikTokProxyRequestException(e);
|
||||||
@@ -160,7 +173,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponse<byte[]> createHttpResponse(byte[] body,
|
private <T> HttpResponse<T> createHttpResponse(T body,
|
||||||
URI uri,
|
URI uri,
|
||||||
ResponseInfo info) {
|
ResponseInfo info) {
|
||||||
return new HttpResponse<>()
|
return new HttpResponse<>()
|
||||||
@@ -176,7 +189,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<HttpResponse<byte[]>> previousResponse() {
|
public Optional<HttpResponse<T>> previousResponse() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +199,7 @@ public class HttpProxyClient extends HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] body() {
|
public T body() {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>extension-recorder</artifactId>
|
<artifactId>extension-recorder</artifactId>
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>API</module>
|
<module>API</module>
|
||||||
<module>Client</module>
|
<module>Client</module>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<version>1.11.6-Release</version>
|
<version>1.11.9-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user