mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Compare commits
5 Commits
1.5.2-Rele
...
develop-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
103ed7e3ed | ||
|
|
67e70c34bc | ||
|
|
786c24d267 | ||
|
|
966d2f65d8 | ||
|
|
7ba7143f5a |
@@ -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.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</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.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
tikTokEventHandler.publish(tikTokLiveClient, new TikTokErrorEvent(e));
|
tikTokEventHandler.publish(tikTokLiveClient, new TikTokErrorEvent(e));
|
||||||
}
|
}
|
||||||
if (isNotClosing()) {
|
if (isOpen()) {
|
||||||
sendPing();
|
sendPing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,8 +79,7 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
pushFrameBuilder.setPayloadType("ack");
|
pushFrameBuilder.setPayloadType("ack");
|
||||||
pushFrameBuilder.setLogId(websocketPushFrame.getLogId());
|
pushFrameBuilder.setLogId(websocketPushFrame.getLogId());
|
||||||
pushFrameBuilder.setPayload(webcastResponse.getInternalExtBytes());
|
pushFrameBuilder.setPayload(webcastResponse.getInternalExtBytes());
|
||||||
if (isNotClosing())
|
if (isOpen()) {
|
||||||
{
|
|
||||||
this.send(pushFrameBuilder.build().toByteArray());
|
this.send(pushFrameBuilder.build().toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +89,7 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onOpen(ServerHandshake serverHandshake) {
|
public void onOpen(ServerHandshake serverHandshake) {
|
||||||
tikTokEventHandler.publish(tikTokLiveClient, new TikTokConnectedEvent());
|
tikTokEventHandler.publish(tikTokLiveClient, new TikTokConnectedEvent());
|
||||||
if (isNotClosing()) {
|
if (isOpen()) {
|
||||||
sendPing();
|
sendPing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +103,7 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
tikTokEventHandler.publish(tikTokLiveClient, new TikTokErrorEvent(error));
|
tikTokEventHandler.publish(tikTokLiveClient, new TikTokErrorEvent(error));
|
||||||
if (isNotClosing()) {
|
if (isOpen()) {
|
||||||
sendPing();
|
sendPing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,10 +128,6 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNotClosing() {
|
|
||||||
return !isClosed() && !isClosing();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(String s) {
|
public void onMessage(String s) {
|
||||||
// System.err.println(s);
|
// System.err.println(s);
|
||||||
|
|||||||
@@ -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.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>extension-collector</artifactId>
|
<artifactId>extension-collector</artifactId>
|
||||||
<version>1.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -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.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<version>1.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>API</artifactId>
|
<artifactId>API</artifactId>
|
||||||
<version>1.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -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.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>extension-recorder</artifactId>
|
<artifactId>extension-recorder</artifactId>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
|||||||
import io.github.jwdeveloper.tiktok.extension.recorder.api.LiveRecorder;
|
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.data.*;
|
||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveQuality;
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.enums.LiveQuality;
|
||||||
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.event.TikTokLiveRecorderStartedEvent;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
||||||
|
|
||||||
@@ -60,7 +61,9 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
var json = event.getLiveData().getJson();
|
var json = event.getLiveData().getJson();
|
||||||
|
|
||||||
liveClient.getLogger().info("Searching for live download url");
|
liveClient.getLogger().info("Searching for live download url");
|
||||||
downloadData = settings.getPrepareDownloadData() != null ? settings.getPrepareDownloadData().apply(json) : mapToDownloadData(json);
|
downloadData = settings.getPrepareDownloadData() != null ?
|
||||||
|
settings.getPrepareDownloadData().apply(json) :
|
||||||
|
mapToDownloadData(json);
|
||||||
|
|
||||||
if (downloadData.getDownloadLiveUrl().isEmpty())
|
if (downloadData.getDownloadLiveUrl().isEmpty())
|
||||||
liveClient.getLogger().warning("Unable to find download live url!");
|
liveClient.getLogger().warning("Unable to find download live url!");
|
||||||
@@ -72,8 +75,11 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
private void onConnected(LiveClient liveClient, TikTokConnectedEvent event) {
|
private void onConnected(LiveClient liveClient, TikTokConnectedEvent event) {
|
||||||
if (isConnected())
|
if (isConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
liveDownloadThread = new Thread(() -> {
|
liveDownloadThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
liveClient.getLogger().info("Recording started");
|
||||||
var url = new URL(downloadData.getFullUrl());
|
var url = new URL(downloadData.getFullUrl());
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
var headers = LiveClientSettings.DefaultRequestHeaders();
|
var headers = LiveClientSettings.DefaultRequestHeaders();
|
||||||
@@ -98,13 +104,19 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
liveClient.getLogger().severe("Stopped recording "+liveClient.getRoomInfo().getHostName());
|
liveClient.getLogger().severe("Stopped recording " + liveClient.getRoomInfo().getHostName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var recordingStartedEvent = new TikTokLiveRecorderStartedEvent(downloadData);
|
||||||
|
liveClient.publishEvent(recordingStartedEvent);
|
||||||
|
if (recordingStartedEvent.isCanceled()) {
|
||||||
|
liveClient.getLogger().info("Recording cancelled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
liveDownloadThread.start();
|
liveDownloadThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,32 +132,6 @@ public class RecorderListener implements LiveRecorder {
|
|||||||
liveDownloadThread.interrupt();
|
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) {
|
private DownloadData mapToDownloadData(String json) {
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,18 @@ import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.DownloadData;
|
import io.github.jwdeveloper.tiktok.extension.recorder.impl.data.DownloadData;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Data
|
@Getter
|
||||||
public class TikTokLiveRecorderStartedEvent extends TikTokEvent
|
public class TikTokLiveRecorderStartedEvent extends TikTokEvent {
|
||||||
{
|
|
||||||
DownloadData downloadData;
|
DownloadData downloadData;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
boolean canceled;
|
||||||
|
|
||||||
|
public TikTokLiveRecorderStartedEvent(DownloadData downloadData) {
|
||||||
|
this.downloadData = downloadData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
|||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>TikTokLiveJava</artifactId>
|
<artifactId>TikTokLiveJava</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.5.1-Release</version>
|
<version>1.5.3-Release</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>API</module>
|
<module>API</module>
|
||||||
<module>Client</module>
|
<module>Client</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user