update
This commit is contained in:
@@ -37,9 +37,9 @@ public class LiveAnchorInfo {
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
@JSONField(name = "room_id")
|
||||
private BigInteger roomId;
|
||||
private String roomId;
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
@JSONField(name = "online")
|
||||
private int online;
|
||||
@JSONField(name = "live_time")
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Objects;
|
||||
@Data
|
||||
public class LiveRoomConfig {
|
||||
String loginUid;
|
||||
BigInteger roomId;
|
||||
String roomId;
|
||||
String anchorName;
|
||||
boolean isLogin;
|
||||
String rootPath="live";
|
||||
@@ -44,7 +44,7 @@ public class LiveRoomConfig {
|
||||
|
||||
public static LiveRoomConfig buildConfig(String roomId){
|
||||
BiliLiveConfigDatabase database = new BiliLiveConfigDatabase();
|
||||
LiveConfigDatabaseBean bean = database.getConfig(new BigInteger(roomId));
|
||||
LiveConfigDatabaseBean bean = database.getConfig(new String(roomId));
|
||||
|
||||
LiveRoomConfig config = new LiveRoomConfig();
|
||||
config.setLoginUid(bean.getRecordUid());
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.util.List;
|
||||
@Data
|
||||
public class LiveRoomInfo {
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
|
||||
@JSONField(name = "room_id")
|
||||
private BigInteger roomId;
|
||||
private String roomId;
|
||||
|
||||
@JSONField(name = "short_id")
|
||||
private int shortId;
|
||||
|
||||
@@ -12,13 +12,13 @@ import java.util.List;
|
||||
@Data
|
||||
public class LiveRoomPlayInfo extends BaseBean {
|
||||
@JSONField(name = "room_id")
|
||||
private BigInteger roomId;
|
||||
private String roomId;
|
||||
|
||||
@JSONField(name = "short_id")
|
||||
private int shortId;
|
||||
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
|
||||
@JSONField(name = "is_hidden")
|
||||
private boolean isHidden;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LiveRoomStatus {
|
||||
private int online;
|
||||
|
||||
@JSONField(name = "roomid")
|
||||
private BigInteger roomid;
|
||||
private String roomid;
|
||||
|
||||
@JSONField(name = "broadcast_type")
|
||||
private int broadcastType;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MasterInfoBean extends BaseBean {
|
||||
@Data
|
||||
public static class Info {
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
|
||||
@JSONField(name = "uname")
|
||||
private String uname;
|
||||
|
||||
@@ -2,12 +2,17 @@ package com.yutou.biliapi.bean.live.database;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.util.DateUtils;
|
||||
import com.yutou.bilibili.Tools.DateFormatUtils;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.yutou.common.utils.Log;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -18,9 +23,9 @@ import static com.alibaba.fastjson2.util.DateUtils.DateTimeFormatPattern.DATE_FO
|
||||
@Data
|
||||
public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "live_room_id")
|
||||
private BigInteger roomId;
|
||||
private String roomId;
|
||||
@JSONField(name = "anchorUid")
|
||||
private BigInteger anchorUid;
|
||||
private String anchorUid;
|
||||
@JSONField(name = "anchorName")
|
||||
private String anchorName;
|
||||
@JSONField(name = "anchorFace")
|
||||
@@ -31,6 +36,8 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
private boolean isRecordDanmu;
|
||||
@JSONField(name = "keyword")
|
||||
private List<String> keywordList;
|
||||
@JSONField(name = "week")
|
||||
private List<String> weeks;
|
||||
@JSONField(name = "recordPath")
|
||||
private String recordPath = "live";
|
||||
@JSONField(name = "recordUid")
|
||||
@@ -38,9 +45,9 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "recordLiveModel")
|
||||
private int recordLiveModel;//0 - ffmpeg 1 - java
|
||||
@JSONField(name = "recordDanmuDate")
|
||||
private String recordDanmuDate = "* * *";// * * * 分 时 星期 | 周日是1
|
||||
private String recordDanmuDate = null;// 时间范围 20:00:00 - 23:59:59
|
||||
@JSONField(name = "recordLiveDate")
|
||||
private String recordLiveDate = "* * *";// * * * 分 时 星期 | 周日是1
|
||||
private String recordLiveDate = null;// 时间范围 20:00:00 - 23:59:59
|
||||
|
||||
|
||||
public LiveConfigDatabaseBean() {
|
||||
@@ -64,55 +71,42 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
}
|
||||
|
||||
private boolean verifyTimer(String val) {
|
||||
int _length = val.length();
|
||||
boolean isFullDate = (_length - val.replace("*", "").length()) == 3
|
||||
&& (_length - val.replace("*", "").trim().length()) == 0;
|
||||
String[] split = val.split(" ");
|
||||
if (isFullDate) {
|
||||
return true;
|
||||
}
|
||||
String minute = split[0];
|
||||
String hour = split[1];
|
||||
String day = split[2];
|
||||
String t = "20:00:00 - 23:59:59";
|
||||
try {
|
||||
Integer.parseInt(minute);
|
||||
Integer.parseInt(hour);
|
||||
Integer.parseInt(day);
|
||||
String[] time = val.split(" - ");
|
||||
Date start = DateFormatUtils.parseTimer(time[0]);
|
||||
Date end = DateFormatUtils.parseTimer(time[1]);
|
||||
if (start != null && end != null) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
Log.e(e);
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkRecordTime(String recordDate) {
|
||||
int _length = recordDate.length();
|
||||
boolean isFullDate = (_length - recordDate.replace("*", "").length()) == 3;
|
||||
if (isFullDate) {
|
||||
return true;
|
||||
}
|
||||
String[] split = recordDate.split(" ");
|
||||
String minute = split[0];
|
||||
String hour = split[1];
|
||||
String day = split[2];
|
||||
boolean isFullMinute = "*".equals(minute);
|
||||
boolean isFullHour = "*".equals(hour);
|
||||
boolean isFullDay = "*".equals(day);
|
||||
Calendar today = Calendar.getInstance();
|
||||
if (!isFullDay) {
|
||||
if (today.get(Calendar.DAY_OF_WEEK) != Integer.parseInt(day) + 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isFullHour) {
|
||||
if (today.get(Calendar.HOUR_OF_DAY) != Integer.parseInt(hour)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isFullMinute) {
|
||||
if (today.get(Calendar.MINUTE) != Integer.parseInt(minute)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
//TODO 待测试
|
||||
String[] parts = recordDate.split(" - ");
|
||||
LocalTime startTime = LocalTime.parse(parts[0], DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
LocalTime endTime = LocalTime.parse(parts[1], DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
|
||||
|
||||
// 获取当前时间
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
|
||||
// 获取当前日期对应的星期几(1-7分别对应周一到周日)
|
||||
int currentWeekDay = currentDate.getDayOfWeek().getValue();
|
||||
|
||||
// 判断当前日期是否在指定的星期列表中
|
||||
boolean isSpecifiedWeekDay = weeks.contains(String.valueOf(currentWeekDay));
|
||||
|
||||
|
||||
// 判断当前时间是否在指定的时间范围内
|
||||
boolean isWithinRange = (currentTime.isAfter(startTime) || currentTime.equals(startTime)) &&
|
||||
(currentTime.isBefore(endTime) || currentTime.equals(endTime));
|
||||
return isWithinRange && isSpecifiedWeekDay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class LiveDanmuDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "time")
|
||||
private long time;
|
||||
@JSONField(name = "uid")
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
@JSONField(name = "uname")
|
||||
private String uname;
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ public class LiveInfoDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "id")
|
||||
int id;
|
||||
@JSONField(name = "roomId")
|
||||
private BigInteger roomId;
|
||||
private String roomId;
|
||||
@JSONField(name = "anchorUid")
|
||||
private BigInteger anchorUid;
|
||||
private String anchorUid;
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
@JSONField(name = "record_time_start")
|
||||
|
||||
@@ -32,7 +32,7 @@ public class UserInfoBean extends BaseBean {
|
||||
private LevelInfo levelInfo;
|
||||
|
||||
@JSONField(name = "mid")
|
||||
private BigInteger mid;
|
||||
private String mid;
|
||||
|
||||
@JSONField(name = "mobile_verified")
|
||||
private int mobileVerified;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class WSDanmuData extends WSData {
|
||||
private long time;
|
||||
private String uCode;
|
||||
private String danmu;
|
||||
private BigInteger uid;
|
||||
private String uid;
|
||||
private String uname;
|
||||
private WSUserMedal medal;
|
||||
|
||||
@@ -36,7 +36,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).getFirst().toString());
|
||||
setUname(infoData.getJSONArray(2).getString(1));
|
||||
try {
|
||||
medal = WSUserMedal.create(infoData.getJSONArray(3));
|
||||
|
||||
@@ -61,7 +61,7 @@ public class BiliBiliLoginDatabase extends SQLiteManager {
|
||||
return list.getFirst();
|
||||
}
|
||||
for (LoginUserDatabaseBean bean : list) {
|
||||
if (bean.getUserInfo().getMid().equals(new BigInteger(userId))) {
|
||||
if (bean.getUserInfo().getMid().equals(new String(userId))) {
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
|
||||
update(bean);
|
||||
}
|
||||
|
||||
public LiveConfigDatabaseBean getConfig(BigInteger roomId) {
|
||||
public LiveConfigDatabaseBean getConfig(String roomId) {
|
||||
List<LiveConfigDatabaseBean> list = get(getDataBean().get(0).getTableName(), LiveConfigDatabaseBean.class);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
@@ -54,7 +54,7 @@ public class BiliLiveConfigDatabase extends SQLiteManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean deleteConfig(BigInteger roomId) {
|
||||
public boolean deleteConfig(String roomId) {
|
||||
LiveConfigDatabaseBean config = getConfig(roomId);
|
||||
if (config == null) {
|
||||
return false;
|
||||
|
||||
@@ -44,18 +44,18 @@ public class BiliLiveNetApiManager extends BaseApi {
|
||||
return createApi(LiveApi.class);
|
||||
}
|
||||
|
||||
public Map<BigInteger, LiveAnchorInfo> getAnchorInfos(String loginUid,List<BigInteger> anchorIds) {
|
||||
public Map<String, LiveAnchorInfo> getAnchorInfos(String loginUid,List<BigInteger> anchorIds) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("uids", anchorIds);
|
||||
try {
|
||||
String src = getApi(loginUid).getLiveRoomStatus(json).execute().body().getSrc();
|
||||
json = JSONObject.parseObject(src);
|
||||
if (json.getInteger("code") == 0) {
|
||||
Map<BigInteger, LiveAnchorInfo> map = new HashMap<>();
|
||||
Map<String, LiveAnchorInfo> map = new HashMap<>();
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
for (String key : data.keySet()) {
|
||||
LiveAnchorInfo info = JSONObject.parseObject(data.getString(key), LiveAnchorInfo.class);
|
||||
map.put(new BigInteger(key), info);
|
||||
map.put(key, info);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WebSocketManager {
|
||||
|
||||
public void stopRoom(String roomId, boolean isUser) {
|
||||
LiveRoomConfig roomConfig = new LiveRoomConfig();
|
||||
roomConfig.setRoomId(new BigInteger(roomId));
|
||||
roomConfig.setRoomId(new String(roomId));
|
||||
if (checkRoom(roomConfig)) {
|
||||
roomMap.get(roomConfig).close();
|
||||
roomMap.remove(roomConfig);
|
||||
@@ -278,7 +278,7 @@ public class WebSocketManager {
|
||||
String buvid = BiliUserUtils.getBuvid(BiliBiliLoginDatabase.getInstance().getCookie(roomConfig.getLoginUid()));
|
||||
if (buvid != null) {
|
||||
try {
|
||||
json.put("roomid", roomConfig.getRoomId());
|
||||
json.put("roomid", new BigInteger(roomConfig.getRoomId()));
|
||||
json.put("protover", 3);
|
||||
json.put("buvid", buvid);
|
||||
json.put("platform", "web");
|
||||
|
||||
Reference in New Issue
Block a user