mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 01:09:40 -05:00
Compare commits
6 Commits
1.1.1-Rele
...
develop-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39c3b5b1bc | ||
|
|
f40a26ad7c | ||
|
|
4fab46b3d9 | ||
|
|
a89e2c2e08 | ||
|
|
bc8c56982f | ||
|
|
fa5385d893 |
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.data.events.control;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokLiveClientEvent;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered when client is connecting to live is successfully established.
|
|
||||||
*/
|
|
||||||
@EventMeta(eventType = EventType.Control)
|
|
||||||
public class TikTokConnectingEvent extends TikTokLiveClientEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.data.events.http;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.requests.LiveData;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EventMeta(eventType = EventType.Debug)
|
|
||||||
public class TikTokRoomDataResponseEvent extends TikTokEvent
|
|
||||||
{
|
|
||||||
private final LiveData.Response liveData;
|
|
||||||
}
|
|
||||||
@@ -36,6 +36,7 @@ public class LiveClientSettings {
|
|||||||
/**
|
/**
|
||||||
* ISO-Language for Client
|
* ISO-Language for Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String clientLanguage;
|
private String clientLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +44,7 @@ public class LiveClientSettings {
|
|||||||
*/
|
*/
|
||||||
private boolean retryOnConnectionFailure;
|
private boolean retryOnConnectionFailure;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Before retrying connect, wait for select amount of time
|
* Before retrying connect, wait for select amount of time
|
||||||
*/
|
*/
|
||||||
@@ -51,35 +53,42 @@ public class LiveClientSettings {
|
|||||||
/**
|
/**
|
||||||
* Whether to print Logs to Console
|
* Whether to print Logs to Console
|
||||||
*/
|
*/
|
||||||
private boolean printToConsole = true;
|
|
||||||
|
|
||||||
|
private boolean printToConsole = true;
|
||||||
/**
|
/**
|
||||||
* LoggingLevel for Logs
|
* LoggingLevel for Logs
|
||||||
*/
|
*/
|
||||||
private Level logLevel;
|
private Level logLevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional: Use it if you need to change TikTok live hostname in builder
|
* Optional: Use it if you need to change TikTok live hostname in builder
|
||||||
*/
|
*/
|
||||||
private String hostName;
|
private String hostName;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters used in requests to TikTok api
|
* Parameters used in requests to TikTok api
|
||||||
*/
|
*/
|
||||||
private HttpClientSettings httpSettings;
|
private HttpClientSettings httpSettings;
|
||||||
|
|
||||||
/**
|
|
||||||
|
/*
|
||||||
* Optional: Sometimes not every messages from chat are send to TikTokLiveJava to fix this issue you can set sessionId
|
* Optional: Sometimes not every messages from chat are send to TikTokLiveJava to fix this issue you can set sessionId
|
||||||
* documentation how to obtain sessionId https://github.com/isaackogan/TikTok-Live-Connector#send-chat-messages
|
* documentation how to obtain sessionId https://github.com/isaackogan/TikTok-Live-Connector#send-chat-messages
|
||||||
*/
|
*/
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Optional: By default roomID is fetched before connect to live, but you can set it manually
|
* Optional: By default roomID is fetched before connect to live, but you can set it manually
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private String roomId;
|
private String roomId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static LiveClientSettings createDefault()
|
public static LiveClientSettings createDefault()
|
||||||
{
|
{
|
||||||
var httpSettings = new HttpClientSettings();
|
var httpSettings = new HttpClientSettings();
|
||||||
@@ -94,10 +103,12 @@ public class LiveClientSettings {
|
|||||||
clientSettings.setPrintToConsole(false);
|
clientSettings.setPrintToConsole(false);
|
||||||
clientSettings.setLogLevel(Level.ALL);
|
clientSettings.setLogLevel(Level.ALL);
|
||||||
|
|
||||||
|
|
||||||
clientSettings.setHttpSettings(httpSettings);
|
clientSettings.setHttpSettings(httpSettings);
|
||||||
return clientSettings;
|
return clientSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Parameters for HTTP-Request
|
* Default Parameters for HTTP-Request
|
||||||
*/
|
*/
|
||||||
@@ -136,9 +147,11 @@ public class LiveClientSettings {
|
|||||||
clientParams.put("webcast_sdk_version", "1.3.0");
|
clientParams.put("webcast_sdk_version", "1.3.0");
|
||||||
clientParams.put("update_version_code", "1.3.0");
|
clientParams.put("update_version_code", "1.3.0");
|
||||||
|
|
||||||
|
|
||||||
return clientParams;
|
return clientParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Headers for HTTP-Request
|
* Default Headers for HTTP-Request
|
||||||
*/
|
*/
|
||||||
@@ -154,4 +167,6 @@ public class LiveClientSettings {
|
|||||||
headers.put("Accept-Language", "en-US,en; q=0.9");
|
headers.put("Accept-Language", "en-US,en; q=0.9");
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ public class ProxyClientSettings implements Iterator<ProxyData>
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
proxyList.remove(index);
|
proxyList.remove(index);
|
||||||
lastSuccess = false; // index is no longer valid and lastSuccess needs falsified
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(int index) {
|
public void setIndex(int index) {
|
||||||
|
|||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.5.5</version>
|
<version>1.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class TikTokLive {
|
|||||||
return requests().fetchLiveUserData(hostName).isLiveOnline();
|
return requests().fetchLiveUserData(hostName).isLiveOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param hostName profile name of Tiktok user could be found in profile link
|
* @param hostName profile name of Tiktok user could be found in profile link
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ import io.github.jwdeveloper.tiktok.data.events.TikTokDisconnectedEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokReconnectingEvent;
|
import io.github.jwdeveloper.tiktok.data.events.TikTokReconnectingEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.control.TikTokConnectingEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.http.TikTokRoomDataResponseEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
|
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.requests.LiveConnectionData;
|
import io.github.jwdeveloper.tiktok.data.requests.LiveConnectionData;
|
||||||
import io.github.jwdeveloper.tiktok.data.requests.LiveData;
|
import io.github.jwdeveloper.tiktok.data.requests.LiveData;
|
||||||
@@ -122,7 +120,7 @@ public class TikTokLiveClient implements LiveClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setState(ConnectionState.CONNECTING);
|
setState(ConnectionState.CONNECTING);
|
||||||
tikTokEventHandler.publish(this,new TikTokConnectingEvent());
|
|
||||||
var userDataRequest = new LiveUserData.Request(liveRoomInfo.getHostName());
|
var userDataRequest = new LiveUserData.Request(liveRoomInfo.getHostName());
|
||||||
var userData = httpClient.fetchLiveUserData(userDataRequest);
|
var userData = httpClient.fetchLiveUserData(userDataRequest);
|
||||||
liveRoomInfo.setStartTime(userData.getStartedAtTimeStamp());
|
liveRoomInfo.setStartTime(userData.getStartedAtTimeStamp());
|
||||||
@@ -136,7 +134,6 @@ public class TikTokLiveClient implements LiveClient {
|
|||||||
|
|
||||||
var liveDataRequest = new LiveData.Request(userData.getRoomId());
|
var liveDataRequest = new LiveData.Request(userData.getRoomId());
|
||||||
var liveData = httpClient.fetchLiveData(liveDataRequest);
|
var liveData = httpClient.fetchLiveData(liveDataRequest);
|
||||||
tikTokEventHandler.publish(this, new TikTokRoomDataResponseEvent(liveData));
|
|
||||||
if (liveData.getLiveStatus() == LiveData.LiveStatus.HostNotFound) {
|
if (liveData.getLiveStatus() == LiveData.LiveStatus.HostNotFound) {
|
||||||
throw new TikTokLiveOfflineHostException("LiveStream for Host name could not be found.");
|
throw new TikTokLiveOfflineHostException("LiveStream for Host name could not be found.");
|
||||||
}
|
}
|
||||||
@@ -162,8 +159,8 @@ public class TikTokLiveClient implements LiveClient {
|
|||||||
if (liveRoomInfo.hasConnectionState(ConnectionState.DISCONNECTED)) {
|
if (liveRoomInfo.hasConnectionState(ConnectionState.DISCONNECTED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(ConnectionState.DISCONNECTED);
|
|
||||||
webSocketClient.stop();
|
webSocketClient.stop();
|
||||||
|
setState(ConnectionState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setState(ConnectionState connectionState) {
|
private void setState(ConnectionState connectionState) {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public class HttpProxyClient extends HttpClient
|
|||||||
try {
|
try {
|
||||||
Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxySettings.next().toSocketAddress());
|
Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxySettings.next().toSocketAddress());
|
||||||
|
|
||||||
|
System.err.println("Connecting to "+ url);
|
||||||
HttpsURLConnection socksConnection = (HttpsURLConnection) url.openConnection(proxy);
|
HttpsURLConnection socksConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||||
socksConnection.setSSLSocketFactory(sc.getSocketFactory());
|
socksConnection.setSSLSocketFactory(sc.getSocketFactory());
|
||||||
socksConnection.setConnectTimeout(httpClientSettings.getTimeout().toMillisPart());
|
socksConnection.setConnectTimeout(httpClientSettings.getTimeout().toMillisPart());
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public class LiveDataMapper {
|
|||||||
public LiveData.Response map(String json) {
|
public LiveData.Response map(String json) {
|
||||||
var response = new LiveData.Response();
|
var response = new LiveData.Response();
|
||||||
|
|
||||||
response.setJson(json);
|
|
||||||
|
|
||||||
var parsedJson = JsonParser.parseString(json);
|
var parsedJson = JsonParser.parseString(json);
|
||||||
var jsonObject = parsedJson.getAsJsonObject();
|
var jsonObject = parsedJson.getAsJsonObject();
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ public class TikTokListenersManager implements ListenersManager {
|
|||||||
EventConsumer eventMethodRef = (liveClient, event) ->
|
EventConsumer eventMethodRef = (liveClient, event) ->
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
method.setAccessible(true);
|
|
||||||
method.invoke(listener, liveClient, event);
|
method.invoke(listener, liveClient, event);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new TikTokEventListenerMethodException(e);
|
throw new TikTokEventListenerMethodException(e);
|
||||||
|
|||||||
@@ -22,11 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.websocket;
|
package io.github.jwdeveloper.tiktok.websocket;
|
||||||
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.*;
|
import io.github.jwdeveloper.tiktok.*;
|
||||||
import io.github.jwdeveloper.tiktok.data.dto.ProxyData;
|
import io.github.jwdeveloper.tiktok.data.dto.ProxyData;
|
||||||
import io.github.jwdeveloper.tiktok.data.requests.LiveConnectionData;
|
import io.github.jwdeveloper.tiktok.data.requests.LiveConnectionData;
|
||||||
import io.github.jwdeveloper.tiktok.data.settings.*;
|
import io.github.jwdeveloper.tiktok.data.settings.*;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.*;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
|
|
||||||
@@ -40,8 +41,6 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
private final TikTokLiveMessageHandler messageHandler;
|
private final TikTokLiveMessageHandler messageHandler;
|
||||||
private final TikTokLiveEventHandler tikTokEventHandler;
|
private final TikTokLiveEventHandler tikTokEventHandler;
|
||||||
private WebSocketClient webSocketClient;
|
private WebSocketClient webSocketClient;
|
||||||
|
|
||||||
private final TikTokWebSocketPingingTask pingingTask;
|
|
||||||
private boolean isConnected;
|
private boolean isConnected;
|
||||||
|
|
||||||
public TikTokWebSocketClient(
|
public TikTokWebSocketClient(
|
||||||
@@ -52,11 +51,11 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
this.messageHandler = messageHandler;
|
this.messageHandler = messageHandler;
|
||||||
this.tikTokEventHandler = tikTokEventHandler;
|
this.tikTokEventHandler = tikTokEventHandler;
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
pingingTask = new TikTokWebSocketPingingTask();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(LiveConnectionData.Response connectionData, LiveClient liveClient) {
|
public void start(LiveConnectionData.Response connectionData, LiveClient liveClient)
|
||||||
|
{
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
@@ -82,15 +81,31 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
private void connectDefault() {
|
private void connectDefault() {
|
||||||
try {
|
try {
|
||||||
webSocketClient.connect();
|
webSocketClient.connect();
|
||||||
pingingTask.run(webSocketClient);
|
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e)
|
||||||
|
{
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
throw new TikTokLiveException("Failed to connect to the websocket", e);
|
throw new TikTokLiveException("Failed to connect to the websocket", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectProxy(ProxyClientSettings proxySettings) {
|
public void connectProxy(ProxyClientSettings proxySettings) {
|
||||||
|
while (proxySettings.hasNext()) {
|
||||||
|
ProxyData proxyData = proxySettings.next();
|
||||||
|
if (!tryProxyConnection(proxySettings, proxyData)) {
|
||||||
|
if (proxySettings.isAutoDiscard())
|
||||||
|
proxySettings.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
isConnected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isConnected)
|
||||||
|
throw new TikTokLiveException("Failed to connect to the websocket");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tryProxyConnection(ProxyClientSettings proxySettings, ProxyData proxyData) {
|
||||||
|
webSocketClient.setProxy(new Proxy(proxySettings.getType(), proxyData.toSocketAddress()));
|
||||||
try {
|
try {
|
||||||
if (proxySettings.getType() == Proxy.Type.SOCKS) {
|
if (proxySettings.getType() == Proxy.Type.SOCKS) {
|
||||||
SSLContext sc = SSLContext.getInstance("SSL");
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
@@ -101,31 +116,10 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
}}, null);
|
}}, null);
|
||||||
webSocketClient.setSocketFactory(sc.getSocketFactory());
|
webSocketClient.setSocketFactory(sc.getSocketFactory());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
// This will never be thrown.
|
|
||||||
throw new TikTokProxyRequestException("Unable to set Socks proxy SSL instance");
|
|
||||||
}
|
|
||||||
while (proxySettings.hasNext()) {
|
|
||||||
ProxyData proxyData = proxySettings.next();
|
|
||||||
if (!tryProxyConnection(proxySettings, proxyData)) {
|
|
||||||
if (proxySettings.isAutoDiscard())
|
|
||||||
proxySettings.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pingingTask.run(webSocketClient);
|
|
||||||
isConnected = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isConnected)
|
|
||||||
throw new TikTokLiveException("Failed to connect to the websocket");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean tryProxyConnection(ProxyClientSettings proxySettings, ProxyData proxyData) {
|
|
||||||
try {
|
|
||||||
webSocketClient.setProxy(new Proxy(proxySettings.getType(), proxyData.toSocketAddress()));
|
|
||||||
webSocketClient.connect();
|
webSocketClient.connect();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +127,6 @@ public class TikTokWebSocketClient implements SocketClient {
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
if (isConnected && webSocketClient != null && webSocketClient.isOpen()) {
|
if (isConnected && webSocketClient != null && webSocketClient.isOpen()) {
|
||||||
webSocketClient.closeConnection(0, "");
|
webSocketClient.closeConnection(0, "");
|
||||||
pingingTask.stop();
|
|
||||||
}
|
}
|
||||||
webSocketClient = null;
|
webSocketClient = null;
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package io.github.jwdeveloper.tiktok.websocket;
|
|
||||||
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class TikTokWebSocketPingingTask
|
|
||||||
{
|
|
||||||
private Thread thread;
|
|
||||||
private boolean isRunning = false;
|
|
||||||
private final int MIN_TIMEOUT = 250;
|
|
||||||
private final int MAX_TIMEOUT = 500;
|
|
||||||
|
|
||||||
public void run(WebSocket webSocket)
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
thread = new Thread(() -> pingTask(webSocket));
|
|
||||||
isRunning = true;
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
if (thread != null)
|
|
||||||
thread.interrupt();
|
|
||||||
isRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void pingTask(WebSocket webSocket)
|
|
||||||
{
|
|
||||||
var random = new Random();
|
|
||||||
while (isRunning) {
|
|
||||||
try {
|
|
||||||
if (!webSocket.isOpen()) {
|
|
||||||
Thread.sleep(100);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
webSocket.sendPing();
|
|
||||||
|
|
||||||
var timeout = random.nextInt(MAX_TIMEOUT)+MIN_TIMEOUT;
|
|
||||||
Thread.sleep(timeout);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
isRunning = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -60,24 +60,6 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>extension-collector</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>extension-recorder</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>extension-collector</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.TikTokLiveCollector;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CollectorExample {
|
|
||||||
|
|
||||||
|
|
||||||
private static String mongoUser;
|
|
||||||
|
|
||||||
private static String mongoPassword;
|
|
||||||
|
|
||||||
private static String mongoDatabase;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
|
|
||||||
var collector = TikTokLiveCollector.use(settings ->
|
|
||||||
{
|
|
||||||
settings.setConnectionUrl("mongodb+srv://" + mongoUser + ":" + mongoPassword + "@" + mongoDatabase + "/?retryWrites=true&w=majority");
|
|
||||||
settings.setDatabaseName("tiktok");
|
|
||||||
});
|
|
||||||
collector.connectDatabase();
|
|
||||||
|
|
||||||
var users = List.of("tehila_723", "dino123597", "domaxyzx", "dash4214", "obserwacje_live");
|
|
||||||
var sessionTag = "Tag1";
|
|
||||||
for (var user : users) {
|
|
||||||
TikTokLive.newClient(user)
|
|
||||||
.configure(liveClientSettings ->
|
|
||||||
{
|
|
||||||
liveClientSettings.setPrintToConsole(true);
|
|
||||||
})
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
event.getException().printStackTrace();
|
|
||||||
})
|
|
||||||
.addListener(collector.newListener(Map.of("sessionTag", sessionTag), document ->
|
|
||||||
{
|
|
||||||
if (document.get("dataType") == "message") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}))
|
|
||||||
.buildAndConnectAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.in.read();
|
|
||||||
collector.disconnectDatabase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -57,7 +57,7 @@ public class ListenerExample
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
* Method in TikTokEventListener should meet 4 requirements to be detected
|
||||||
* - must have @TikTokEventObserver annotation
|
* - must have @TikTokEventHandler annotation
|
||||||
* - must have 2 parameters
|
* - must have 2 parameters
|
||||||
* - first parameter must be LiveClient
|
* - first parameter must be LiveClient
|
||||||
* - second must be class that extending TikTokEvent
|
* - second must be class that extending TikTokEvent
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ package io.github.jwdeveloper.tiktok;
|
|||||||
|
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
|
|
||||||
public class ProxyExample {
|
public class ProxyExample
|
||||||
|
{
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||||
.configure(clientSettings -> {
|
.configure(clientSettings -> {
|
||||||
@@ -37,16 +38,13 @@ public class ProxyExample {
|
|||||||
})
|
})
|
||||||
.onConnected((liveClient, event) ->
|
.onConnected((liveClient, event) ->
|
||||||
liveClient.getLogger().info("Connected "+liveClient.getRoomInfo().getHostName()))
|
liveClient.getLogger().info("Connected "+liveClient.getRoomInfo().getHostName()))
|
||||||
.onComment((liveClient, event) -> liveClient.getLogger().info(event.getUser().getName()+": "+event.getText()))
|
|
||||||
.onLike((liveClient, event) -> liveClient.getLogger().info(event.getUser().getName()+" sent "+event.getLikes()+"x likes!"))
|
|
||||||
.onDisconnected((liveClient, event) ->
|
.onDisconnected((liveClient, event) ->
|
||||||
liveClient.getLogger().info("Disconnect reason: "+event.getReason()))
|
liveClient.getLogger().info("Disconnect reason: "+event.getReason()))
|
||||||
.onLiveEnded((liveClient, event) ->
|
.onLiveEnded((liveClient, event) ->
|
||||||
liveClient.getLogger().info("Live Ended: "+liveClient.getRoomInfo().getHostName()))
|
liveClient.getLogger().info("Live Ended"))
|
||||||
.onError((liveClient, event) ->
|
.onError((liveClient, event) ->
|
||||||
event.getException().printStackTrace())
|
event.getException().printStackTrace())
|
||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
|
|
||||||
System.in.read();
|
System.in.read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok;
|
|
||||||
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.TikTokLiveRecorder;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.event.TikTokLiveRecorderStartedEvent;
|
|
||||||
|
|
||||||
public class RecorderExample {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
TikTokLive.newClient("bangbetmenygy")
|
|
||||||
.configure(liveClientSettings ->
|
|
||||||
{
|
|
||||||
liveClientSettings.setPrintToConsole(true);
|
|
||||||
})
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
event.getException().printStackTrace();
|
|
||||||
})
|
|
||||||
.addListener(TikTokLiveRecorder.use(recorderSettings ->
|
|
||||||
{
|
|
||||||
recorderSettings.setFfmpegPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\libs\\ffmpeg.exe");
|
|
||||||
recorderSettings.setOutputPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\out");
|
|
||||||
recorderSettings.setOutputFileName("test.flv");
|
|
||||||
}))
|
|
||||||
.onEvent(TikTokLiveRecorderStartedEvent.class, (liveClient, event) ->
|
|
||||||
{
|
|
||||||
System.out.println(event.getDownloadData().getFullUrl());
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,18 +23,27 @@
|
|||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubNotifyEvent;
|
import io.github.jwdeveloper.tiktok.data.events.TikTokSubNotifyEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
|
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
|
||||||
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||||
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
||||||
|
import io.github.jwdeveloper.tiktok.utils.JsonUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SimpleExample {
|
public class SimpleExample {
|
||||||
public static String TIKTOK_HOSTNAME = "dash4114";
|
public static String TIKTOK_HOSTNAME = "dash4214";
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
|
|
||||||
showLogo();
|
showLogo();
|
||||||
|
|
||||||
|
|||||||
500
README.md
500
README.md
@@ -29,7 +29,8 @@ A Java library inspired by [TikTokLive](https://github.com/isaackogan/TikTokLive
|
|||||||
The library includes a wrapper that connects to the WebCast service using just the username (`uniqueId`). This allows you to connect to your own live chat as well as the live chat of other streamers.
|
The library includes a wrapper that connects to the WebCast service using just the username (`uniqueId`). This allows you to connect to your own live chat as well as the live chat of other streamers.
|
||||||
No credentials are required. Events such as [Members Joining](#member), [Gifts](#gift), [Subscriptions](#subscribe), [Viewers](#roomuser), [Follows](#social), [Shares](#social), [Questions](#questionnew), [Likes](#like) and [Battles](#linkmicbattle) can be tracked.
|
No credentials are required. Events such as [Members Joining](#member), [Gifts](#gift), [Subscriptions](#subscribe), [Viewers](#roomuser), [Follows](#social), [Shares](#social), [Questions](#questionnew), [Likes](#like) and [Battles](#linkmicbattle) can be tracked.
|
||||||
|
|
||||||
|
# Contributors
|
||||||
|
[Library documentation for contributors](https://github.com/jwdeveloper/TikTokLiveJava/wiki)
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="https://www.youtube.com/watch?v=eerWGgUKc6c" align="right" target="blank"><img src="https://img.youtube.com/vi/eerWGgUKc6c/hqdefault.jpg" alt="IMAGE ALT TEXT" width="38%" align="right"></a>
|
<a href="https://www.youtube.com/watch?v=eerWGgUKc6c" align="right" target="blank"><img src="https://img.youtube.com/vi/eerWGgUKc6c/hqdefault.jpg" alt="IMAGE ALT TEXT" width="38%" align="right"></a>
|
||||||
@@ -49,7 +50,6 @@ Do you prefer other programming languages?
|
|||||||
#### Overview
|
#### Overview
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [Events](#events)
|
- [Events](#events)
|
||||||
- [Extensions](#extensions)
|
|
||||||
- [Listeners](#listeners)
|
- [Listeners](#listeners)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ Maven
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
||||||
<artifactId>Client</artifactId>
|
<artifactId>Client</artifactId>
|
||||||
<version>1.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -87,7 +87,7 @@ dependencyResolutionManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.jwdeveloper.TikTok-Live-Java:Client:1.1.0-Release'
|
implementation 'com.github.jwdeveloper.TikTok-Live-Java:Client:1.0.16-Release'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -166,79 +166,37 @@ TikTokLive.newClient("bangbetmenygy")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Events
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Control**:
|
**Control**:
|
||||||
|
|
||||||
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
|
|
||||||
- [onError](#onerror-tiktokerrorevent)
|
|
||||||
- [onConnected](#onconnected-tiktokconnectedevent)
|
- [onConnected](#onconnected-tiktokconnectedevent)
|
||||||
- [onDisconnected](#ondisconnected-tiktokdisconnectedevent)
|
- [onDisconnected](#ondisconnected-tiktokdisconnectedevent)
|
||||||
|
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
|
||||||
|
- [onError](#onerror-tiktokerrorevent)
|
||||||
|
|
||||||
**Message**:
|
**Message**:
|
||||||
|
|
||||||
- [onEvent](#onevent-tiktokevent)
|
- [onEvent](#onevent-tiktokevent)
|
||||||
- [onEvent](#onevent-tiktokevent)
|
|
||||||
- [onComment](#oncomment-tiktokcommentevent)
|
|
||||||
- [onRoomInfo](#onroominfo-tiktokroominfoevent)
|
|
||||||
- [onGift](#ongift-tiktokgiftevent)
|
|
||||||
- [onSubscribe](#onsubscribe-tiktoksubscribeevent)
|
- [onSubscribe](#onsubscribe-tiktoksubscribeevent)
|
||||||
- [onFollow](#onfollow-tiktokfollowevent)
|
|
||||||
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
|
|
||||||
- [onLiveEnded](#onliveended-tiktokliveendedevent)
|
|
||||||
- [onQuestion](#onquestion-tiktokquestionevent)
|
- [onQuestion](#onquestion-tiktokquestionevent)
|
||||||
- [onShare](#onshare-tiktokshareevent)
|
- [onFollow](#onfollow-tiktokfollowevent)
|
||||||
- [onLiveUnpaused](#onliveunpaused-tiktokliveunpausedevent)
|
|
||||||
- [onEmote](#onemote-tiktokemoteevent)
|
|
||||||
- [onJoin](#onjoin-tiktokjoinevent)
|
|
||||||
- [onLike](#onlike-tiktoklikeevent)
|
- [onLike](#onlike-tiktoklikeevent)
|
||||||
|
- [onLiveEnded](#onliveended-tiktokliveendedevent)
|
||||||
|
- [onRoomInfo](#onroominfo-tiktokroominfoevent)
|
||||||
|
- [onShare](#onshare-tiktokshareevent)
|
||||||
|
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
|
||||||
|
- [onEmote](#onemote-tiktokemoteevent)
|
||||||
|
- [onGift](#ongift-tiktokgiftevent)
|
||||||
|
- [onComment](#oncomment-tiktokcommentevent)
|
||||||
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
|
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
|
||||||
|
- [onLiveUnpaused](#onliveunpaused-tiktokliveunpausedevent)
|
||||||
|
- [onJoin](#onjoin-tiktokjoinevent)
|
||||||
|
|
||||||
**Debug**:
|
**Debug**:
|
||||||
|
|
||||||
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
|
|
||||||
- [onWebsocketUnhandledMessage](#onwebsocketunhandledmessage-tiktokwebsocketunhandledmessageevent)
|
- [onWebsocketUnhandledMessage](#onwebsocketunhandledmessage-tiktokwebsocketunhandledmessageevent)
|
||||||
- [onHttpResponse](#onhttpresponse-tiktokhttpresponseevent)
|
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
|
||||||
- [onWebsocketMessage](#onwebsocketmessage-tiktokwebsocketmessageevent)
|
- [onWebsocketMessage](#onwebsocketmessage-tiktokwebsocketmessageevent)
|
||||||
# Examples
|
# Examples
|
||||||
<br>
|
|
||||||
|
|
||||||
## onReconnecting [TikTokReconnectingEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokReconnectingEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onReconnecting((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onError [TikTokErrorEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokErrorEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
General error event. You should handle this.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onConnected [TikTokConnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokConnectedEvent.java)
|
## onConnected [TikTokConnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokConnectedEvent.java)
|
||||||
@@ -280,15 +238,32 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onEvent [TikTokEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/common/TikTokEvent.java)
|
## onReconnecting [TikTokReconnectingEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokReconnectingEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Base class for all events
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onEvent((liveClient, event) ->
|
.onReconnecting((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onError [TikTokErrorEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokErrorEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
General error event. You should handle this.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onError((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -318,15 +293,91 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
|
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered every time a new chat comment arrives.
|
Triggers when a user creates a subscription.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onComment((liveClient, event) ->
|
.onSubscribe((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time someone asks a new question via the question feature.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onQuestion((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggers when a user follows the streamer. Based on social event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onFollow((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onLike((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onLiveEnded((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -340,8 +391,6 @@ TikTokLive.newClient("host-name")
|
|||||||
## onRoomInfo [TikTokRoomInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java)
|
## onRoomInfo [TikTokRoomInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
@@ -354,6 +403,73 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onShare [TikTokShareEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokShareEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggers when a user shares the stream. Based on social event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onShare((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time gift is sent
|
||||||
|
|
||||||
|
@see GiftSendType it has 3 states
|
||||||
|
|
||||||
|
<p>Example when user sends gift with combo</p>
|
||||||
|
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
||||||
|
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
||||||
|
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
||||||
|
<p>Combo: 12 -> comboState = GiftSendType.Finished</p>
|
||||||
|
|
||||||
|
Remember if comboState is Finished both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onGiftCombo((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time a subscriber sends an emote (sticker).
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onEmote((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
|
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
|
||||||
@@ -377,192 +493,15 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
|
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user creates a subscription.
|
Triggered every time a new chat comment arrives.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onSubscribe((liveClient, event) ->
|
.onComment((liveClient, event) ->
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user follows the streamer. Based on social event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onFollow((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time gift is sent
|
|
||||||
|
|
||||||
@see GiftSendType it has 3 states
|
|
||||||
|
|
||||||
<p>Example when user sends gift with combo</p>
|
|
||||||
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
|
||||||
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
|
||||||
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
|
||||||
<p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
|
|
||||||
<p>
|
|
||||||
Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onGiftCombo((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLiveEnded((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time someone asks a new question via the question feature.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onQuestion((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onShare [TikTokShareEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokShareEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user shares the stream. Based on social event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onShare((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLiveUnpaused [TikTokLiveUnpausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLiveUnpaused((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time a subscriber sends an emote (sticker).
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onEmote((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onJoin [TikTokJoinEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokJoinEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onJoin((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLike((liveClient, event) ->
|
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -590,13 +529,30 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onWebsocketResponse [TikTokWebsocketResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketResponseEvent.java)
|
## onLiveUnpaused [TikTokLiveUnpausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onWebsocketResponse((liveClient, event) ->
|
.onLiveUnpaused((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onJoin [TikTokJoinEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokJoinEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onJoin((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -626,17 +582,17 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onHttpResponse [TikTokHttpResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/http/TikTokHttpResponseEvent.java)
|
## onWebsocketResponse [TikTokWebsocketResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketResponseEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onHttpResponse((liveClient, event) ->
|
.onWebsocketResponse((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -646,37 +602,24 @@ TikTokLive.newClient("host-name")
|
|||||||
## onWebsocketMessage [TikTokWebsocketMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java)
|
## onWebsocketMessage [TikTokWebsocketMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered every time TikTok sends data. Data incoming as protobuf message.
|
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
|
||||||
You can deserialize the binary object depending on the use case.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onWebsocketMessage((liveClient, event) ->
|
.onWebsocketMessage((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
## Extensions
|
|
||||||
|
|
||||||
List of extensions (addons) to TiktokLiveJava
|
|
||||||
that will save your time
|
|
||||||
|
|
||||||
- [Video Recorder](https://github.com/jwdeveloper/TikTokLiveJava/tree/master/extension-recorder)
|
|
||||||
- [Live data collector to database](https://github.com/jwdeveloper/TikTokLiveJava/tree/master/extension-collector)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Listeners
|
## Listeners
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@@ -709,24 +652,24 @@ public static void main(String[] args) throws IOException {
|
|||||||
|
|
||||||
public static class CustomListener implements TikTokEventListener {
|
public static class CustomListener implements TikTokEventListener {
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
||||||
System.out.println(event.toString());
|
System.out.println(event.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
||||||
// event.getException().printStackTrace();
|
// event.getException().printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
|
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
|
||||||
var userName = event.getUser().getName();
|
var userName = event.getUser().getName();
|
||||||
var text = event.getText();
|
var text = event.getText();
|
||||||
liveClient.getLogger().info(userName + ": " + text);
|
liveClient.getLogger().info(userName + ": " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
||||||
var message = switch (event.getGift()) {
|
var message = switch (event.getGift()) {
|
||||||
case ROSE -> "Thanks :)";
|
case ROSE -> "Thanks :)";
|
||||||
@@ -751,7 +694,4 @@ public static class CustomListener implements TikTokEventListener {
|
|||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
[Library documentation for contributors](https://github.com/jwdeveloper/TikTokLiveJava/wiki)
|
|
||||||
|
|
||||||
Your improvements are welcome! Feel free to open an <a href="https://github.com/jwdeveloper/TikTok-Live-Java/issues">issue</a> or <a href="https://github.com/jwdeveloper/TikTok-Live-Java/pulls">pull request</a>.
|
Your improvements are welcome! Feel free to open an <a href="https://github.com/jwdeveloper/TikTok-Live-Java/issues">issue</a> or <a href="https://github.com/jwdeveloper/TikTok-Live-Java/pulls">pull request</a>.
|
||||||
|
|||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>Tools-EventsWebViewer</artifactId>
|
<artifactId>Tools-EventsWebViewer</artifactId>
|
||||||
|
|||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ TikTokLive.newClient("bangbetmenygy")
|
|||||||
{
|
{
|
||||||
settings.setHostName("bangbetmenygy"); // This method is useful in case you want change hostname later
|
settings.setHostName("bangbetmenygy"); // This method is useful in case you want change hostname later
|
||||||
settings.setClientLanguage("en"); // Language
|
settings.setClientLanguage("en"); // Language
|
||||||
|
settings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
|
||||||
settings.setLogLevel(Level.ALL); // Log level
|
settings.setLogLevel(Level.ALL); // Log level
|
||||||
settings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
|
settings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
|
||||||
settings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
|
settings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
|
||||||
@@ -151,73 +152,35 @@ TikTokLive.newClient("bangbetmenygy")
|
|||||||
|
|
||||||
**Control**:
|
**Control**:
|
||||||
|
|
||||||
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
|
|
||||||
- [onError](#onerror-tiktokerrorevent)
|
|
||||||
- [onConnected](#onconnected-tiktokconnectedevent)
|
- [onConnected](#onconnected-tiktokconnectedevent)
|
||||||
- [onDisconnected](#ondisconnected-tiktokdisconnectedevent)
|
- [onDisconnected](#ondisconnected-tiktokdisconnectedevent)
|
||||||
|
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
|
||||||
|
- [onError](#onerror-tiktokerrorevent)
|
||||||
|
|
||||||
**Message**:
|
**Message**:
|
||||||
|
|
||||||
- [onEvent](#onevent-tiktokevent)
|
- [onEvent](#onevent-tiktokevent)
|
||||||
- [onEvent](#onevent-tiktokevent)
|
|
||||||
- [onComment](#oncomment-tiktokcommentevent)
|
|
||||||
- [onRoomInfo](#onroominfo-tiktokroominfoevent)
|
|
||||||
- [onGift](#ongift-tiktokgiftevent)
|
|
||||||
- [onSubscribe](#onsubscribe-tiktoksubscribeevent)
|
- [onSubscribe](#onsubscribe-tiktoksubscribeevent)
|
||||||
- [onFollow](#onfollow-tiktokfollowevent)
|
|
||||||
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
|
|
||||||
- [onLiveEnded](#onliveended-tiktokliveendedevent)
|
|
||||||
- [onQuestion](#onquestion-tiktokquestionevent)
|
- [onQuestion](#onquestion-tiktokquestionevent)
|
||||||
- [onShare](#onshare-tiktokshareevent)
|
- [onFollow](#onfollow-tiktokfollowevent)
|
||||||
- [onLiveUnpaused](#onliveunpaused-tiktokliveunpausedevent)
|
|
||||||
- [onEmote](#onemote-tiktokemoteevent)
|
|
||||||
- [onJoin](#onjoin-tiktokjoinevent)
|
|
||||||
- [onLike](#onlike-tiktoklikeevent)
|
- [onLike](#onlike-tiktoklikeevent)
|
||||||
|
- [onLiveEnded](#onliveended-tiktokliveendedevent)
|
||||||
|
- [onRoomInfo](#onroominfo-tiktokroominfoevent)
|
||||||
|
- [onShare](#onshare-tiktokshareevent)
|
||||||
|
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
|
||||||
|
- [onEmote](#onemote-tiktokemoteevent)
|
||||||
|
- [onGift](#ongift-tiktokgiftevent)
|
||||||
|
- [onComment](#oncomment-tiktokcommentevent)
|
||||||
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
|
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
|
||||||
|
- [onLiveUnpaused](#onliveunpaused-tiktokliveunpausedevent)
|
||||||
|
- [onJoin](#onjoin-tiktokjoinevent)
|
||||||
|
|
||||||
**Debug**:
|
**Debug**:
|
||||||
|
|
||||||
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
|
|
||||||
- [onWebsocketUnhandledMessage](#onwebsocketunhandledmessage-tiktokwebsocketunhandledmessageevent)
|
- [onWebsocketUnhandledMessage](#onwebsocketunhandledmessage-tiktokwebsocketunhandledmessageevent)
|
||||||
- [onHttpResponse](#onhttpresponse-tiktokhttpresponseevent)
|
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
|
||||||
- [onWebsocketMessage](#onwebsocketmessage-tiktokwebsocketmessageevent)
|
- [onWebsocketMessage](#onwebsocketmessage-tiktokwebsocketmessageevent)
|
||||||
# Examples
|
# Examples
|
||||||
<br>
|
|
||||||
|
|
||||||
## onReconnecting [TikTokReconnectingEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokReconnectingEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onReconnecting((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onError [TikTokErrorEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokErrorEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
General error event. You should handle this.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onConnected [TikTokConnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokConnectedEvent.java)
|
## onConnected [TikTokConnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokConnectedEvent.java)
|
||||||
@@ -259,15 +222,32 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onEvent [TikTokEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/common/TikTokEvent.java)
|
## onReconnecting [TikTokReconnectingEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokReconnectingEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Base class for all events
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onEvent((liveClient, event) ->
|
.onReconnecting((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onError [TikTokErrorEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokErrorEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
General error event. You should handle this.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onError((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -297,15 +277,91 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
|
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered every time a new chat comment arrives.
|
Triggers when a user creates a subscription.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onComment((liveClient, event) ->
|
.onSubscribe((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time someone asks a new question via the question feature.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onQuestion((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggers when a user follows the streamer. Based on social event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onFollow((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onLike((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onLiveEnded((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -319,8 +375,6 @@ TikTokLive.newClient("host-name")
|
|||||||
## onRoomInfo [TikTokRoomInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java)
|
## onRoomInfo [TikTokRoomInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
@@ -333,6 +387,73 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onShare [TikTokShareEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokShareEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggers when a user shares the stream. Based on social event.
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onShare((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time gift is sent
|
||||||
|
|
||||||
|
@see GiftSendType it has 3 states
|
||||||
|
|
||||||
|
<p>Example when user sends gift with combo</p>
|
||||||
|
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
||||||
|
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
||||||
|
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
||||||
|
<p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
|
||||||
|
|
||||||
|
Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onGiftCombo((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
Triggered every time a subscriber sends an emote (sticker).
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onEmote((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
|
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
|
||||||
@@ -356,192 +477,15 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
|
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user creates a subscription.
|
Triggered every time a new chat comment arrives.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onSubscribe((liveClient, event) ->
|
.onComment((liveClient, event) ->
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user follows the streamer. Based on social event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onFollow((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time gift is sent
|
|
||||||
|
|
||||||
@see GiftSendType it has 3 states
|
|
||||||
|
|
||||||
<p>Example when user sends gift with combo</p>
|
|
||||||
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
|
||||||
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
|
||||||
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
|
||||||
<p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
|
|
||||||
<p>
|
|
||||||
Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onGiftCombo((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLiveEnded((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time someone asks a new question via the question feature.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onQuestion((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onShare [TikTokShareEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokShareEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggers when a user shares the stream. Based on social event.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onShare((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLiveUnpaused [TikTokLiveUnpausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLiveUnpaused((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered every time a subscriber sends an emote (sticker).
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onEmote((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onJoin [TikTokJoinEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokJoinEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onJoin((liveClient, event) ->
|
|
||||||
{
|
|
||||||
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
|
|
||||||
|
|
||||||
|
|
||||||
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
|
||||||
TikTokLive.newClient("host-name")
|
|
||||||
.onLike((liveClient, event) ->
|
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -569,13 +513,30 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onWebsocketResponse [TikTokWebsocketResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketResponseEvent.java)
|
## onLiveUnpaused [TikTokLiveUnpausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onWebsocketResponse((liveClient, event) ->
|
.onLiveUnpaused((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.buildAndConnect();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## onJoin [TikTokJoinEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokJoinEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```java
|
||||||
|
TikTokLive.newClient("host-name")
|
||||||
|
.onJoin((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -605,13 +566,13 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## onHttpResponse [TikTokHttpResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/http/TikTokHttpResponseEvent.java)
|
## onWebsocketResponse [TikTokWebsocketResponseEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketResponseEvent.java)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TikTokLive.newClient("host-name")
|
TikTokLive.newClient("host-name")
|
||||||
.onHttpResponse((liveClient, event) ->
|
.onWebsocketResponse((liveClient, event) ->
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -625,8 +586,7 @@ TikTokLive.newClient("host-name")
|
|||||||
## onWebsocketMessage [TikTokWebsocketMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java)
|
## onWebsocketMessage [TikTokWebsocketMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java)
|
||||||
|
|
||||||
|
|
||||||
Triggered every time TikTok sends data. Data incoming as protobuf message.
|
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
|
||||||
You can deserialize the binary object depending on the use case.
|
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@@ -642,17 +602,6 @@ TikTokLive.newClient("host-name")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{for item of data }}
|
|
||||||
|
|
||||||
{{if item is 2}}
|
|
||||||
|
|
||||||
my name is {{item.name}}
|
|
||||||
|
|
||||||
{{else}}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Listeners
|
## Listeners
|
||||||
@@ -679,7 +628,7 @@ my name is {{item.name}}
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Method in TikTokEventListener should meet 4 requirements to be detected
|
* Method in TikTokEventListener should meet 4 requirements to be detected
|
||||||
* - must have @TikTokEventObserver annotation
|
* - must have @TikTokEventHandler annotation
|
||||||
* - must have 2 parameters
|
* - must have 2 parameters
|
||||||
* - first parameter must be LiveClient
|
* - first parameter must be LiveClient
|
||||||
* - second must be class that extending TikTokEvent
|
* - second must be class that extending TikTokEvent
|
||||||
@@ -687,24 +636,24 @@ my name is {{item.name}}
|
|||||||
|
|
||||||
public static class CustomListener implements TikTokEventListener {
|
public static class CustomListener implements TikTokEventListener {
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
|
||||||
System.out.println(event.toString());
|
System.out.println(event.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
||||||
// event.getException().printStackTrace();
|
// event.getException().printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
|
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
|
||||||
var userName = event.getUser().getName();
|
var userName = event.getUser().getName();
|
||||||
var text = event.getText();
|
var text = event.getText();
|
||||||
liveClient.getLogger().info(userName + ": " + text);
|
liveClient.getLogger().info(userName + ": " + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
||||||
var message = switch (event.getGift()) {
|
var message = switch (event.getGift()) {
|
||||||
case ROSE -> "Thanks :)";
|
case ROSE -> "Thanks :)";
|
||||||
@@ -717,7 +666,7 @@ my name is {{item.name}}
|
|||||||
liveClient.getLogger().info(message);
|
liveClient.getLogger().info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TikTokEventObserver
|
@TikTokEventHandler
|
||||||
public void onAnyEvent(LiveClient liveClient, TikTokEvent event) {
|
public void onAnyEvent(LiveClient liveClient, TikTokEvent event) {
|
||||||
liveClient.getLogger().info(event.getClass().getSimpleName());
|
liveClient.getLogger().info(event.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
Collects live data to mongodb database
|
|
||||||
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
|
||||||
<artifactId>Client</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
|
||||||
<artifactId>extension-collector</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
|
|
||||||
```java
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
|
|
||||||
var collector = TikTokLiveCollector.use(settings ->
|
|
||||||
{
|
|
||||||
settings.setConnectionUrl("mongodb+srv://" + mongoUser + ":" + mongoPassword + "@" + mongoDatabase + "/?retryWrites=true&w=majority");
|
|
||||||
settings.setDatabaseName("tiktok");
|
|
||||||
});
|
|
||||||
collector.connectDatabase();
|
|
||||||
|
|
||||||
var users = List.of("tehila_723", "dino123597", "domaxyzx", "dash4214", "obserwacje_live");
|
|
||||||
var sessionTag = "Tag1";
|
|
||||||
for (var user : users) {
|
|
||||||
TikTokLive.newClient(user)
|
|
||||||
.configure(liveClientSettings ->
|
|
||||||
{
|
|
||||||
liveClientSettings.setPrintToConsole(true);
|
|
||||||
})
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
event.getException().printStackTrace();
|
|
||||||
})
|
|
||||||
.addListener(collector.newListener(Map.of("sessionTag", sessionTag), document ->
|
|
||||||
{
|
|
||||||
if (document.get("dataType") == "message") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}))
|
|
||||||
.buildAndConnectAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.in.read();
|
|
||||||
collector.disconnectDatabase();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
|
|
||||||
<artifactId>extension-collector</artifactId>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>API</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.protobuf</groupId>
|
|
||||||
<artifactId>protobuf-java</artifactId>
|
|
||||||
<version>3.24.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongodb-driver-sync</artifactId>
|
|
||||||
<version>4.4.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>API</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.collector;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.LiveDataCollector;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.data.LiveDataCollectorSettings;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.impl.TikTokLiveDataCollector;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class TikTokLiveCollector
|
|
||||||
{
|
|
||||||
|
|
||||||
public static TikTokLiveDataCollector use(Consumer<LiveDataCollectorSettings> consumer)
|
|
||||||
{
|
|
||||||
var settings = new LiveDataCollectorSettings();
|
|
||||||
consumer.accept(settings);
|
|
||||||
return new TikTokLiveDataCollector(settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.collector.api;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
|
|
||||||
|
|
||||||
public interface LiveDataCollector extends TikTokEventListener
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package io.github.jwdeveloper.tiktok.extension.collector.api.data;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.bson.Document;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class CollectorListenerSettings {
|
|
||||||
private Map<String, Object> extraFields;
|
|
||||||
private Function<Document, Boolean> filter;
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.collector.api.data;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class LiveDataCollectorSettings {
|
|
||||||
|
|
||||||
private String connectionUrl;
|
|
||||||
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
private String sessionTag;
|
|
||||||
|
|
||||||
|
|
||||||
public void setConnectionUrl(String connectionUrl) {
|
|
||||||
this.connectionUrl = connectionUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectionUrl(Consumer<MongoDBConnectionStringBuilder> consumer) {
|
|
||||||
var builder = new MongoDBConnectionStringBuilder();
|
|
||||||
consumer.accept(builder);
|
|
||||||
connectionUrl = builder.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.collector.api.data;
|
|
||||||
|
|
||||||
public class MongoDBConnectionStringBuilder {
|
|
||||||
private String username;
|
|
||||||
private String password;
|
|
||||||
private String database;
|
|
||||||
private String cluster;
|
|
||||||
|
|
||||||
public MongoDBConnectionStringBuilder setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MongoDBConnectionStringBuilder setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MongoDBConnectionStringBuilder setDatabase(String database) {
|
|
||||||
this.database = database;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MongoDBConnectionStringBuilder setCluster(String cluster) {
|
|
||||||
this.cluster = cluster;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String build() {
|
|
||||||
return String.format("mongodb+srv://%s:%s@%s/%s?retryWrites=true&w=majority",
|
|
||||||
username, password, cluster, database);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.collector.impl;
|
|
||||||
|
|
||||||
import com.mongodb.ConnectionString;
|
|
||||||
import com.mongodb.MongoClientSettings;
|
|
||||||
import com.mongodb.ServerApi;
|
|
||||||
import com.mongodb.ServerApiVersion;
|
|
||||||
import com.mongodb.client.MongoClient;
|
|
||||||
import com.mongodb.client.MongoClients;
|
|
||||||
import com.mongodb.client.MongoCollection;
|
|
||||||
import com.mongodb.client.MongoDatabase;
|
|
||||||
import com.mongodb.client.model.Indexes;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.data.CollectorListenerSettings;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.data.LiveDataCollectorSettings;
|
|
||||||
import org.bson.Document;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class TikTokLiveDataCollector {
|
|
||||||
|
|
||||||
private final LiveDataCollectorSettings settings;
|
|
||||||
private MongoClient mongoClient;
|
|
||||||
private MongoDatabase database;
|
|
||||||
private MongoCollection<Document> collection;
|
|
||||||
|
|
||||||
public TikTokLiveDataCollector(LiveDataCollectorSettings settings) {
|
|
||||||
this.settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void connectDatabase() {
|
|
||||||
var serverApi = ServerApi.builder()
|
|
||||||
.version(ServerApiVersion.V1)
|
|
||||||
.build();
|
|
||||||
var mongoSettings = MongoClientSettings.builder()
|
|
||||||
.applyConnectionString(new ConnectionString(settings.getConnectionUrl()))
|
|
||||||
.serverApi(serverApi)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
mongoClient = MongoClients.create(mongoSettings);
|
|
||||||
database = mongoClient.getDatabase(settings.getDatabaseName());
|
|
||||||
collection = database.getCollection("data");
|
|
||||||
collection.createIndex(Indexes.hashed("session"));
|
|
||||||
collection.createIndex(Indexes.hashed("dataType"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void disconnectDatabase() {
|
|
||||||
mongoClient.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokLiveDataCollectorListener newListener() {
|
|
||||||
return newListener(Map.of());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokLiveDataCollectorListener newListener(Map<String, Object> additionalFields) {
|
|
||||||
return newListener(additionalFields, (e)->true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokLiveDataCollectorListener newListener(Map<String, Object> additionalFields,
|
|
||||||
Function<Document, Boolean> filter) {
|
|
||||||
var settings = new CollectorListenerSettings();
|
|
||||||
settings.setExtraFields(additionalFields);
|
|
||||||
settings.setFilter(filter);
|
|
||||||
return new TikTokLiveDataCollectorListener(collection, settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
package io.github.jwdeveloper.tiktok.extension.collector.impl;
|
|
||||||
|
|
||||||
import com.mongodb.client.MongoCollection;
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.control.TikTokConnectingEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketResponseEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.LiveDataCollector;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.collector.api.data.CollectorListenerSettings;
|
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
|
||||||
import io.github.jwdeveloper.tiktok.utils.JsonUtil;
|
|
||||||
import org.bson.Document;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class TikTokLiveDataCollectorListener implements LiveDataCollector {
|
|
||||||
|
|
||||||
private final MongoCollection<Document> collection;
|
|
||||||
private final CollectorListenerSettings settings;
|
|
||||||
private String sessionId;
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
public TikTokLiveDataCollectorListener(MongoCollection<Document> collection, CollectorListenerSettings settings) {
|
|
||||||
this.collection = collection;
|
|
||||||
this.settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onResponse(LiveClient liveClient, TikTokWebsocketResponseEvent event) {
|
|
||||||
includeResponse(liveClient, event.getResponse());
|
|
||||||
event.getResponse().getMessagesList().forEach(message ->
|
|
||||||
{
|
|
||||||
includeMessage(liveClient, message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onEvent(LiveClient liveClient, TikTokEvent event) {
|
|
||||||
if (event instanceof TikTokConnectingEvent) {
|
|
||||||
sessionId = UUID.randomUUID().toString();
|
|
||||||
userName = liveClient.getRoomInfo().getHostName();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event instanceof TikTokErrorEvent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
includeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onError(LiveClient liveClient, TikTokErrorEvent event) {
|
|
||||||
event.getException().printStackTrace();
|
|
||||||
includeError(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void includeResponse(LiveClient liveClient, WebcastResponse message) {
|
|
||||||
var messageContent = Base64.getEncoder().encodeToString(message.toByteArray());
|
|
||||||
insertDocument(createDocument("response", "webcast", messageContent));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void includeMessage(LiveClient liveClient, WebcastResponse.Message message) {
|
|
||||||
var method = message.getMethod();
|
|
||||||
var messageContent = Base64.getEncoder().encodeToString(message.getPayload().toByteArray());
|
|
||||||
|
|
||||||
insertDocument(createDocument("message", method, messageContent));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void includeEvent(TikTokEvent event) {
|
|
||||||
var json = JsonUtil.toJson(event);
|
|
||||||
var content = Base64.getEncoder().encodeToString(json.getBytes());
|
|
||||||
var name = event.getClass().getSimpleName();
|
|
||||||
insertDocument(createDocument("event", name, content));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void includeError(TikTokErrorEvent event) {
|
|
||||||
var exception = event.getException();
|
|
||||||
var exceptionName = event.getException().getClass().getSimpleName();
|
|
||||||
|
|
||||||
var sw = new StringWriter();
|
|
||||||
var pw = new PrintWriter(sw);
|
|
||||||
event.getException().printStackTrace(pw);
|
|
||||||
var content = sw.toString();
|
|
||||||
|
|
||||||
var doc = createDocument("error", exceptionName, content);
|
|
||||||
if (exception instanceof TikTokLiveMessageException ex) {
|
|
||||||
doc.append("message", ex.messageToBase64())
|
|
||||||
.append("response", ex.webcastResponseToBase64());
|
|
||||||
}
|
|
||||||
insertDocument(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void insertDocument(Document document) {
|
|
||||||
if (!settings.getFilter().apply(document)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
collection.insertOne(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Document createDocument(String dataType, String dataTypeName, String content) {
|
|
||||||
var doc = new Document();
|
|
||||||
doc.append("session", sessionId);
|
|
||||||
for (var entry : settings.getExtraFields().entrySet()) {
|
|
||||||
doc.append(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
doc.append("tiktokUser", userName);
|
|
||||||
doc.append("dataType", dataType);
|
|
||||||
doc.append("dataTypeName", dataTypeName);
|
|
||||||
doc.append("content", content);
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
Records stream to flv file
|
|
||||||
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
|
||||||
<artifactId>Client</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
|
|
||||||
<artifactId>extension-recorder</artifactId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
|
|
||||||
```java
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
TikTokLive.newClient("bangbetmenygy")
|
|
||||||
.configure(liveClientSettings ->
|
|
||||||
{
|
|
||||||
liveClientSettings.setPrintToConsole(true);
|
|
||||||
})
|
|
||||||
.onError((liveClient, event) ->
|
|
||||||
{
|
|
||||||
event.getException().printStackTrace();
|
|
||||||
})
|
|
||||||
.addListener(TikTokLiveRecorder.use(recorderSettings ->
|
|
||||||
{
|
|
||||||
recorderSettings.setFfmpegPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\libs\\ffmpeg.exe");
|
|
||||||
recorderSettings.setOutputPath("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\extension-recorder\\out");
|
|
||||||
recorderSettings.setOutputFileName("test.flv");
|
|
||||||
}))
|
|
||||||
.onEvent(TikTokLiveRecorderStartedEvent.class, (liveClient, event) ->
|
|
||||||
{
|
|
||||||
System.out.println(event.getDownloadData().getFullUrl());
|
|
||||||
})
|
|
||||||
.buildAndConnect();
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<version>1.1.0-Release</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>extension-recorder</artifactId>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>Client</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
|
||||||
<artifactId>API</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>16</maven.compiler.source>
|
|
||||||
<maven.compiler.target>16</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.api.LiveRecorder;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.RecorderListener;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.RecorderSettings;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class TikTokLiveRecorder
|
|
||||||
{
|
|
||||||
|
|
||||||
public static LiveRecorder use(Consumer<RecorderSettings> consumer)
|
|
||||||
{
|
|
||||||
return new RecorderListener(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LiveRecorder use()
|
|
||||||
{
|
|
||||||
return use(x ->{});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.api;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
|
|
||||||
|
|
||||||
public interface LiveRecorder extends TikTokEventListener {
|
|
||||||
|
|
||||||
void pause();
|
|
||||||
void unpause();
|
|
||||||
}
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.*;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.http.TikTokRoomDataResponseEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.api.LiveRecorder;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.*;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveQuality;
|
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
|
||||||
|
|
||||||
public class RecorderListener implements LiveRecorder {
|
|
||||||
|
|
||||||
private final Consumer<RecorderSettings> consumer;
|
|
||||||
private RecorderSettings settings;
|
|
||||||
private DownloadData downloadData;
|
|
||||||
private Thread liveDownloadThread;
|
|
||||||
|
|
||||||
public RecorderListener(Consumer<RecorderSettings> consumer) {
|
|
||||||
this.consumer = consumer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pause() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unpause() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onResponse(LiveClient liveClient, TikTokRoomDataResponseEvent event) {
|
|
||||||
settings = RecorderSettings.DEFAULT();
|
|
||||||
consumer.accept(settings);
|
|
||||||
|
|
||||||
var json = event.getLiveData().getJson();
|
|
||||||
|
|
||||||
liveClient.getLogger().info("Searching for live download url");
|
|
||||||
if (settings.getPrepareDownloadData() != null) {
|
|
||||||
downloadData = settings.getPrepareDownloadData().apply(json);
|
|
||||||
} else {
|
|
||||||
downloadData = mapToDownloadData(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (downloadData.getDownloadLiveUrl().isEmpty()) {
|
|
||||||
throw new TikTokLiveException("Unable to find download live url!");
|
|
||||||
}
|
|
||||||
liveClient.getLogger().info("Live download url found!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onConnected(LiveClient liveClient, TikTokConnectedEvent event) {
|
|
||||||
liveDownloadThread = new Thread(() -> {
|
|
||||||
try {
|
|
||||||
var bufferSize = 1024;
|
|
||||||
var url = new URL(downloadData.getFullUrl());
|
|
||||||
HttpsURLConnection socksConnection = (HttpsURLConnection) url.openConnection();
|
|
||||||
var headers = LiveClientSettings.DefaultRequestHeaders();
|
|
||||||
for (var entry : headers.entrySet()) {
|
|
||||||
socksConnection.setRequestProperty(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
var in = new BufferedInputStream(socksConnection.getInputStream());
|
|
||||||
var path = settings.getOutputPath() + File.separator + settings.getOutputFileName();
|
|
||||||
var file = new File(path);
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
var fileOutputStream = new FileOutputStream(file);
|
|
||||||
byte[] dataBuffer = new byte[bufferSize];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = in.read(dataBuffer, 0, bufferSize)) != -1) {
|
|
||||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
liveDownloadThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void downloadUsingStream(String urlStr, String file) throws IOException {
|
|
||||||
URL url = new URL(urlStr);
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(url.openStream());
|
|
||||||
FileOutputStream fis = new FileOutputStream(file);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int count;
|
|
||||||
while ((count = bis.read(buffer, 0, 1024)) != -1)
|
|
||||||
fis.write(buffer, 0, count);
|
|
||||||
fis.close();
|
|
||||||
bis.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onDisconnected(LiveClient liveClient, TikTokDisconnectedEvent event) {
|
|
||||||
if (isConnected())
|
|
||||||
liveDownloadThread.interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@TikTokEventObserver
|
|
||||||
private void onDisconnected(LiveClient liveClient, TikTokLiveEndedEvent event) {
|
|
||||||
if (isConnected())
|
|
||||||
liveDownloadThread.interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int terminateFfmpeg(final Process process) {
|
|
||||||
if (!process.isAlive()) {
|
|
||||||
// ffmpeg -version, do nothing
|
|
||||||
return process.exitValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ffmpeg -f x11grab
|
|
||||||
System.out.println("About to destroy the child process...");
|
|
||||||
try (final OutputStreamWriter out = new OutputStreamWriter(process.getOutputStream(), UTF_8)) {
|
|
||||||
out.write('q');
|
|
||||||
} catch (final IOException ioe) {
|
|
||||||
ioe.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!process.waitFor(5L, TimeUnit.SECONDS)) {
|
|
||||||
process.destroy();
|
|
||||||
process.waitFor();
|
|
||||||
}
|
|
||||||
return process.exitValue();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
System.out.println("Interrupted");
|
|
||||||
ie.printStackTrace();
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DownloadData mapToDownloadData(String json) {
|
|
||||||
|
|
||||||
var parsedJson = JsonParser.parseString(json);
|
|
||||||
var jsonObject = parsedJson.getAsJsonObject();
|
|
||||||
var streamDataJson = jsonObject.getAsJsonObject("data")
|
|
||||||
.getAsJsonObject("stream_url")
|
|
||||||
.getAsJsonObject("live_core_sdk_data")
|
|
||||||
.getAsJsonObject("pull_data")
|
|
||||||
.get("stream_data")
|
|
||||||
.getAsString();
|
|
||||||
|
|
||||||
var streamDataJsonObject = JsonParser.parseString(streamDataJson).getAsJsonObject();
|
|
||||||
|
|
||||||
var urlLink = streamDataJsonObject.getAsJsonObject("data")
|
|
||||||
.getAsJsonObject(LiveQuality.origin.name())
|
|
||||||
.getAsJsonObject("main")
|
|
||||||
.get("flv")
|
|
||||||
.getAsString();
|
|
||||||
|
|
||||||
var sessionId = streamDataJsonObject.getAsJsonObject("common")
|
|
||||||
.get("session_id")
|
|
||||||
.getAsString();
|
|
||||||
|
|
||||||
//main
|
|
||||||
//https://pull-f5-tt03.fcdn.eu.tiktokcdn.com/stage/stream-3284937501738533765.flv?session_id=136-20240109000954BF818F1B3A8E5E39E238&_webnoredir=1
|
|
||||||
//Working
|
|
||||||
//https://pull-f5-tt03.fcdn.eu.tiktokcdn.com/game/stream-3284937501738533765_sd5.flv?_session_id=136-20240109001052D91FDBC00143211020C8.1704759052997&_webnoredir=1
|
|
||||||
//https://pull-f5-tt02.fcdn.eu.tiktokcdn.com/stage/stream-3861399216374940610_uhd5.flv?_session_id=136-20240109000223D0BAA1A83974490EE630.1704758544391&_webnoredir=1
|
|
||||||
|
|
||||||
return new DownloadData(urlLink, sessionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isConnected() {
|
|
||||||
return liveDownloadThread != null && liveDownloadThread.isAlive();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl.data;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DownloadData {
|
|
||||||
|
|
||||||
private String downloadLiveUrl;
|
|
||||||
|
|
||||||
private String sessionId;
|
|
||||||
|
|
||||||
public String getFullUrl() {
|
|
||||||
return downloadLiveUrl + "&_webnoredir=1&session_id=" + sessionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl.data;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveQuality;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveFormat;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class RecorderSettings {
|
|
||||||
private String ffmpegPath;
|
|
||||||
private String quality;
|
|
||||||
private String format;
|
|
||||||
private String outputPath;
|
|
||||||
private String outputFileName;
|
|
||||||
private Function<String,DownloadData> prepareDownloadData;
|
|
||||||
private boolean startOnConnected;
|
|
||||||
|
|
||||||
public static RecorderSettings DEFAULT() {
|
|
||||||
return new RecorderSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuality(LiveQuality quality) {
|
|
||||||
this.quality = quality.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFormat(LiveFormat format) {
|
|
||||||
this.format = format.name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl.enums;
|
|
||||||
|
|
||||||
public enum LiveFormat
|
|
||||||
{
|
|
||||||
MP4
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl.enums;
|
|
||||||
|
|
||||||
public enum LiveQuality {
|
|
||||||
origin, hd_60, ao, hd, sd, ld,uhd_60
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package io.github.jwdeveloper.tiktok.extension.recorder.impl.event;
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.DownloadData;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class TikTokLiveRecorderStartedEvent extends TikTokEvent
|
|
||||||
{
|
|
||||||
DownloadData downloadData;
|
|
||||||
}
|
|
||||||
5
pom.xml
5
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.1.0-Release</version>
|
<version>1.0.16-Release</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>API</module>
|
<module>API</module>
|
||||||
<module>Client</module>
|
<module>Client</module>
|
||||||
@@ -16,9 +16,6 @@
|
|||||||
<module>Tools-EventsCollector</module>
|
<module>Tools-EventsCollector</module>
|
||||||
<module>Tools-ReadmeGenerator</module>
|
<module>Tools-ReadmeGenerator</module>
|
||||||
<module>Tools-EventsWebViewer</module>
|
<module>Tools-EventsWebViewer</module>
|
||||||
|
|
||||||
<module>extension-recorder</module>
|
|
||||||
<module>extension-collector</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
Reference in New Issue
Block a user