init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.yutou.bilibili.BiliBili;
|
||||
|
||||
import com.yutou.bilibili.BiliBili.Tools.SaveLive;
|
||||
import com.yutou.bilibili.Tools.AppTools;
|
||||
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Timer;
|
||||
|
||||
public class LiveController {
|
||||
private static LiveController controller;
|
||||
private Timer timer;
|
||||
|
||||
public static LiveController getInstance() {
|
||||
if (controller == null) {
|
||||
controller = new LiveController();
|
||||
}
|
||||
return controller;
|
||||
}
|
||||
|
||||
private LiveController() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
}
|
||||
|
||||
public void updateUpInfo(BilibiliUpInfo data) {
|
||||
Live live = LiveUtils.liveContains(data);
|
||||
if (live != null) {
|
||||
live.setSaveDanmo(data.getSavedanmu() == 1);
|
||||
boolean saveLive=SaveLive.getInstance().checkLive(data.getRoomid());
|
||||
if(data.getSavelive()==1){
|
||||
if(!saveLive){
|
||||
SaveLive.getInstance().addLive(live);
|
||||
}
|
||||
}else{
|
||||
if(saveLive){
|
||||
SaveLive.getInstance().stop(data.getRoomid());
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (live != null) {
|
||||
live.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user