This commit is contained in:
yutou 2021-04-13 17:38:54 +08:00
parent 633543ab05
commit c0a8478d10
3 changed files with 7 additions and 5 deletions

View File

@ -110,7 +110,7 @@ public class SaveLive {
private String getLiveUrl(int roomId) { private String getLiveUrl(int roomId) {
JSONObject json = LiveUtils.http_get(String.format("https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl?cid=%d&platform=web", roomId)); JSONObject json = LiveUtils.http_get(String.format("https://api.live.bilibili.com/xlive/web-room/v1/playUrl/playUrl?cid=%d&platform=web", roomId));
if (json.getInteger("code") == 0) { if (json != null && json.getInteger("code") == 0) {
return json.getJSONObject("data").getJSONArray("durl").getJSONObject(0).getString("url"); return json.getJSONObject("data").getJSONArray("durl").getJSONObject(0).getString("url");
} else { } else {
return null; return null;
@ -125,6 +125,8 @@ public class SaveLive {
com.yutou.bilibili.Tools.Log.i("开始录制:" + roomId); com.yutou.bilibili.Tools.Log.i("开始录制:" + roomId);
QQBotManager.getInstance().sendMessage(roomId + " 已启动录制"); QQBotManager.getInstance().sendMessage(roomId + " 已启动录制");
HttpURLConnection connection = LiveUtils.getBiliHttpGet(url, LiveUtils.getCookie()); HttpURLConnection connection = LiveUtils.getBiliHttpGet(url, LiveUtils.getCookie());
connection.setReadTimeout(5000);
connection.setConnectTimeout(5000);
heartbeat = new Timer(); heartbeat = new Timer();
//Heartbeat beat = new Heartbeat(); //Heartbeat beat = new Heartbeat();
heartbeat.schedule(new Heartbeat(), 0, 30000); heartbeat.schedule(new Heartbeat(), 0, 30000);

View File

@ -249,7 +249,7 @@ public class QQBotManager implements ApplicationContextAware {
for (Live live : Live.lives) { for (Live live : Live.lives) {
JSONObject liveJson = LiveUtils.LiveInfoManager.getInstance().getInfo(live.getInfo().getRoomid()); JSONObject liveJson = LiveUtils.LiveInfoManager.getInstance().getInfo(live.getInfo().getRoomid());
if(LiveUtils.isLivePlayer(live.getInfo().getRoomid())){ if(LiveUtils.isLivePlayer(live.getInfo().getRoomid())){
builder.append("[直播中]"); builder.append("【直播中】");
} }
builder builder
.append("名字:").append(live.geData().getName()).append(" ") .append("名字:").append(live.geData().getName()).append(" ")

View File

@ -102,7 +102,7 @@ public class ApplicationInit implements ApplicationRunner {
private void checkLive() { private void checkLive() {
for (BilibiliUpInfo info : service.getUpInfo()) { for (BilibiliUpInfo info : service.getUpInfo()) {
if (info.getOfflinelistening() == 1) { if (info.getOfflinelistening() == 1) {
if (info.getLive() == 1) { if (info.getEnable() == 1) {
Live live = LiveUtils.liveContains(info); Live live = LiveUtils.liveContains(info);
if (live == null) { if (live == null) {
try { try {