mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-03-21 21:00:26 +08:00
增加一个新的弹幕数据包类型 TV_END
This commit is contained in:
parent
4e97600b01
commit
912ce9a19d
@ -1,5 +1,5 @@
|
||||
group = 'com.hiczp'
|
||||
version = '0.0.5'
|
||||
version = '0.0.6'
|
||||
description = 'Bilibili android client API library written in Java'
|
||||
|
||||
apply plugin: 'idea'
|
||||
@ -22,11 +22,11 @@ dependencies {
|
||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
|
||||
// https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor
|
||||
compile group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '3.9.1'
|
||||
compile group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '3.10.0'
|
||||
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
|
||||
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
|
||||
// https://mvnrepository.com/artifact/io.netty/netty-all
|
||||
compile group: 'io.netty', name: 'netty-all', version: '4.1.20.Final'
|
||||
compile group: 'io.netty', name: 'netty-all', version: '4.1.22.Final'
|
||||
// https://mvnrepository.com/artifact/com.google.guava/guava
|
||||
compile group: 'com.google.guava', name: 'guava', version: '24.0-jre'
|
||||
}
|
||||
|
21
record/bullet_screen_stream_json/TV_END.json
Normal file
21
record/bullet_screen_stream_json/TV_END.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"cmd": "TV_END",
|
||||
"data": {
|
||||
"id": "39077",
|
||||
"uname": "かこゆきこvew",
|
||||
"sname": "是你的苏苏吖",
|
||||
"giftName": "10W银瓜子",
|
||||
"mobileTips": "恭喜 かこゆきこvew 获得10W银瓜子",
|
||||
"raffleId": "39077",
|
||||
"type": "small_tv",
|
||||
"from": "是你的苏苏吖",
|
||||
"fromFace": "http://i0.hdslb.com/bfs/face/147f137d24138d1cfec5443d98ac8b03c4332398.jpg",
|
||||
"win": {
|
||||
"uname": "かこゆきこvew",
|
||||
"face": "http://i0.hdslb.com/bfs/face/4d63bd62322e7f3ef38723a91440bc6930626d9f.jpg",
|
||||
"giftName": "银瓜子",
|
||||
"giftId": "silver",
|
||||
"giftNum": 100000
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
package com.hiczp.bilibili.api.live.socket.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class TVEndEntity implements DataEntity {
|
||||
/**
|
||||
* cmd : TV_END
|
||||
* data : {"id":"39077","uname":"かこゆきこvew","sname":"是你的苏苏吖","giftName":"10W银瓜子","mobileTips":"恭喜 かこゆきこvew 获得10W银瓜子","raffleId":"39077","type":"small_tv","from":"是你的苏苏吖","fromFace":"http://i0.hdslb.com/bfs/face/147f137d24138d1cfec5443d98ac8b03c4332398.jpg","win":{"uname":"かこゆきこvew","face":"http://i0.hdslb.com/bfs/face/4d63bd62322e7f3ef38723a91440bc6930626d9f.jpg","giftName":"银瓜子","giftId":"silver","giftNum":100000}}
|
||||
*/
|
||||
|
||||
@SerializedName("cmd")
|
||||
private String cmd;
|
||||
@SerializedName("data")
|
||||
private Data data;
|
||||
|
||||
@Override
|
||||
public String getCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public void setCmd(String cmd) {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public Data getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Data data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
/**
|
||||
* id : 39077
|
||||
* uname : かこゆきこvew
|
||||
* sname : 是你的苏苏吖
|
||||
* giftName : 10W银瓜子
|
||||
* mobileTips : 恭喜 かこゆきこvew 获得10W银瓜子
|
||||
* raffleId : 39077
|
||||
* type : small_tv
|
||||
* from : 是你的苏苏吖
|
||||
* fromFace : http://i0.hdslb.com/bfs/face/147f137d24138d1cfec5443d98ac8b03c4332398.jpg
|
||||
* win : {"uname":"かこゆきこvew","face":"http://i0.hdslb.com/bfs/face/4d63bd62322e7f3ef38723a91440bc6930626d9f.jpg","giftName":"银瓜子","giftId":"silver","giftNum":100000}
|
||||
*/
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
@SerializedName("uname")
|
||||
private String uname;
|
||||
@SerializedName("sname")
|
||||
private String sname;
|
||||
@SerializedName("giftName")
|
||||
private String giftName;
|
||||
@SerializedName("mobileTips")
|
||||
private String mobileTips;
|
||||
@SerializedName("raffleId")
|
||||
private String raffleId;
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
@SerializedName("from")
|
||||
private String from;
|
||||
@SerializedName("fromFace")
|
||||
private String fromFace;
|
||||
@SerializedName("win")
|
||||
private Win win;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUname() {
|
||||
return uname;
|
||||
}
|
||||
|
||||
public void setUname(String uname) {
|
||||
this.uname = uname;
|
||||
}
|
||||
|
||||
public String getSname() {
|
||||
return sname;
|
||||
}
|
||||
|
||||
public void setSname(String sname) {
|
||||
this.sname = sname;
|
||||
}
|
||||
|
||||
public String getGiftName() {
|
||||
return giftName;
|
||||
}
|
||||
|
||||
public void setGiftName(String giftName) {
|
||||
this.giftName = giftName;
|
||||
}
|
||||
|
||||
public String getMobileTips() {
|
||||
return mobileTips;
|
||||
}
|
||||
|
||||
public void setMobileTips(String mobileTips) {
|
||||
this.mobileTips = mobileTips;
|
||||
}
|
||||
|
||||
public String getRaffleId() {
|
||||
return raffleId;
|
||||
}
|
||||
|
||||
public void setRaffleId(String raffleId) {
|
||||
this.raffleId = raffleId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getFromFace() {
|
||||
return fromFace;
|
||||
}
|
||||
|
||||
public void setFromFace(String fromFace) {
|
||||
this.fromFace = fromFace;
|
||||
}
|
||||
|
||||
public Win getWin() {
|
||||
return win;
|
||||
}
|
||||
|
||||
public void setWin(Win win) {
|
||||
this.win = win;
|
||||
}
|
||||
|
||||
public static class Win {
|
||||
/**
|
||||
* uname : かこゆきこvew
|
||||
* face : http://i0.hdslb.com/bfs/face/4d63bd62322e7f3ef38723a91440bc6930626d9f.jpg
|
||||
* giftName : 银瓜子
|
||||
* giftId : silver
|
||||
* giftNum : 100000
|
||||
*/
|
||||
|
||||
@SerializedName("uname")
|
||||
private String uname;
|
||||
@SerializedName("face")
|
||||
private String face;
|
||||
@SerializedName("giftName")
|
||||
private String giftName;
|
||||
@SerializedName("giftId")
|
||||
private String giftId;
|
||||
@SerializedName("giftNum")
|
||||
private int giftNum;
|
||||
|
||||
public String getUname() {
|
||||
return uname;
|
||||
}
|
||||
|
||||
public void setUname(String uname) {
|
||||
this.uname = uname;
|
||||
}
|
||||
|
||||
public String getFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
public void setFace(String face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public String getGiftName() {
|
||||
return giftName;
|
||||
}
|
||||
|
||||
public void setGiftName(String giftName) {
|
||||
this.giftName = giftName;
|
||||
}
|
||||
|
||||
public String getGiftId() {
|
||||
return giftId;
|
||||
}
|
||||
|
||||
public void setGiftId(String giftId) {
|
||||
this.giftId = giftId;
|
||||
}
|
||||
|
||||
public int getGiftNum() {
|
||||
return giftNum;
|
||||
}
|
||||
|
||||
public void setGiftNum(int giftNum) {
|
||||
this.giftNum = giftNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.hiczp.bilibili.api.live.socket.event;
|
||||
|
||||
import com.hiczp.bilibili.api.live.socket.entity.TVEndEntity;
|
||||
|
||||
public class TVEndPackageEvent extends ReceiveDataPackageEvent<TVEndEntity> {
|
||||
public TVEndPackageEvent(Object source, TVEndEntity entity) {
|
||||
super(source, entity);
|
||||
}
|
||||
}
|
@ -139,6 +139,10 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
|
||||
eventCreationExpression = () -> new GuardMsgPackageEvent(this, GSON.fromJson(content, GuardMsgEntity.class));
|
||||
}
|
||||
break;
|
||||
case "TV_END": {
|
||||
eventCreationExpression = () -> new TVEndPackageEvent(this, GSON.fromJson(content, TVEndEntity.class));
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
LOGGER.error("Received unknown json below: \n{}", formatJson(content));
|
||||
eventCreationExpression = () -> new UnknownPackageEvent(this, content);
|
||||
|
@ -129,7 +129,7 @@ public class LiveClientTest {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void SysGift(SysGiftPackageEvent sysGiftPackageEvent) {
|
||||
public void sysGift(SysGiftPackageEvent sysGiftPackageEvent) {
|
||||
SysGiftEntity sysGiftEntity = sysGiftPackageEvent.getEntity();
|
||||
LOGGER.info("[SysGift] {}: {}",
|
||||
sysGiftEntity.getMsg(),
|
||||
@ -138,7 +138,7 @@ public class LiveClientTest {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void SysMsg(SysMsgPackageEvent sysMsgPackageEvent) {
|
||||
public void sysMsg(SysMsgPackageEvent sysMsgPackageEvent) {
|
||||
SysMsgEntity sysMsgEntity = sysMsgPackageEvent.getEntity();
|
||||
LOGGER.info("[SysMsg] {}: {}",
|
||||
sysMsgEntity.getMsg(),
|
||||
@ -147,21 +147,16 @@ public class LiveClientTest {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void ViewerCount(ViewerCountPackageEvent viewerCountPackageEvent) {
|
||||
LOGGER.info("[ViewerCount] {}", viewerCountPackageEvent.getViewerCount());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void WelcomeGuard(WelcomeGuardPackageEvent welcomeGuardPackageEvent) {
|
||||
WelcomeGuardEntity.DataEntity dataEntity = welcomeGuardPackageEvent.getEntity().getData();
|
||||
LOGGER.info("[WelcomeGuard] [GL {}] {}",
|
||||
dataEntity.getGuardLevel(),
|
||||
dataEntity.getUsername()
|
||||
public void tvEnd(TVEndPackageEvent tvEndPackageEvent) {
|
||||
TVEndEntity tvEndEntity = tvEndPackageEvent.getEntity();
|
||||
LOGGER.info("[TVEnd] user {} win the {}",
|
||||
tvEndEntity.getData().getUname(),
|
||||
tvEndEntity.getData().getType()
|
||||
);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void Welcome(WelcomePackageEvent welcomePackageEvent) {
|
||||
public void welcome(WelcomePackageEvent welcomePackageEvent) {
|
||||
WelcomeEntity.DataEntity dataEntity = welcomePackageEvent.getEntity().getData();
|
||||
StringBuilder stringBuilder = new StringBuilder("[Welcome] ");
|
||||
if (dataEntity.isAdmin()) {
|
||||
@ -171,5 +166,19 @@ public class LiveClientTest {
|
||||
.append(dataEntity.getUserName());
|
||||
LOGGER.info(stringBuilder.toString());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void welcomeGuard(WelcomeGuardPackageEvent welcomeGuardPackageEvent) {
|
||||
WelcomeGuardEntity.DataEntity dataEntity = welcomeGuardPackageEvent.getEntity().getData();
|
||||
LOGGER.info("[WelcomeGuard] [GL {}] {}",
|
||||
dataEntity.getGuardLevel(),
|
||||
dataEntity.getUsername()
|
||||
);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void viewerCount(ViewerCountPackageEvent viewerCountPackageEvent) {
|
||||
LOGGER.info("[ViewerCount] {}", viewerCountPackageEvent.getViewerCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user