Compare commits
No commits in common. "590c54b7774f83a3e855ad20c8ce0cadcc2d65bf" and "9521e9d5c85c413e3c4920ef096c10189ec9d064" have entirely different histories.
590c54b777
...
9521e9d5c8
32
biliapi/pom.xml
Normal file
32
biliapi/pom.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?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>com.yutou</groupId>
|
||||
<artifactId>bilibili</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>biliapi</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava3</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>3.1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aayushatharva.brotli4j</groupId>
|
||||
<artifactId>brotli4j</artifactId>
|
||||
<version>1.16.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
192
biliapi/src/main/java/com/yutou/Main.java
Normal file
192
biliapi/src/main/java/com/yutou/Main.java
Normal file
@ -0,0 +1,192 @@
|
||||
package com.yutou;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.bili.api.LiveApi;
|
||||
import com.yutou.bili.api.UserApi;
|
||||
import com.yutou.bili.bean.live.LiveRoomConfig;
|
||||
import com.yutou.bili.bean.live.LiveRoomPlayInfo;
|
||||
import com.yutou.bili.bean.live.SpiBean;
|
||||
import com.yutou.bili.bean.login.LoginCookie;
|
||||
import com.yutou.bili.bean.login.UserInfoBean;
|
||||
import com.yutou.bili.enums.LiveProtocol;
|
||||
import com.yutou.bili.enums.LiveVideoCodec;
|
||||
import com.yutou.bili.enums.LiveVideoDefinition;
|
||||
import com.yutou.bili.enums.LiveVideoFormat;
|
||||
import com.yutou.bili.net.BiliLiveNetApiManager;
|
||||
import com.yutou.bili.net.BiliLoginNetApiManager;
|
||||
import com.yutou.bili.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.bili.net.BiliUserNetApiManager;
|
||||
import com.yutou.bili.net.WebSocketManager;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import com.yutou.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.utils.Log;
|
||||
import jakarta.xml.bind.DatatypeConverter;
|
||||
import okhttp3.Headers;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
HttpLoggingInterceptor.setLog(false);
|
||||
HttpLoggingInterceptor.setLog(true);
|
||||
// getPlayUrl();
|
||||
LiveRoomConfig config=new LiveRoomConfig();
|
||||
LoginCookie cookie = BiliBiliLoginDatabase.getInstance().get();
|
||||
config.setLogin(true);
|
||||
config.setUid(cookie.getDedeUserID());
|
||||
config.setRoomId(String.valueOf(855204));
|
||||
config.setRoomId(String.valueOf(22642754));
|
||||
config.setRoomId(String.valueOf(81004));
|
||||
WebSocketManager.getInstance().addRoom(config);
|
||||
}
|
||||
|
||||
|
||||
public static void testSocket(SpiBean spi) {
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
// json.put("roomid", "32805602");
|
||||
json.put("roomid", "855204");
|
||||
json.put("protover", "3");
|
||||
json.put("platform", "web");
|
||||
json.put("type", 2);
|
||||
json.put("buvid",spi.getB_3());
|
||||
json.put("key", "aaaabbb");
|
||||
Log.i(json);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
// outputStream.write(toLH(json.toString().length() + 16));
|
||||
outputStream.write(new byte[]{0, 0, 1, 68, 0, 16, 0, 1, 0, 0, 0, 7, 0, 0, 0, 1});
|
||||
outputStream.write(json.toJSONString().getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
System.out.println("\n\n\n");
|
||||
String str = DatatypeConverter.printHexBinary(outputStream.toByteArray());
|
||||
for (int i = 0; i < str.length(); i = i + 4) {
|
||||
if (i % 32 == 0 && i != 0) {
|
||||
System.out.println();
|
||||
}
|
||||
if (str.length() - i > 4) {
|
||||
System.out.print(str.substring(i, i + 4) + " ");
|
||||
} else {
|
||||
System.out.println(str.substring(i));
|
||||
}
|
||||
}
|
||||
System.out.println("\n\n\n");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void getPlayUrl() {
|
||||
BiliLiveNetApiManager
|
||||
.getInstance()
|
||||
.getApi(new IHttpApiCheckCallback<LiveApi>() {
|
||||
@Override
|
||||
public void onSuccess(LiveApi api) {
|
||||
String roomId = "32805602";
|
||||
String mid = "68057278";
|
||||
|
||||
// roomId="42062";
|
||||
|
||||
api.getLiveRoomPlayInfo(
|
||||
roomId,
|
||||
LiveProtocol.getAll(),
|
||||
LiveVideoFormat.getAll(),
|
||||
LiveVideoCodec.getAll(),
|
||||
LiveVideoDefinition.ORIGINAL.getValue()
|
||||
).enqueue(new HttpCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, LiveRoomPlayInfo response, String rawResponse) {
|
||||
LiveRoomPlayInfo.Codec codec = response.getPlayurlInfo().getPlayurl().getStream().get(0).getFormat().get(0).getCodec().get(0);
|
||||
|
||||
LiveRoomConfig config = new LiveRoomConfig();
|
||||
config.setUid("0");
|
||||
config.setRoomId(roomId);
|
||||
config.setMid(mid);
|
||||
config.setLogin(false);
|
||||
WebSocketManager.getInstance().addRoom(config);
|
||||
|
||||
/*String url = codec.getUrlInfo().get(0).getHost() + codec.getBaseUrl() + codec.getUrlInfo().get(0).getExtra();
|
||||
System.out.println("下载url = " + url);
|
||||
api.downloadLive(url).enqueue(new FileCallback<>(response) {
|
||||
@Override
|
||||
public void onStart(LiveRoomPlayInfo bean) {
|
||||
System.out.println("开始下载");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDownload(Headers headers, LiveRoomPlayInfo bean, long len, long total) {
|
||||
System.out.println("下载中:"+len+"|"+total);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(LiveRoomPlayInfo bean) {
|
||||
System.out.println("下载结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(LiveRoomPlayInfo bean, Throwable throwable) {
|
||||
System.out.println("下载失败");
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void login(String username, String password) {
|
||||
BiliLoginNetApiManager.getInstance().login(new HttpCallback<LoginCookie>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, LoginCookie response, String rawResponse) {
|
||||
System.out.println("headers = " + headers + ", code = " + code + ", status = " + status + ", response = " + response + ", rawResponse = " + rawResponse);
|
||||
if (code == BiliLoginNetApiManager.LOGIN_SUCCESS) {
|
||||
BiliBiliLoginDatabase.getInstance().initData(response).close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getUserInfo() {
|
||||
BiliUserNetApiManager.getInstance().getUserApi(new IHttpApiCheckCallback<UserApi>() {
|
||||
@Override
|
||||
public void onSuccess(UserApi api) {
|
||||
api.getUserInfo().enqueue(new HttpCallback<UserInfoBean>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, UserInfoBean response, String rawResponse) {
|
||||
System.out.println("response = " + rawResponse);
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
System.out.println("code = " + code + ", error = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package com.yutou.biliapi.api;
|
||||
package com.yutou.bili.api;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.bean.live.*;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.common.okhttp.FileBody;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.bili.bean.live.*;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.FileBody;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.*;
|
||||
|
||||
@ -31,10 +30,10 @@ public interface LiveApi {
|
||||
/**
|
||||
* 获取直播间信息
|
||||
* @param id 直播间id
|
||||
* @param protocol 直播协议 {@link com.yutou.biliapi.enums.LiveProtocol}
|
||||
* @param format 格式 {@link com.yutou.biliapi.enums.LiveVideoFormat}
|
||||
* @param codec 编码 {@link com.yutou.biliapi.enums.LiveVideoCodec}
|
||||
* @param qn 清晰度 {@link com.yutou.biliapi.enums.LiveVideoDefinition}
|
||||
* @param protocol 直播协议 {@link com.yutou.bili.enums.LiveProtocol}
|
||||
* @param format 格式 {@link com.yutou.bili.enums.LiveVideoFormat}
|
||||
* @param codec 编码 {@link com.yutou.bili.enums.LiveVideoCodec}
|
||||
* @param qn 清晰度 {@link com.yutou.bili.enums.LiveVideoDefinition}
|
||||
* @return
|
||||
*/
|
||||
@GET("/xlive/web-room/v2/index/getRoomPlayInfo")
|
||||
@ -51,12 +50,4 @@ public interface LiveApi {
|
||||
|
||||
@GET("/xlive/web-room/v1/index/getDanmuInfo")
|
||||
Call<HttpBody<LiveDanmuInfo>> getLiveRoomDanmuInfo(@Query("id")String id);
|
||||
|
||||
@GET("/xlive/web-room/v1/giftPanel/giftConfig?platform=pc")
|
||||
Call<HttpBody<BaseBean>> getLiveGiftConfig();
|
||||
|
||||
@POST("/room/v1/Room/get_status_info_by_uids")
|
||||
Call<HttpBody<BaseBean>> getLiveRoomStatus( @Body
|
||||
JSONObject uids);
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.yutou.biliapi.api;
|
||||
package com.yutou.bili.api;
|
||||
|
||||
import com.yutou.biliapi.bean.login.CheckCookieBean;
|
||||
import com.yutou.biliapi.bean.login.LoginInfoBean;
|
||||
import com.yutou.biliapi.bean.login.QRCodeGenerateBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.bili.bean.login.CheckCookieBean;
|
||||
import com.yutou.bili.bean.login.LoginInfoBean;
|
||||
import com.yutou.bili.bean.login.QRCodeGenerateBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
@ -1,8 +1,8 @@
|
||||
package com.yutou.biliapi.api;
|
||||
package com.yutou.bili.api;
|
||||
|
||||
import com.yutou.biliapi.bean.live.SpiBean;
|
||||
import com.yutou.biliapi.bean.login.UserInfoBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.bili.bean.live.SpiBean;
|
||||
import com.yutou.bili.bean.login.UserInfoBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
@ -0,0 +1,13 @@
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LiveRoomConfig {
|
||||
String uid;
|
||||
String roomId;
|
||||
String mid;//真实房间id
|
||||
boolean isLogin;
|
||||
LiveDanmuInfo liveInfo;
|
||||
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LiveRoomInfo {
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private int uid;
|
||||
|
||||
@JSONField(name = "room_id")
|
||||
private BigInteger roomId;
|
||||
private int roomId;
|
||||
|
||||
@JSONField(name = "short_id")
|
||||
private int shortId;
|
@ -1,24 +1,23 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class LiveRoomPlayInfo extends BaseBean {
|
||||
@JSONField(name = "room_id")
|
||||
private BigInteger roomId;
|
||||
private int roomId;
|
||||
|
||||
@JSONField(name = "short_id")
|
||||
private int shortId;
|
||||
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private int uid;
|
||||
|
||||
@JSONField(name = "is_hidden")
|
||||
private boolean isHidden;
|
@ -1,10 +1,8 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Data
|
||||
public class LiveRoomStatus {
|
||||
@JSONField(name = "roomStatus")
|
||||
@ -29,7 +27,7 @@ public class LiveRoomStatus {
|
||||
private int online;
|
||||
|
||||
@JSONField(name = "roomid")
|
||||
private BigInteger roomid;
|
||||
private int roomid;
|
||||
|
||||
@JSONField(name = "broadcast_type")
|
||||
private int broadcastType;
|
@ -1,11 +1,10 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -41,7 +40,7 @@ public class MasterInfoBean extends BaseBean {
|
||||
@Data
|
||||
public static class Info {
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private int uid;
|
||||
|
||||
@JSONField(name = "uname")
|
||||
private String uname;
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.biliapi.bean.live;
|
||||
package com.yutou.bili.bean.live;
|
||||
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.bili.bean.login;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.bili.bean.login;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yutou.databases.AbsDatabasesBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class LoginCookieDatabaseBean extends AbsDatabasesBean {
|
||||
|
||||
public class LoginCookie extends AbsDatabasesBean {
|
||||
@JSONField(name = "SESSDATA")
|
||||
String sessdta;
|
||||
@JSONField(name = "Path")
|
||||
@ -28,11 +28,7 @@ public class LoginCookieDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "gourl")
|
||||
String gourl;
|
||||
|
||||
public LoginCookieDatabaseBean() {
|
||||
super("login_cookie", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String toCookieString() {
|
||||
return "SESSDATA=" + sessdta + "; Path=" + path + "; DedeUserID=" + dedeUserID + "; DedeUserID__ckMd5=" + dedeUserIDCkMd5 + "; bili_jct=" + biliJct + "; Expires=" + expires + "; Domain=" + domain + "; sid=" + sid + "; gourl=" + gourl;
|
||||
public LoginCookie() {
|
||||
setTableName("login_cookie");
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.bili.bean.login;
|
||||
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.bili.bean.login;
|
||||
|
||||
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.bili.bean.login;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -32,7 +32,7 @@ public class UserInfoBean extends BaseBean {
|
||||
private LevelInfo levelInfo;
|
||||
|
||||
@JSONField(name = "mid")
|
||||
private BigInteger mid;
|
||||
private long mid;
|
||||
|
||||
@JSONField(name = "mobile_verified")
|
||||
private int mobileVerified;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket;
|
||||
package com.yutou.bili.bean.websocket;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.biliapi.bean.websocket;
|
||||
package com.yutou.bili.bean.websocket;
|
||||
|
||||
import com.yutou.biliapi.utils.BytesUtils;
|
||||
import com.yutou.bili.utils.BytesUtils;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,13 +1,11 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.common.utils.Log;
|
||||
import com.yutou.utils.Log;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 弹幕信息
|
||||
* <a href="https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/live/message_stream.md#%E5%BC%B9%E5%B9%95">弹幕</a>
|
||||
@ -23,7 +21,7 @@ public class WSDanmuData extends WSData {
|
||||
private long time;
|
||||
private String uCode;
|
||||
private String danmu;
|
||||
private BigInteger uid;
|
||||
private long uid;
|
||||
private String uname;
|
||||
private WSUserMedal medal;
|
||||
|
||||
@ -36,7 +34,7 @@ public class WSDanmuData extends WSData {
|
||||
setTime(infoData.getJSONArray(0).getLong(4));
|
||||
setUCode(infoData.getJSONArray(0).getString(7));
|
||||
setDanmu(infoData.getString(1));
|
||||
setUid(infoData.getJSONArray(2).getBigInteger(0));
|
||||
setUid(infoData.getJSONArray(2).getInteger(0));
|
||||
setUname(infoData.getJSONArray(2).getString(1));
|
||||
try {
|
||||
medal = WSUserMedal.create(infoData.getJSONArray(3));
|
@ -1,12 +1,10 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.common.inter.ISqlDatabaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
public class WSData implements Serializable, ISqlDatabaseBean {
|
||||
|
||||
public class WSData implements Serializable {
|
||||
public String cmd;
|
||||
public String jsonSrc;
|
||||
public long ws_timer;
|
||||
@ -41,9 +39,4 @@ public class WSData implements Serializable, ISqlDatabaseBean {
|
||||
default -> new WSData(json);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJson(){
|
||||
return jsonSrc;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
@ -14,14 +14,14 @@ import org.springframework.util.StringUtils;
|
||||
public class WSInteractWord extends WSData {
|
||||
public final static int TYPE_ENTER = 1;
|
||||
public final static int TYPE_FOLLOW = 2;
|
||||
private long uid;
|
||||
private int type; //1为进场,2为关注
|
||||
private long roomId;
|
||||
private long timer;
|
||||
private WSUserMedal medal;
|
||||
private long uid;
|
||||
private String uname;
|
||||
private String uname_color;
|
||||
private String face;
|
||||
private WSUserMedal medal;
|
||||
|
||||
|
||||
public WSInteractWord(JSONObject json) {
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
@ -76,7 +76,7 @@ public class WSSendGift extends WSData {
|
||||
@JSONField(name = "float_sc_resource_id")
|
||||
private long floatScResourceID;
|
||||
@JSONField(name = "giftId")
|
||||
private int giftId;
|
||||
private long giftID;
|
||||
@JSONField(name = "giftName")
|
||||
private String giftName;
|
||||
@JSONField(name = "giftType")
|
||||
@ -150,7 +150,7 @@ public class WSSendGift extends WSData {
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
public static class FaceEffectV2 implements Serializable {
|
||||
public static class FaceEffectV2 implements Serializable{
|
||||
@JSONField(name = "id")
|
||||
private long id;
|
||||
@JSONField(name = "type")
|
||||
@ -158,7 +158,7 @@ public class WSSendGift extends WSData {
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
public static class GiftInfo implements Serializable {
|
||||
public static class GiftInfo implements Serializable{
|
||||
@JSONField(name = "effect_id")
|
||||
private long effectID;
|
||||
@JSONField(name = "has_imaged_gift")
|
||||
@ -224,7 +224,6 @@ public class WSSendGift extends WSData {
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
public static class ComboSend implements Serializable {
|
||||
@JSONField(name = "action")
|
||||
@ -232,13 +231,13 @@ public class WSSendGift extends WSData {
|
||||
@JSONField(name = "combo_id")
|
||||
private String comboID;
|
||||
@JSONField(name = "combo_num")
|
||||
private int comboNum;
|
||||
private long comboNum;
|
||||
@JSONField(name = "gift_id")
|
||||
private long giftID;
|
||||
@JSONField(name = "gift_name")
|
||||
private String giftName;
|
||||
@JSONField(name = "gift_num")
|
||||
private int giftNum;
|
||||
private long giftNum;
|
||||
@JSONField(name = "uid")
|
||||
private long uid;
|
||||
@JSONField(name = "uname")
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
@ -6,7 +6,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 超级留言
|
||||
* <a href="https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/live/message_stream.md#%E9%86%92%E7%9B%AE%E7%95%99%E8%A8%80-super_chat_message">醒目留言</a>
|
||||
* <a href="https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/live/message_stream.md#%E9%86%92%E7%9B%AE%E7%95%99%E8%A8%80">醒目留言</a>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.websocket.live;
|
||||
package com.yutou.bili.bean.websocket.live;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import lombok.Data;
|
@ -0,0 +1,53 @@
|
||||
package com.yutou.bili.databases;
|
||||
|
||||
import com.yutou.bili.bean.login.LoginCookie;
|
||||
import com.yutou.databases.SQLiteManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BiliBiliLoginDatabase extends SQLiteManager {
|
||||
LoginCookie cookie;
|
||||
private static BiliBiliLoginDatabase instance;
|
||||
|
||||
private BiliBiliLoginDatabase(Class<LoginCookie> tClass) {
|
||||
try {
|
||||
cookie = new LoginCookie();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
public static BiliBiliLoginDatabase getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new BiliBiliLoginDatabase(LoginCookie.class);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public BiliBiliLoginDatabase initData(LoginCookie cookie) {
|
||||
this.cookie = cookie;
|
||||
for (BuildSqlTable table : build.getTable()) {
|
||||
cookie.setTableName(table.getName());
|
||||
add(cookie);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginCookie get() {
|
||||
List<LoginCookie> list = super.get(cookie.getTableName(), LoginCookie.class);
|
||||
if (!list.isEmpty()) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoginCookie getDataBean() {
|
||||
return new LoginCookie();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.enums;
|
||||
package com.yutou.bili.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.enums;
|
||||
package com.yutou.bili.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.enums;
|
||||
package com.yutou.bili.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.enums;
|
||||
package com.yutou.bili.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.yutou.biliapi.net;
|
||||
package com.yutou.bili.net;
|
||||
|
||||
import com.yutou.biliapi.bean.login.CheckCookieBean;
|
||||
import com.yutou.common.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.common.okhttp.HttpCallback;
|
||||
import com.yutou.common.utils.RSAUtils;
|
||||
import com.yutou.bili.bean.login.CheckCookieBean;
|
||||
import com.yutou.bili.bean.login.LoginInfoBean;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import com.yutou.utils.RSAUtils;
|
||||
import okhttp3.Headers;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
@ -29,7 +30,7 @@ public class BiliCookieManager {
|
||||
"-----END PUBLIC KEY-----";
|
||||
|
||||
public void checkCookie(IHttpApiCheckCallback<Integer> callback){
|
||||
BiliLoginNetApiManager.getInstance().getLoginApi(null)
|
||||
BiliLoginNetApiManager.getInstance().getLoginApi(true)
|
||||
.checkCookie().enqueue(new HttpCallback<CheckCookieBean>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, CheckCookieBean response, String rawResponse) {
|
@ -0,0 +1,39 @@
|
||||
package com.yutou.bili.net;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.bili.api.LiveApi;
|
||||
import com.yutou.bili.bean.login.LoginCookie;
|
||||
import com.yutou.bili.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.api.BaseApi;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class BiliLiveNetApiManager extends BaseApi {
|
||||
private static BiliLiveNetApiManager instance;
|
||||
|
||||
public static BiliLiveNetApiManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new BiliLiveNetApiManager("https://api.live.bilibili.com");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private BiliLiveNetApiManager(String URL) {
|
||||
super(URL);
|
||||
}
|
||||
|
||||
public void getApi(IHttpApiCheckCallback<LiveApi> callback) {
|
||||
LoginCookie cookie = BiliBiliLoginDatabase.getInstance().get();
|
||||
if (cookie != null) {
|
||||
useCookie(JSONObject.parseObject(JSONObject.toJSONString(cookie)));
|
||||
}
|
||||
HashMap<String,String> header=new HashMap<>();
|
||||
header.put("Accept-Language", "zh-CN,zh;q=0.8");
|
||||
header.put("Referer", "https://live.bilibili.com");
|
||||
header.put("Connection", "keep-alive");
|
||||
header.put("Upgrade-Insecure-Requests", "1");
|
||||
addHeader(header);
|
||||
callback.onSuccess(createApi(LiveApi.class));
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package com.yutou.biliapi.net;
|
||||
package com.yutou.bili.net;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.api.LoginApi;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.LoginInfoBean;
|
||||
import com.yutou.biliapi.bean.login.QRCodeGenerateBean;
|
||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.common.okhttp.HttpCallback;
|
||||
import com.yutou.common.okhttp.api.BaseApi;
|
||||
import com.yutou.bili.api.LoginApi;
|
||||
import com.yutou.bili.bean.login.LoginCookie;
|
||||
import com.yutou.bili.bean.login.LoginInfoBean;
|
||||
import com.yutou.bili.bean.login.QRCodeGenerateBean;
|
||||
import com.yutou.bili.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import com.yutou.okhttp.api.BaseApi;
|
||||
import okhttp3.Headers;
|
||||
import org.springframework.util.StringUtils;
|
||||
import retrofit2.Response;
|
||||
@ -38,12 +38,12 @@ public class BiliLoginNetApiManager extends BaseApi {
|
||||
}
|
||||
|
||||
public LoginApi getLoginApi() {
|
||||
return getLoginApi(null);
|
||||
return getLoginApi(false);
|
||||
}
|
||||
|
||||
public LoginApi getLoginApi(String loginUid) {
|
||||
if (StringUtils.hasText(loginUid)) {
|
||||
LoginCookieDatabaseBean cookie = BiliBiliLoginDatabase.getInstance().getCookie(loginUid);
|
||||
public LoginApi getLoginApi(boolean isCookie) {
|
||||
if (isCookie) {
|
||||
LoginCookie cookie = BiliBiliLoginDatabase.getInstance().get();
|
||||
if (cookie != null) {
|
||||
useCookie(JSONObject.parseObject(JSONObject.toJSONString(cookie)));
|
||||
}
|
||||
@ -51,7 +51,12 @@ public class BiliLoginNetApiManager extends BaseApi {
|
||||
return loginApi;
|
||||
}
|
||||
|
||||
public void login(HttpCallback<LoginCookieDatabaseBean> callback) {
|
||||
public void login(HttpCallback<LoginCookie> callback) {
|
||||
LoginCookie cookie = BiliBiliLoginDatabase.getInstance().get();
|
||||
if (cookie != null) {
|
||||
callback.onResponse(null, LOGIN_SUCCESS, null, cookie, null);
|
||||
return;
|
||||
}
|
||||
loginApi.getQRCodeGenerate().enqueue(new HttpCallback<QRCodeGenerateBean>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, QRCodeGenerateBean response, String rawResponse) {
|
||||
@ -69,7 +74,7 @@ public class BiliLoginNetApiManager extends BaseApi {
|
||||
});
|
||||
}
|
||||
|
||||
private void waitLogin(String oauthKey, HttpCallback<LoginCookieDatabaseBean> callback) {
|
||||
private void waitLogin(String oauthKey, HttpCallback<LoginCookie> callback) {
|
||||
long time = System.currentTimeMillis();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
@ -105,7 +110,7 @@ public class BiliLoginNetApiManager extends BaseApi {
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
ck.put("gourl", bd);
|
||||
LoginCookieDatabaseBean cookie = JSONObject.parseObject(ck.toString(), LoginCookieDatabaseBean.class);
|
||||
LoginCookie cookie = JSONObject.parseObject(ck.toString(), LoginCookie.class);
|
||||
cancel();
|
||||
callback.onResponse(headers, LOGIN_SUCCESS, "ok", cookie, ck.toString());
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.yutou.biliapi.net;
|
||||
package com.yutou.bili.net;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.api.UserApi;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.common.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.common.okhttp.api.BaseApi;
|
||||
import com.yutou.bili.api.UserApi;
|
||||
import com.yutou.bili.bean.login.LoginCookie;
|
||||
import com.yutou.bili.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.api.BaseApi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BiliUserNetApiManager extends BaseApi {
|
||||
public static final int LOGIN_LOGOUT = 1;
|
||||
@ -25,7 +26,8 @@ public class BiliUserNetApiManager extends BaseApi {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public UserApi getUserApi(LoginCookieDatabaseBean cookie) {
|
||||
public void getUserApi(IHttpApiCheckCallback<UserApi> callback) {
|
||||
LoginCookie cookie = BiliBiliLoginDatabase.getInstance().get();
|
||||
if (cookie != null) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(cookie));
|
||||
@ -35,8 +37,10 @@ public class BiliUserNetApiManager extends BaseApi {
|
||||
}
|
||||
headers.put("Cookie", ck.toString());
|
||||
setHeaders(headers);
|
||||
callback.onSuccess(createApi(UserApi.class));
|
||||
} else {
|
||||
callback.onError(LOGIN_LOGOUT, "未登录");
|
||||
}
|
||||
return createApi(UserApi.class);
|
||||
}
|
||||
|
||||
}
|
248
biliapi/src/main/java/com/yutou/bili/net/WebSocketManager.java
Normal file
248
biliapi/src/main/java/com/yutou/bili/net/WebSocketManager.java
Normal file
@ -0,0 +1,248 @@
|
||||
package com.yutou.bili.net;
|
||||
|
||||
import com.aayushatharva.brotli4j.Brotli4jLoader;
|
||||
import com.aayushatharva.brotli4j.decoder.Decoder;
|
||||
import com.aayushatharva.brotli4j.decoder.DecoderJNI;
|
||||
import com.aayushatharva.brotli4j.decoder.DirectDecompress;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.bili.api.LiveApi;
|
||||
import com.yutou.bili.bean.live.LiveDanmuInfo;
|
||||
import com.yutou.bili.bean.live.LiveRoomConfig;
|
||||
import com.yutou.bili.bean.websocket.WebSocketBody;
|
||||
import com.yutou.bili.bean.websocket.WebSocketHeader;
|
||||
import com.yutou.bili.bean.websocket.live.WSData;
|
||||
import com.yutou.bili.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.bili.utils.BiliUserUtils;
|
||||
import com.yutou.bili.utils.BytesUtils;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import com.yutou.utils.Log;
|
||||
import okhttp3.Headers;
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
import org.java_websocket.handshake.ServerHandshake;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class WebSocketManager {
|
||||
private static WebSocketManager instance;
|
||||
Map<LiveRoomConfig, WebSocketClientTh> roomMap;
|
||||
|
||||
private WebSocketManager() {
|
||||
roomMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public static WebSocketManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new WebSocketManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addRoom(LiveRoomConfig roomConfig) {
|
||||
BiliLiveNetApiManager.getInstance().getApi(new IHttpApiCheckCallback<LiveApi>() {
|
||||
@Override
|
||||
public void onSuccess(LiveApi api) {
|
||||
api.getLiveRoomDanmuInfo(roomConfig.getRoomId()).enqueue(new HttpCallback<LiveDanmuInfo>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, LiveDanmuInfo response, String rawResponse) {
|
||||
if (!response.getHostList().isEmpty()) {
|
||||
LiveDanmuInfo.Host host = response.getHostList().get(0);
|
||||
String url = "wss://" + host.getHost() + ":" + host.getWssPort() + "/sub";
|
||||
// url="ws://127.0.0.1:8765";
|
||||
try {
|
||||
roomConfig.setLiveInfo(response);
|
||||
new WebSocketClientTh(new URI(url), roomConfig);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class WebSocketClientTh extends WebSocketClient {
|
||||
private LiveRoomConfig roomConfig;
|
||||
private HeartbeatTask heartbeatTask;
|
||||
|
||||
|
||||
public WebSocketClientTh(URI serverUri, LiveRoomConfig roomId) {
|
||||
super(serverUri);
|
||||
this.roomConfig = roomId;
|
||||
heartbeatTask = new HeartbeatTask();
|
||||
connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(ServerHandshake serverHandshake) {
|
||||
WebSocketManager.getInstance().roomMap.put(roomConfig, this);
|
||||
heartbeatTask.setSocket(this);
|
||||
heartbeatTask.sendInitAuthData();
|
||||
new Timer().schedule(heartbeatTask, 1000, 30000);
|
||||
System.out.println("WebSocketClientTh.onOpen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String s) {
|
||||
System.out.println("s = " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ByteBuffer bytes) {
|
||||
System.out.println("WebSocketClientTh.onMessage");
|
||||
super.onMessage(bytes);
|
||||
decompress(bytes.array());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int i, String s, boolean b) {
|
||||
System.out.println("WebSocketClientTh.onClose");
|
||||
System.out.println("i = " + i + ", s = " + s + ", b = " + b);
|
||||
WebSocketManager.getInstance().roomMap.remove(roomConfig);
|
||||
heartbeatTask.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
System.out.println("WebSocketClientTh.onError");
|
||||
e.printStackTrace();
|
||||
WebSocketManager.getInstance().roomMap.remove(roomConfig);
|
||||
heartbeatTask.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压缩
|
||||
*
|
||||
* @param data 待压缩的数据
|
||||
*/
|
||||
public void decompress(byte[] data) {
|
||||
byte[] bytes = new byte[data.length - 16];
|
||||
WebSocketHeader header = new WebSocketHeader(data);
|
||||
System.arraycopy(data, header.getHeaderSize(), bytes, 0, data.length - header.getHeaderSize());
|
||||
System.out.println("数据大小:" + header.getDataSize() + " 协议:" + header.getAgree() + " 头部大小:" + header.getHeaderSize() + " 命令:" + header.getCmdData());
|
||||
switch (header.getAgree()) {
|
||||
case 0:
|
||||
case 1:
|
||||
danmu(bytes);
|
||||
break;
|
||||
default:
|
||||
unzipDanmu(bytes, header.getAgree() == 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void danmu(byte[] bytes) {
|
||||
Log.i("未压缩:" + new String(bytes));
|
||||
}
|
||||
|
||||
private void unzipDanmu(byte[] bytes, boolean useHeader) {
|
||||
try {
|
||||
Brotli4jLoader.ensureAvailability();
|
||||
DirectDecompress directDecompress = Decoder.decompress(bytes);
|
||||
if (directDecompress.getResultStatus() == DecoderJNI.Status.DONE) {
|
||||
WebSocketBody body = new WebSocketBody(directDecompress.getDecompressedData());
|
||||
Log.i("3协议:" + useHeader + " 命令数:" + body.getBodyList().size());
|
||||
for (JSONObject json : body.getBodyList()) {
|
||||
Log.i("解压:" + WSData.parse(json));
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
} else {
|
||||
Log.e(new RuntimeException("解压失败"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class HeartbeatTask extends TimerTask {
|
||||
WebSocketClientTh socket;
|
||||
|
||||
public void setSocket(WebSocketClientTh socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// com.yutou.bilibili.Tools.Log.i("-------发送心跳--------");
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(BytesUtils.toLH("[object Object]".length() + 16));
|
||||
outputStream.write(new byte[]{0, 16, 0, 1, 0, 0, 0, 2, 0, 0, 0, 1});
|
||||
outputStream.write("[object Object]".getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
socket.send(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendInitAuthData() {
|
||||
JSONObject json = new JSONObject();
|
||||
if (roomConfig.isLogin()) {
|
||||
json.put("uid", Long.parseLong(roomConfig.getUid()));
|
||||
|
||||
} else {
|
||||
json.put("uid", 0);
|
||||
}
|
||||
BiliUserUtils.getBuvid(new IHttpApiCheckCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String api) {
|
||||
try {
|
||||
json.put("roomid", Long.parseLong(roomConfig.getRoomId()));
|
||||
json.put("protover", 3);
|
||||
json.put("buvid", api);
|
||||
json.put("platform", "web");
|
||||
json.put("type", 2);
|
||||
json.put("key", roomConfig.getLiveInfo().getToken());
|
||||
byte[] bytes = {0, 16, 0, 1, 0, 0, 0, 7, 0, 0, 0, 1};
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
System.out.println("bytes.length = " + bytes.length);
|
||||
Log.i(json);
|
||||
outputStream.write(BytesUtils.toLH(json.toString().length() + 16));
|
||||
outputStream.write(bytes);
|
||||
outputStream.write(json.toJSONString().getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
BytesUtils.printHex(outputStream.toByteArray());
|
||||
System.out.println(socket.isOpen());
|
||||
socket.send(outputStream.toByteArray());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.yutou.bili.utils;
|
||||
|
||||
import com.yutou.bili.api.UserApi;
|
||||
import com.yutou.bili.bean.live.SpiBean;
|
||||
import com.yutou.bili.net.BiliUserNetApiManager;
|
||||
import com.yutou.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import com.yutou.utils.RedisTools;
|
||||
import okhttp3.Headers;
|
||||
|
||||
public class BiliUserUtils {
|
||||
public static void getBuvid(IHttpApiCheckCallback<String> callback) {
|
||||
String buvid= RedisTools.get(RedisTools.BILI_USER_BUVID);
|
||||
if(buvid!=null){
|
||||
callback.onSuccess(buvid);
|
||||
return;
|
||||
}
|
||||
BiliUserNetApiManager.getInstance().getUserApi(new IHttpApiCheckCallback<UserApi>() {
|
||||
@Override
|
||||
public void onSuccess(UserApi api) {
|
||||
api.getFingerSpi().enqueue(new HttpCallback<SpiBean>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, SpiBean response, String rawResponse) {
|
||||
RedisTools.set(RedisTools.BILI_USER_BUVID,response.getB_3());
|
||||
callback.onSuccess(response.getB_3());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.biliapi.utils;
|
||||
package com.yutou.bili.utils;
|
||||
|
||||
import com.yutou.common.utils.Log;
|
||||
import com.yutou.utils.Log;
|
||||
import jakarta.xml.bind.DatatypeConverter;
|
||||
|
||||
public class BytesUtils {
|
@ -1,10 +1,12 @@
|
||||
package com.yutou.biliapi.utils;
|
||||
package com.yutou.bili.utils;
|
||||
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
import org.java_websocket.handshake.ServerHandshake;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LiveHeartBeat {
|
34
common/pom.xml
Normal file
34
common/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?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>com.yutou</groupId>
|
||||
<artifactId>bilibili</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>retrofit</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,17 @@
|
||||
package com.yutou.databases;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AbsDatabasesBean {
|
||||
String tableName;
|
||||
|
||||
|
||||
public JSONObject toJson() {
|
||||
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(this, JSONWriter.Feature.WriteMapNullValue));
|
||||
json.remove("tableName");
|
||||
return json;
|
||||
}
|
||||
}
|
302
common/src/main/java/com/yutou/databases/SQLiteManager.java
Normal file
302
common/src/main/java/com/yutou/databases/SQLiteManager.java
Normal file
@ -0,0 +1,302 @@
|
||||
package com.yutou.databases;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.utils.Log;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SQLiteManager {
|
||||
protected Connection conn;
|
||||
private String url = "jdbc:sqlite:";
|
||||
private File sql;
|
||||
@Getter
|
||||
public BuildSql build;
|
||||
|
||||
public void init() {
|
||||
AbsDatabasesBean data = getDataBean();
|
||||
List<BuildSqlItem> items = new ArrayList<>();
|
||||
Field[] fields = data.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
String name = field.getAnnotation(JSONField.class).name();
|
||||
if (name.equals("tableName")) continue;
|
||||
String type = BuildSqlItem.TYPE_STRING;
|
||||
if (field.getType() == int.class) {
|
||||
type = BuildSqlItem.TYPE_INT;
|
||||
} else if (field.getType() == String.class) {
|
||||
type = BuildSqlItem.TYPE_STRING;
|
||||
} else if (field.getType() == Date.class) {
|
||||
type = BuildSqlItem.TYPE_TIME;
|
||||
}
|
||||
items.add(BuildSqlItem.create().setName(name).setType(type).setNull(true).setKey(false));
|
||||
}
|
||||
BuildSql sql = BuildSql.create()
|
||||
.setFileName("bilibili_login.db")
|
||||
.setTable(BuildSqlTable.create().setName(data.getTableName()).setItem(items));
|
||||
build(sql);
|
||||
}
|
||||
|
||||
|
||||
public void startBatch() {
|
||||
try {
|
||||
conn.setAutoCommit(false);
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void closeBatch() {
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void commit() {
|
||||
try {
|
||||
conn.commit();
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends AbsDatabasesBean> void add(T t) {
|
||||
try {
|
||||
Statement statement = conn.createStatement();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
sb.append("INSERT INTO `").append(t.getTableName()).append("` ");
|
||||
sb.append("(");
|
||||
value.append("(");
|
||||
for (String key : t.toJson().keySet()) {
|
||||
sb.append("`").append(key).append("`,");
|
||||
value.append("'").append(t.toJson().get(key)).append("',");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
value.deleteCharAt(value.length() - 1);
|
||||
value.append(")");
|
||||
sb.append(") VALUES ");
|
||||
sb.append(value);
|
||||
statement.executeUpdate(sb.toString());
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends AbsDatabasesBean> List<T> get(String table, Class<T> tClass) {
|
||||
List<T> list = new ArrayList<>();
|
||||
try {
|
||||
Statement statement = conn.createStatement();
|
||||
String sql = "SELECT * FROM `" + table + "`";
|
||||
ResultSet resultSet = statement.executeQuery(sql);
|
||||
while (resultSet.next()) {
|
||||
JSONObject json = new JSONObject();
|
||||
for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) {
|
||||
String name = resultSet.getMetaData().getColumnName(i + 1);
|
||||
json.put(name, resultSet.getObject(name));
|
||||
}
|
||||
list.add(json.to(tClass));
|
||||
}
|
||||
resultSet.close();
|
||||
statement.closeOnCompletion();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private void createSql(BuildSql build) {
|
||||
try {
|
||||
sql.mkdirs();
|
||||
sql.delete();
|
||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
startBatch();
|
||||
for (BuildSqlTable table : build.getTable()) {
|
||||
Log.i("创建表:" + table.getName());
|
||||
createSqlOfTable(table);
|
||||
}
|
||||
closeBatch();
|
||||
}
|
||||
|
||||
private void createSqlOfTable(BuildSqlTable table) {
|
||||
String tableName = table.getName();
|
||||
try {
|
||||
Statement statement = conn.createStatement();
|
||||
List<BuildSqlItem> items = table.getItem();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("CREATE TABLE `")
|
||||
.append(tableName)
|
||||
.append("` (");
|
||||
for (BuildSqlItem item : items) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String type = switch (item.getType()) {
|
||||
case "int" -> " INTEGER ";
|
||||
case "TIME" -> " NUMERIC ";
|
||||
default -> " TEXT ";
|
||||
};
|
||||
builder.append("`")
|
||||
.append(item.getName())
|
||||
.append("`")
|
||||
.append(type)
|
||||
.append(item.isNull() ? "" : " NOT NULL ")
|
||||
.append(item.isKey() ? " PRIMARY KEY AUTOINCREMENT " : "")
|
||||
.append(",");
|
||||
sql.append(builder.toString());
|
||||
}
|
||||
sql.append(");");
|
||||
System.out.println("创建表 > " + sql.toString());
|
||||
statement.execute(sql.toString().replace(",);", ");"));
|
||||
statement.closeOnCompletion();
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void build(BuildSql buildSql) {
|
||||
try {
|
||||
this.build = buildSql;
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
sql = new File("databases" + File.separator + buildSql.getFileName());
|
||||
if (!sql.exists()) {
|
||||
createSql(buildSql);
|
||||
} else {
|
||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setDB(String fileName) {
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
sql = new File("db" + File.separator + fileName);
|
||||
if (sql.exists()) {
|
||||
if (conn != null && !conn.isClosed()) {
|
||||
conn.close();
|
||||
}
|
||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected abstract AbsDatabasesBean getDataBean();
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BuildSql {
|
||||
String fileName;
|
||||
List<BuildSqlTable> table;
|
||||
|
||||
public static BuildSql create() {
|
||||
return new BuildSql();
|
||||
}
|
||||
|
||||
public BuildSql setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSql setTable(List<BuildSqlTable> table) {
|
||||
this.table = table;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSql setTable(BuildSqlTable... table) {
|
||||
this.table = List.of(table);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BuildSqlTable {
|
||||
String name;
|
||||
List<BuildSqlItem> item;
|
||||
|
||||
public static BuildSqlTable create() {
|
||||
return new BuildSqlTable();
|
||||
}
|
||||
|
||||
public BuildSqlTable setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSqlTable setItem(List<BuildSqlItem> item) {
|
||||
this.item = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSqlTable setItem(BuildSqlItem... item) {
|
||||
this.item = List.of(item);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BuildSqlItem {
|
||||
public static final String TYPE_INT = "init";
|
||||
public static final String TYPE_STRING = "String";
|
||||
public static final String TYPE_TIME = "TIME";
|
||||
|
||||
|
||||
String name;
|
||||
String type;
|
||||
boolean isNull;
|
||||
boolean isKey;
|
||||
|
||||
public static BuildSqlItem create() {
|
||||
return new BuildSqlItem();
|
||||
}
|
||||
|
||||
public BuildSqlItem setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSqlItem setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSqlItem setNull(boolean aNull) {
|
||||
isNull = aNull;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildSqlItem setKey(boolean key) {
|
||||
isKey = key;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.inter;
|
||||
package com.yutou.inter;
|
||||
|
||||
public interface IHttpApiCheckCallback<T> {
|
||||
void onSuccess(T api);
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.HttpUrl;
|
||||
@ -18,11 +18,10 @@ public abstract class FileCallback<T> implements Callback<FileBody<T>> {
|
||||
|
||||
private static ThreadPoolExecutor executor;
|
||||
private final T bean;
|
||||
private String savePath;
|
||||
|
||||
public FileCallback(T bean, String savePath) {
|
||||
|
||||
public FileCallback(T bean) {
|
||||
this.bean = bean;
|
||||
this.savePath = savePath;
|
||||
if (executor == null) {
|
||||
executor = new ThreadPoolExecutor(2, 4, Long.MAX_VALUE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));
|
||||
}
|
||||
@ -46,7 +45,7 @@ public abstract class FileCallback<T> implements Callback<FileBody<T>> {
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("开始下载");
|
||||
File file = new File(savePath);
|
||||
File file = new File("download" + File.separator + System.currentTimeMillis() + ".flv");
|
||||
onStart(bean);
|
||||
if (!file.exists()) {
|
||||
boolean mkdirs = file.getParentFile().mkdirs();
|
||||
@ -68,7 +67,6 @@ public abstract class FileCallback<T> implements Callback<FileBody<T>> {
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
onFailure(bean,e);
|
||||
} finally {
|
||||
onFinish(bean);
|
||||
try {
|
||||
@ -93,13 +91,7 @@ public abstract class FileCallback<T> implements Callback<FileBody<T>> {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<FileBody<T>> call, Response<FileBody<T>> response) {
|
||||
try {
|
||||
executor.execute(new DownloadTask(bean, response.headers(), call.request().url(), response.body().getInputStream()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
onFailure(bean,e);
|
||||
call.cancel();
|
||||
}
|
||||
executor.execute(new DownloadTask(bean, response.headers(), call.request().url(), response.body().getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
|
||||
import okhttp3.Headers;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import retrofit2.Call;
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
|
||||
import com.yutou.common.utils.Log;
|
||||
import com.yutou.utils.Log;
|
||||
import okhttp3.*;
|
||||
import okhttp3.internal.http.HttpHeaders;
|
||||
import okio.Buffer;
|
||||
@ -16,7 +16,7 @@ public class HttpLoggingInterceptor implements Interceptor {
|
||||
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
private volatile Level printLevel = Level.BODY;
|
||||
private volatile Level printLevel = Level.NONE;
|
||||
private java.util.logging.Level colorLevel;
|
||||
private Logger logger;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import okhttp3.Request;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
import com.yutou.common.utils.ConfigTools;
|
||||
import okhttp3.Request;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -39,7 +38,7 @@ public class ParamsContext {
|
||||
break;
|
||||
}
|
||||
headerMap.remove("tableName");
|
||||
headerMap.put("User-Agent", ConfigTools.getUserAgent());
|
||||
headerMap.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36");
|
||||
return iRequestParam.getRequest(headerMap, map, request);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp;
|
||||
package com.yutou.okhttp;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
@ -1,13 +1,13 @@
|
||||
package com.yutou.common.okhttp.api;
|
||||
package com.yutou.okhttp.api;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.internal.bind.DateTypeAdapter;
|
||||
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.common.okhttp.ParamsContext;
|
||||
import com.yutou.common.okhttp.converter.JsonCallAdapter;
|
||||
import com.yutou.common.okhttp.converter.JsonConverterFactory;
|
||||
import com.yutou.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.okhttp.ParamsContext;
|
||||
import com.yutou.okhttp.converter.JsonCallAdapter;
|
||||
import com.yutou.okhttp.converter.JsonConverterFactory;
|
||||
import okhttp3.*;
|
||||
import retrofit2.CallAdapter;
|
||||
import retrofit2.Converter;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp.converter;
|
||||
package com.yutou.okhttp.converter;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import retrofit2.CallAdapter;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp.converter;
|
||||
package com.yutou.okhttp.converter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.okhttp.converter;
|
||||
package com.yutou.okhttp.converter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
@ -1,11 +1,11 @@
|
||||
package com.yutou.common.okhttp.converter;
|
||||
package com.yutou.okhttp.converter;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.yutou.common.okhttp.FileBody;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.okhttp.FileBody;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import retrofit2.Converter;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.utils;
|
||||
package com.yutou.utils;
|
||||
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
@ -1,5 +1,4 @@
|
||||
package com.yutou.common.utils;
|
||||
|
||||
package com.yutou.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
@ -1,8 +1,7 @@
|
||||
package com.yutou.common.utils;
|
||||
package com.yutou.utils;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -94,16 +93,4 @@ public class ConfigTools {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getUserAgent() {
|
||||
String ua=load(CONFIG,"userAgent",String.class);
|
||||
if(!StringUtils.hasText(ua)){
|
||||
ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36";
|
||||
}
|
||||
return ua;
|
||||
}
|
||||
public static boolean saveUserAgent(String ua) {
|
||||
return save(CONFIG,"userAgent",ua);
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.utils;
|
||||
package com.yutou.utils;
|
||||
|
||||
|
||||
import java.io.File;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.common.utils;
|
||||
package com.yutou.utils;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.yutou.common.utils;
|
||||
package com.yutou.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -27,7 +29,7 @@ public class RedisTools {
|
||||
//Properties properties = PropertyUtil.loadProperties("jedis.properties");
|
||||
//host = properties.getProperty("redis.host");
|
||||
//port = Integer.valueOf(properties.getProperty("redis.port"));
|
||||
host = "127.0.0.1";
|
||||
host = "172.22.81.254";
|
||||
port = 6379;
|
||||
}
|
||||
|
74
pom.xml
74
pom.xml
@ -14,9 +14,14 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>bilibili</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<modules>
|
||||
<module>biliapi</module>
|
||||
<module>qqbot</module>
|
||||
<module>common</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<kotlin.version>1.7.22</kotlin.version>
|
||||
<kotlin.version>1.6.10</kotlin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -27,6 +32,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web-services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
@ -67,6 +77,11 @@
|
||||
<artifactId>Java-WebSocket</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
@ -95,36 +110,22 @@
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava3</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>3.1.8</version>
|
||||
<groupId>com.yutou</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aayushatharva.brotli4j</groupId>
|
||||
<artifactId>brotli4j</artifactId>
|
||||
<version>1.16.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
<groupId>com.yutou</groupId>
|
||||
<artifactId>qqbot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>retrofit</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
||||
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -145,6 +146,27 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -152,7 +174,7 @@
|
||||
<!--使用-Dloader.path需要在打包的时候增加<layout>ZIP</layout>,不指定的话-Dloader.path不生效-->
|
||||
<layout>ZIP</layout>
|
||||
<!-- 指定该jar包启动时的主类[建议] -->
|
||||
<mainClass>com.yutou.BilibiliApplication</mainClass>
|
||||
<mainClass>com.yutou.bilibili.BilibiliApplication</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@ -171,8 +193,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<source>7</source>
|
||||
<target>7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
29
qqbot/pom.xml
Normal file
29
qqbot/pom.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?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>com.yutou</groupId>
|
||||
<artifactId>bilibili</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qqbot</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>com.yutou</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
@ -1,11 +1,10 @@
|
||||
package com.yutou.qqbot;
|
||||
package com.yutou.napcat;
|
||||
|
||||
import com.yutou.qqbot.handle.MessageHandleBuild;
|
||||
import com.yutou.qqbot.handle.Text;
|
||||
import com.yutou.qqbot.http.NapCatApi;
|
||||
import com.yutou.qqbot.model.SendMessageResponse;
|
||||
import com.yutou.common.okhttp.HttpCallback;
|
||||
import com.yutou.common.utils.Base64Tools;
|
||||
import com.yutou.napcat.handle.MessageHandleBuild;
|
||||
import com.yutou.napcat.handle.Text;
|
||||
import com.yutou.napcat.http.NapCatApi;
|
||||
import com.yutou.napcat.model.SendMessageResponse;
|
||||
import com.yutou.okhttp.HttpCallback;
|
||||
import okhttp3.Headers;
|
||||
|
||||
import java.io.File;
|
||||
@ -27,7 +26,6 @@ public class NapCatQQ {
|
||||
list.add(new Text("5"));
|
||||
QQBotManager.getInstance().sendMessage(false, 891655174L, list);*/
|
||||
NapCatApi.setLog(false);
|
||||
Base64Tools.decode("111");
|
||||
File file = new File("C:\\Users\\58381\\Downloads\\0074TT8Yly1hp5mqidwqeg30g20f27wh.gif");
|
||||
NapCatApi.getMessageApi().sendPrivateMsg(
|
||||
MessageHandleBuild.create()
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot;
|
||||
package com.yutou.napcat;
|
||||
|
||||
import com.yutou.qqbot.model.FriendBean;
|
||||
import com.yutou.qqbot.model.GroupBean;
|
||||
import com.yutou.napcat.model.FriendBean;
|
||||
import com.yutou.napcat.model.GroupBean;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1,27 +1,20 @@
|
||||
package com.yutou.qqbot;
|
||||
package com.yutou.napcat;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.common.utils.RedisTools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.yutou.utils.RedisTools;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
public class QQNumberManager {
|
||||
@ResponseBody
|
||||
@RequestMapping("/bot/test")
|
||||
public String test(){
|
||||
return "hello world";
|
||||
}
|
||||
private static QQNumberManager manager;
|
||||
private QQNumberManager(){
|
||||
|
||||
}
|
||||
|
||||
public static QQNumberManager getManager() {
|
||||
if(manager==null) {
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.enums;
|
||||
package com.yutou.napcat.enums;
|
||||
|
||||
public enum MessageEnum {
|
||||
TEXT("text"),
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.enums;
|
||||
package com.yutou.napcat.enums;
|
||||
|
||||
public enum RecordFormatEnum {
|
||||
MP3("mp3"),
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.qqbot.event;
|
||||
package com.yutou.napcat.event;
|
||||
|
||||
import com.yutou.qqbot.model.GroupFrom;
|
||||
import com.yutou.napcat.model.GroupFrom;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.yutou.qqbot.event;
|
||||
package com.yutou.napcat.event;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.qqbot.QQDatabase;
|
||||
import com.yutou.qqbot.enums.MessageEnum;
|
||||
import com.yutou.qqbot.handle.*;
|
||||
import com.yutou.qqbot.model.SourceFrom;
|
||||
import com.yutou.napcat.QQDatabase;
|
||||
import com.yutou.napcat.enums.MessageEnum;
|
||||
import com.yutou.napcat.handle.*;
|
||||
import com.yutou.napcat.model.SourceFrom;
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
public class At extends BaseHandle<At.AtData> {
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.utils.Base64Tools;
|
||||
import com.yutou.utils.Base64Tools;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.yutou.qqbot.model.AppShareBean;
|
||||
import com.yutou.napcat.model.AppShareBean;
|
||||
import lombok.Data;
|
||||
|
||||
public class OtherHandle extends BaseHandle<OtherHandle.OtherInfo>{
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
public class QuoteReply {
|
||||
private final String messageId;
|
@ -1,6 +1,6 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import com.yutou.common.utils.ConfigTools;
|
||||
import com.yutou.utils.ConfigTools;
|
||||
import lombok.Data;
|
||||
|
||||
public class Record extends BaseHandle<Record.RecordInfo> {
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.handle;
|
||||
package com.yutou.napcat.handle;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.http;
|
||||
package com.yutou.napcat.http;
|
||||
|
||||
import com.yutou.qqbot.model.FriendBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.napcat.model.FriendBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.POST;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.yutou.qqbot.http;
|
||||
package com.yutou.napcat.http;
|
||||
|
||||
import com.yutou.qqbot.model.GroupBean;
|
||||
import com.yutou.qqbot.model.GroupUserBean;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.napcat.model.GroupBean;
|
||||
import com.yutou.napcat.model.GroupUserBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
@ -1,10 +1,10 @@
|
||||
package com.yutou.qqbot.http;
|
||||
package com.yutou.napcat.http;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.model.MessageBean;
|
||||
import com.yutou.qqbot.model.SendMessageResponse;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.napcat.model.MessageBean;
|
||||
import com.yutou.napcat.model.SendMessageResponse;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Field;
|
||||
@ -14,7 +14,7 @@ import retrofit2.http.POST;
|
||||
public interface MessageAPI {
|
||||
/**
|
||||
* 发送私聊消息
|
||||
* @param message {@link com.yutou.qqbot.handle.MessageHandleBuild}
|
||||
* @param message {@link com.yutou.napcat.handle.MessageHandleBuild}
|
||||
* @return 消息id
|
||||
*/
|
||||
@POST("/send_private_msg")
|
@ -1,8 +1,8 @@
|
||||
package com.yutou.qqbot.http;
|
||||
package com.yutou.napcat.http;
|
||||
|
||||
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.common.okhttp.api.BaseApi;
|
||||
import com.yutou.common.utils.ConfigTools;
|
||||
import com.yutou.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.okhttp.api.BaseApi;
|
||||
import com.yutou.utils.ConfigTools;
|
||||
|
||||
public class NapCatApi extends BaseApi {
|
||||
private static final String URL;
|
@ -1,8 +1,8 @@
|
||||
package com.yutou.qqbot.http;
|
||||
package com.yutou.napcat.http;
|
||||
|
||||
import com.yutou.qqbot.model.*;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.napcat.model.*;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
@ -13,7 +13,7 @@ public interface UtilsApi {
|
||||
* 获取语音
|
||||
*
|
||||
* @param fileId 收到的语音文件名(消息段的 file 参数),如 0B38145AA44505000B38145AA4450500.silk
|
||||
* @param format 要转换到的格式,目前支持 mp3、amr、wma、m4a、spx、ogg、wav、flac {@link com.yutou.qqbot.enums.RecordFormatEnum}
|
||||
* @param format 要转换到的格式,目前支持 mp3、amr、wma、m4a、spx、ogg、wav、flac {@link com.yutou.napcat.enums.RecordFormatEnum}
|
||||
* @return 转换后的语音文件路径
|
||||
*/
|
||||
@FormUrlEncoded
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
@ -1,7 +1,7 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,4 +1,4 @@
|
||||
package com.yutou.qqbot.model;
|
||||
package com.yutou.napcat.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user