diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Live.java b/src/main/java/com/yutou/bilibili/BiliBili/Live.java index cd4215d..1cfb8d0 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/Live.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/Live.java @@ -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); diff --git a/src/main/java/com/yutou/bilibili/BiliBili/LiveController.java b/src/main/java/com/yutou/bilibili/BiliBili/LiveController.java index 0d6b808..51e0243 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/LiveController.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/LiveController.java @@ -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); - } + live=new Live(); + live.add(data.getRoomid(), !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json")))); } } else { if (live != null) { diff --git a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java index 56005eb..d865b9c 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java @@ -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); diff --git a/src/main/java/com/yutou/bilibili/BilibiliApplication.java b/src/main/java/com/yutou/bilibili/BilibiliApplication.java index 7816b80..39bf88d 100644 --- a/src/main/java/com/yutou/bilibili/BilibiliApplication.java +++ b/src/main/java/com/yutou/bilibili/BilibiliApplication.java @@ -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(); diff --git a/src/main/java/com/yutou/bilibili/QQBot/QQBotManager.java b/src/main/java/com/yutou/bilibili/QQBot/QQBotManager.java index 813b889..6a3b50c 100644 --- a/src/main/java/com/yutou/bilibili/QQBot/QQBotManager.java +++ b/src/main/java/com/yutou/bilibili/QQBot/QQBotManager.java @@ -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 diff --git a/src/main/java/com/yutou/bilibili/Test/TestController.java b/src/main/java/com/yutou/bilibili/Test/TestController.java index 5fc25f7..d4ec070 100644 --- a/src/main/java/com/yutou/bilibili/Test/TestController.java +++ b/src/main/java/com/yutou/bilibili/Test/TestController.java @@ -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); diff --git a/src/main/java/com/yutou/bilibili/Tools/ApplicationInit.java b/src/main/java/com/yutou/bilibili/Tools/ApplicationInit.java index dfc757b..58aaab5 100644 --- a/src/main/java/com/yutou/bilibili/Tools/ApplicationInit.java +++ b/src/main/java/com/yutou/bilibili/Tools/ApplicationInit.java @@ -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); - } + live = new Live(); + live.add(info.getRoomid(), !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json")))); } } }