mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Initial commit
This commit is contained in:
28
API/pom.xml
Normal file
28
API/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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>org.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>API</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</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>
|
||||
@@ -0,0 +1,71 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Data
|
||||
public class ClientSettings {
|
||||
/// <summary>
|
||||
/// Timeout for Connections
|
||||
/// </summary>
|
||||
|
||||
private Duration Timeout;
|
||||
/// <summary>
|
||||
/// Polling-Interval for Socket-Connection
|
||||
/// </summary
|
||||
|
||||
private Duration PollingInterval;
|
||||
/// <summary>
|
||||
/// Proxy for Connection
|
||||
/// </summary>
|
||||
|
||||
// public RotatingProxy Proxy;
|
||||
/// <summary>
|
||||
/// ISO-Language for Client
|
||||
/// </summary>
|
||||
|
||||
private String ClientLanguage;
|
||||
/// <summary>
|
||||
/// Size for Buffer for Socket-Connection
|
||||
/// </summary>
|
||||
|
||||
private int SocketBufferSize;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to Retry if Connection Fails
|
||||
/// </summary>
|
||||
private boolean RetryOnConnectionFailure;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Whether to handle Messages received from Room when Connecting
|
||||
/// </summary>
|
||||
private boolean HandleExistingMessagesOnConnect;
|
||||
/// <summary>
|
||||
/// Whether to download List of Gifts for Room when Connecting
|
||||
/// </summary>
|
||||
private boolean DownloadGiftInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to print Logs to Console
|
||||
/// </summary>
|
||||
|
||||
private boolean PrintToConsole;
|
||||
/// <summary>
|
||||
/// LoggingLevel for Logs
|
||||
/// </summary>
|
||||
private Level LogLevel;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to print Base64-Data for Messages to Console
|
||||
/// </summary>
|
||||
private boolean PrintMessageData;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to check Messages for Unparsed Data
|
||||
/// </summary>
|
||||
private boolean CheckForUnparsedData;
|
||||
}
|
||||
|
||||
121
API/src/main/java/io/github/jwdeveloper/tiktok/Constants.java
Normal file
121
API/src/main/java/io/github/jwdeveloper/tiktok/Constants.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Constants {
|
||||
|
||||
/// <summary>
|
||||
/// Web-URL for TikTok
|
||||
/// </summary>
|
||||
public static final String TIKTOK_URL_WEB = "https://www.tiktok.com/";
|
||||
/// <summary>
|
||||
/// WebCast-BaseURL for TikTok
|
||||
/// </summary>
|
||||
public static final String TIKTOK_URL_WEBCAST = "https://webcast.tiktok.com/webcast/";
|
||||
/// <summary>
|
||||
/// Signing API by Isaac Kogan
|
||||
/// https://github-wiki-see.page/m/isaackogan/TikTokLive/wiki/All-About-Signatures
|
||||
/// </summary>
|
||||
public static final String TIKTOK_SIGN_API = "https://tiktok.eulerstream.com/webcast/sign_url";
|
||||
|
||||
/// <summary>
|
||||
/// Default TimeOut for Connections
|
||||
/// </summary>
|
||||
public static final int DEFAULT_TIMEOUT = 20;
|
||||
/// <summary>
|
||||
/// Default Polling-Time for Socket-Connection
|
||||
/// </summary>
|
||||
public static final int DEFAULT_POLLTIME = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Default Settings for Client
|
||||
/// </summary>
|
||||
|
||||
|
||||
|
||||
public static ClientSettings DefaultClientSettings() {
|
||||
var clientSettings = new ClientSettings();
|
||||
|
||||
clientSettings.setTimeout(Duration.ofSeconds(DEFAULT_TIMEOUT));
|
||||
clientSettings.setPollingInterval(Duration.ofSeconds(DEFAULT_POLLTIME));
|
||||
clientSettings.setClientLanguage("en-US");
|
||||
clientSettings.setHandleExistingMessagesOnConnect(true);
|
||||
clientSettings.setDownloadGiftInfo(true);
|
||||
clientSettings.setRetryOnConnectionFailure(true);
|
||||
clientSettings.setSocketBufferSize(500_000);
|
||||
clientSettings.setPrintToConsole(true);
|
||||
clientSettings.setLogLevel(Level.ALL);
|
||||
clientSettings.setCheckForUnparsedData(false);
|
||||
clientSettings.setPrintMessageData(false);
|
||||
return clientSettings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default Parameters for HTTP-Request
|
||||
/// </summary>
|
||||
|
||||
|
||||
public static Map<String,Object> DefaultClientParams() {
|
||||
var clientParams = new TreeMap<String,Object>();
|
||||
clientParams.put("aid", 1988);
|
||||
clientParams.put("app_language", "en-US");
|
||||
clientParams.put("app_name", "tiktok_web");
|
||||
clientParams.put("browser_language", "en");
|
||||
clientParams.put("browser_name", "Mozilla");
|
||||
clientParams.put("browser_online", true);
|
||||
clientParams.put("browser_platform", "Win32");
|
||||
clientParams.put("browser_version", "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36");
|
||||
clientParams.put("cookie_enabled", true);
|
||||
clientParams.put("cursor", "");
|
||||
clientParams.put("internal_ext", "");
|
||||
clientParams.put("device_platform", "web");
|
||||
clientParams.put("focus_state", true);
|
||||
clientParams.put("from_page", "user");
|
||||
clientParams.put("history_len", 4);
|
||||
clientParams.put("is_fullscreen", false);
|
||||
clientParams.put("is_page_visible", true);
|
||||
clientParams.put("did_rule", 3);
|
||||
clientParams.put("fetch_rule", 1);
|
||||
clientParams.put("identity", "audience");
|
||||
clientParams.put("last_rtt", 0);
|
||||
clientParams.put("live_id", 12);
|
||||
clientParams.put("resp_content_type", "protobuf");
|
||||
clientParams.put("screen_height", 1152);
|
||||
clientParams.put("screen_width", 2048);
|
||||
clientParams.put("tz_name", "Europe/Berlin");
|
||||
clientParams.put("referer", "https, //www.tiktok.com/");
|
||||
clientParams.put("root_referer", "https, //www.tiktok.com/");
|
||||
clientParams.put("msToken", "");
|
||||
clientParams.put("version_code", 180800);
|
||||
clientParams.put("webcast_sdk_version", "1.3.0");
|
||||
clientParams.put("update_version_code", "1.3.0");
|
||||
|
||||
|
||||
return clientParams;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default Headers for HTTP-Request
|
||||
/// </summary>
|
||||
public static Map<String,String> DefaultRequestHeaders() {
|
||||
var headers = new HashMap<String,String>();
|
||||
|
||||
// headers.put("Connection", "keep-alive");
|
||||
headers.put("Cache-Control", "max-age=0");
|
||||
headers.put("Accept", "text/html,application/json,application/protobuf");
|
||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36");
|
||||
headers.put("Referer", "https://www.tiktok.com/");
|
||||
headers.put("Origin", "https://www.tiktok.com");
|
||||
headers.put("Accept-Language", "en-US,en; q=0.9");
|
||||
// headers.put("Accept-Encoding", "gzip, deflate");
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.github.jwdeveloper.tiktok.http.Resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ClientFetchDataResponse {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.github.jwdeveloper.tiktok.http;
|
||||
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TikTokHttpRequest {
|
||||
TikTokHttpRequest SetQueries(Map<String, Object> queries);
|
||||
|
||||
TikTokHttpRequest setHeader(String key, String value);
|
||||
String Get(String url);
|
||||
|
||||
String Post(String url, HttpRequest.BodyPublisher data);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
public enum ConnectionState
|
||||
{
|
||||
CONNECTING,CONNECTED,DISCONNECTED
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
public interface LiveClient {
|
||||
void run();
|
||||
|
||||
void stop();
|
||||
|
||||
LiveMeta getMeta();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
public interface LiveMeta
|
||||
{
|
||||
int getViewersCount();
|
||||
|
||||
String getRoomId();
|
||||
String getUserName();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LiveRoomInfo
|
||||
{
|
||||
private int status;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TikTokLiveMeta implements LiveMeta
|
||||
{
|
||||
private int viewersCount;
|
||||
|
||||
private String roomId;
|
||||
|
||||
private String userName;
|
||||
private ConnectionState connectionState = ConnectionState.DISCONNECTED;
|
||||
|
||||
public boolean hasConnectionState(ConnectionState state)
|
||||
{
|
||||
return connectionState == state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DefaultFormat
|
||||
{
|
||||
private boolean bold ;
|
||||
private String color ;
|
||||
private int font_size ;
|
||||
private boolean italic ;
|
||||
private int italic_angle ;
|
||||
private boolean use_highlight_color ;
|
||||
private boolean use_remote_color ;
|
||||
private int weight ;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DisplayText
|
||||
{
|
||||
private DefaultFormat default_format ;
|
||||
private String default_pattern ;
|
||||
private String key ;
|
||||
private List<Object> pieces ;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GiftLabelIcon
|
||||
{
|
||||
private String avg_color ;
|
||||
private int height ;
|
||||
private int image_type ;
|
||||
private boolean is_animated ;
|
||||
private String open_web_url ;
|
||||
private String uri ;
|
||||
private List<String> url_list ;
|
||||
private int width ;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class GiftPanelBanner
|
||||
{
|
||||
private List<Object> bg_color_values ;
|
||||
private DisplayText display_text ;
|
||||
private LeftIcon left_icon ;
|
||||
private String schema_url ;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class Icon {
|
||||
private String avg_color;
|
||||
private int height;
|
||||
private int image_type;
|
||||
private boolean is_animated;
|
||||
private String open_web_url;
|
||||
private String uri;
|
||||
private List<String> url_list;
|
||||
private int width;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Image
|
||||
{
|
||||
private String avg_color ;
|
||||
private int height ;
|
||||
private int image_type ;
|
||||
private boolean is_animated ;
|
||||
private String open_web_url ;
|
||||
private String uri ;
|
||||
private List<String> url_list ;
|
||||
private int width ;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LeftIcon
|
||||
{
|
||||
private String avg_color ;
|
||||
private int height ;
|
||||
private int image_type ;
|
||||
private boolean is_animated ;
|
||||
private String open_web_url ;
|
||||
private String uri ;
|
||||
private List<String> url_list ;
|
||||
private int width ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
public class LockInfo
|
||||
{
|
||||
public int lock_type;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
public class SpecialEffects {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TikTokGift
|
||||
{
|
||||
private int action_type;
|
||||
private int app_id;
|
||||
private String business_text;
|
||||
private boolean can_put_in_gift_box;
|
||||
private List<Object> color_infos;
|
||||
private boolean combo;
|
||||
private String describe;
|
||||
private int diamond_count;
|
||||
private int duration;
|
||||
private String event_name;
|
||||
private boolean for_custom;
|
||||
private boolean for_linkmic;
|
||||
private GiftLabelIcon gift_label_icon;
|
||||
private GiftPanelBanner gift_panel_banner;
|
||||
private String gift_rank_recommend_info;
|
||||
private int gift_scene;
|
||||
private String gold_effect;
|
||||
private String gray_scheme_url;
|
||||
private String guide_url;
|
||||
private Icon icon;
|
||||
private int id;
|
||||
private Image image;
|
||||
private boolean is_box_gift;
|
||||
private boolean is_broadcast_gift;
|
||||
private boolean is_displayed_on_panel;
|
||||
private boolean is_effect_befview;
|
||||
private boolean is_gray;
|
||||
private boolean is_random_gift;
|
||||
private int item_type;
|
||||
private LockInfo lock_info;
|
||||
private String manual;
|
||||
private String name;
|
||||
private boolean notify;
|
||||
private int primary_effect_id;
|
||||
private String region;
|
||||
private String scheme_url;
|
||||
private SpecialEffects special_effects;
|
||||
private TrackerParams tracker_params;
|
||||
private List<Object> trigger_words;
|
||||
private int type;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.github.jwdeveloper.tiktok.live.models.gift;
|
||||
|
||||
public class TrackerParams {
|
||||
}
|
||||
Reference in New Issue
Block a user