mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Added convenience methods back to TikTokLive and changed sing to sign where misspelled!
This commit is contained in:
@@ -23,9 +23,12 @@
|
|||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.data.requests.LiveUserData;
|
||||||
import io.github.jwdeveloper.tiktok.http.LiveHttpClient;
|
import io.github.jwdeveloper.tiktok.http.LiveHttpClient;
|
||||||
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
|
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class TikTokLive {
|
public class TikTokLive {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,6 +40,52 @@ public class TikTokLive {
|
|||||||
return new TikTokLiveClientBuilder(hostName);
|
return new TikTokLiveClientBuilder(hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param hostName profile name of Tiktok user could be found in profile link
|
||||||
|
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
|
||||||
|
* @return true if live is Online, false if is offline
|
||||||
|
*/
|
||||||
|
public static boolean isLiveOnline(String hostName)
|
||||||
|
{
|
||||||
|
LiveUserData.UserStatus status = requests().fetchLiveUserData(hostName).getUserStatus();
|
||||||
|
return status == LiveUserData.UserStatus.Live || status == LiveUserData.UserStatus.LivePaused;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param hostName profile name of Tiktok user could be found in profile link
|
||||||
|
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
|
||||||
|
* @return true if live is Online, false if is offline
|
||||||
|
*/
|
||||||
|
public static CompletableFuture<Boolean> isLiveOnlineAsync(String hostName)
|
||||||
|
{
|
||||||
|
return CompletableFuture.supplyAsync(()-> isLiveOnline(hostName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param hostName profile name of Tiktok user could be found in profile link
|
||||||
|
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
|
||||||
|
* @return true is hostName name is valid and exists, false if not
|
||||||
|
*/
|
||||||
|
public static boolean isHostNameValid(String hostName)
|
||||||
|
{
|
||||||
|
LiveUserData.UserStatus status = requests().fetchLiveUserData(hostName).getUserStatus();
|
||||||
|
return status != LiveUserData.UserStatus.NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param hostName profile name of Tiktok user could be found in profile link
|
||||||
|
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
|
||||||
|
* @return true is hostName name is valid and exists, false if not
|
||||||
|
*/
|
||||||
|
public static CompletableFuture<Boolean> isHostNameValidAsync(String hostName)
|
||||||
|
{
|
||||||
|
return CompletableFuture.supplyAsync(()-> isHostNameValid(hostName));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use to get some data from TikTok about users are lives
|
* Use to get some data from TikTok about users are lives
|
||||||
@@ -44,9 +93,6 @@ public class TikTokLive {
|
|||||||
* @return LiveHttpClient
|
* @return LiveHttpClient
|
||||||
*/
|
*/
|
||||||
public static LiveHttpClient requests() {
|
public static LiveHttpClient requests() {
|
||||||
|
|
||||||
|
|
||||||
return new TikTokLiveHttpClient();
|
return new TikTokLiveHttpClient();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -50,14 +50,14 @@ public class TikTokLiveHttpClient implements LiveHttpClient {
|
|||||||
private final HttpClientFactory httpFactory;
|
private final HttpClientFactory httpFactory;
|
||||||
private final LiveUserDataMapper liveUserDataMapper;
|
private final LiveUserDataMapper liveUserDataMapper;
|
||||||
private final LiveDataMapper liveDataMapper;
|
private final LiveDataMapper liveDataMapper;
|
||||||
private final SignServerResponseMapper singServerResponseMapper;
|
private final SignServerResponseMapper signServerResponseMapper;
|
||||||
private final GiftsDataMapper giftsDataMapper;
|
private final GiftsDataMapper giftsDataMapper;
|
||||||
|
|
||||||
public TikTokLiveHttpClient(HttpClientFactory factory) {
|
public TikTokLiveHttpClient(HttpClientFactory factory) {
|
||||||
this.httpFactory = factory;
|
this.httpFactory = factory;
|
||||||
liveUserDataMapper = new LiveUserDataMapper();
|
liveUserDataMapper = new LiveUserDataMapper();
|
||||||
liveDataMapper = new LiveDataMapper();
|
liveDataMapper = new LiveDataMapper();
|
||||||
singServerResponseMapper = new SignServerResponseMapper();
|
signServerResponseMapper = new SignServerResponseMapper();
|
||||||
giftsDataMapper = new GiftsDataMapper();
|
giftsDataMapper = new GiftsDataMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ public class TikTokLiveHttpClient implements LiveHttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var json = optional.get();
|
var json = optional.get();
|
||||||
return singServerResponseMapper.map(json);
|
return signServerResponseMapper.map(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponse<byte[]> getWebsocketCredentialsResponse(String signedUrl) {
|
HttpResponse<byte[]> getWebsocketCredentialsResponse(String signedUrl) {
|
||||||
@@ -194,4 +194,4 @@ public class TikTokLiveHttpClient implements LiveHttpClient {
|
|||||||
return optionalResponse.get();
|
return optionalResponse.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user