This commit is contained in:
yutou 2021-05-27 10:29:13 +08:00
parent efcb7e5ac2
commit 470d07d416
7 changed files with 16 additions and 25 deletions

View File

@ -98,7 +98,11 @@ public class Live implements ApplicationContextAware {
Live.lives.put(roomId, this);
updateUpInfo();
com.yutou.bilibili.Tools.Log.i("roomId = " + roomId + ", isLogin = " + isLogin);
try {
start();
} catch (Exception e) {
e.printStackTrace();
}
}
private void updateUpInfo() {
@ -126,7 +130,7 @@ public class Live implements ApplicationContextAware {
*
* @throws Exception 发生异常
*/
public void start() throws Exception {
private void start() throws Exception {
run = true;
if (LiveUtils.isLivePlayer(roomId)) {
upData.setLive(1);

View File

@ -44,13 +44,8 @@ public class LiveController {
}
if (data.getEnable()==1||data.getOfflinelistening()==1) {
if (live == null) {
try {
live=new Live();
live.add(data.getRoomid(), !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json"))));
live.start();
} catch (Exception e) {
com.yutou.bilibili.Tools.Log.e(e);
}
}
} else {
if (live != null) {

View File

@ -375,6 +375,9 @@ public class LiveUtils {
}
reloadLiveState(roomId);
return false;*/
if(!Live.lives.containsKey(roomId)){
return false;
}
return Live.lives.get(roomId).geData().getLive()==1;
}
@ -385,11 +388,6 @@ public class LiveUtils {
if (live == null) {
live = new Live();
live.add(roomId, !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json"))));
try {
live.start();
} catch (Exception e) {
com.yutou.bilibili.Tools.Log.e(e);
}
}
if (!SaveLive.getInstance().checkLive(roomId)) {
SaveLive.getInstance().addLive(roomId);

View File

@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import;
@SpringBootApplication
public class BilibiliApplication {
public static String version="0.7.4.4";
public static String version="0.7.4.5";
public static void main(String[] args) {
QQBotManager.getInstance().init();

View File

@ -265,7 +265,7 @@ public class QQBotManager implements ApplicationContextAware {
builder.append("\n");
for (Live live : Live.lives.values()) {
Live.LiveInfo info=live.getLiveInfo();
if (LiveUtils.isLivePlayer(live.getInfo().getRoomid())) {
if (live.geData().getLive()==1) {
builder.append("【直播中】");
}
builder

View File

@ -30,7 +30,7 @@ public class TestController {
JSONObject item=new JSONObject();
item.put("info", JSON.toJSON(live.getInfo()));
item.put("data",JSON.toJSON(live.geData()));
item.put("isLive", LiveUtils.isLivePlayer(live.getInfo().getRoomid()));
item.put("isLive", live.geData().getLive()==1);
array.add(item);
}
json.put("array",array);

View File

@ -99,14 +99,8 @@ public class ApplicationInit implements ApplicationRunner {
if (info.getEnable() == 1) {
Live live = LiveUtils.liveContains(info);
if (live == null) {
try {
live = new Live();
live.add(info.getRoomid(), !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json"))));
live.start();
} catch (Exception e) {
com.yutou.bilibili.Tools.Log.e(e);
}
}
}
}