50 lines
1.6 KiB
Java
50 lines
1.6 KiB
Java
package com.yutou.bilibili.Controllers;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
|
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
|
|
import com.yutou.bilibili.datas.ResultData;
|
|
import com.yutou.bilibili.datas.ReturnCode;
|
|
import com.yutou.bilibili.services.LiveDatabasesService;
|
|
import com.yutou.bilibili.services.LiveVideoDownloadService;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import java.util.List;
|
|
|
|
@Controller
|
|
public class LiveVideoController {
|
|
@Resource
|
|
LiveVideoDownloadService videoService;
|
|
@Resource
|
|
LiveDatabasesService databasesService;
|
|
|
|
@RequestMapping("/live/video/list")
|
|
@ResponseBody
|
|
public JSONObject getLiveVideoList() {
|
|
return ResultData.success(videoService.getDownloadTasks());
|
|
}
|
|
|
|
@RequestMapping("/live/video/stop")
|
|
@ResponseBody
|
|
public JSONObject stopDownload(String roomId) {
|
|
videoService.stop(roomId, true);
|
|
return ResultData.success(true);
|
|
}
|
|
|
|
@RequestMapping("/live/video/start")
|
|
@ResponseBody
|
|
public JSONObject startDownload(String roomId) {
|
|
List<LiveConfigDatabaseBean> list = databasesService.getConfigDatabase().getAllConfig();
|
|
for (LiveConfigDatabaseBean bean : list) {
|
|
if (bean.getRoomId().toString().equals(roomId)) {
|
|
videoService.start(bean, true);
|
|
return ResultData.success(true);
|
|
}
|
|
}
|
|
return ResultData.fail(ReturnCode.RC999);
|
|
}
|
|
}
|