update
This commit is contained in:
@@ -39,6 +39,11 @@ public class LiveDanmuController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/live/danmu/file/list")
|
||||
public JSONObject getDanmuList(String roomId) {
|
||||
return ResultData.success(service.getDanmuFileList(roomId));
|
||||
return ResultData.success(ReturnCode.RC100);
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/live/danmu/get")
|
||||
public JSONObject getDanmu(String roomId,String videoId,String startTimer,long step) {
|
||||
return ResultData.success(ReturnCode.RC100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,8 @@ public class VideoFileController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/file/list")
|
||||
public JSONObject getFileList(int page,int limit,String roomId) {
|
||||
List<VideoFilePath> list;
|
||||
if (StringUtils.hasText(roomId)) {
|
||||
list = videoService.getVideoPath(roomId);
|
||||
} else {
|
||||
list = videoService.getAllVideoPath(page,limit);
|
||||
}
|
||||
return ResultData.success(list);
|
||||
public JSONObject getFileList(int page, int limit, String roomId) {
|
||||
return ResultData.success(videoService.getVideoPath(roomId));
|
||||
}
|
||||
|
||||
@RequestMapping("/file/{base64}")
|
||||
@@ -74,6 +68,7 @@ public class VideoFileController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/file/imgTmp", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String getTmpImg(String url) {
|
||||
@@ -105,4 +100,9 @@ public class VideoFileController {
|
||||
return "";
|
||||
}
|
||||
|
||||
@RequestMapping("/video/play")
|
||||
@ResponseBody
|
||||
public JSONObject getVideoUrl(String roomId, String videoId) {
|
||||
return ResultData.success("/play/"+videoService.getVideoPlay(roomId, videoId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ public class DateFormatUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static String parseString(String date,String format){
|
||||
Date time = parse(date, format);
|
||||
return format(time,format);
|
||||
}
|
||||
|
||||
public static boolean checkTime(List<String> weeks, String recordDate) {
|
||||
if (!StringUtils.hasText(recordDate)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.yutou.bilibili.datas;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class VideoFilePath {
|
||||
@@ -12,5 +13,5 @@ public class VideoFilePath {
|
||||
private String path;
|
||||
private String cover;
|
||||
private boolean isParent;
|
||||
private List<VideoFilePath> children;
|
||||
private Map<String, List<VideoFilePath>> children;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.yutou.bilibili.services;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.bean.live.LiveRoomConfig;
|
||||
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
||||
import com.yutou.biliapi.bean.live.database.LiveDanmuDatabaseBean;
|
||||
import com.yutou.biliapi.bean.live.database.LiveVideoDatabaseBean;
|
||||
import com.yutou.biliapi.bean.websocket.live.WSData;
|
||||
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
|
||||
import com.yutou.biliapi.databases.BiliLiveDatabase;
|
||||
import com.yutou.biliapi.net.WebSocketManager;
|
||||
@@ -44,7 +46,7 @@ public class LiveDanmuService {
|
||||
|
||||
public List<File> getDanmuFileList(String roomId) {
|
||||
BiliLiveConfigDatabase configDatabase=new BiliLiveConfigDatabase();
|
||||
LiveConfigDatabaseBean bean = configDatabase.getConfig(new String(roomId));
|
||||
LiveConfigDatabaseBean bean = configDatabase.getConfig(roomId);
|
||||
configDatabase.close();
|
||||
return Tools.scanFile(new File(bean.getRecordPath() + File.separator + bean.getAnchorName()));
|
||||
}
|
||||
@@ -76,12 +78,12 @@ public class LiveDanmuService {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LiveDanmuService service = new LiveDanmuService();
|
||||
List<File> files = service.getDanmuFileList("22047448");
|
||||
for (File file : files) {
|
||||
Log.i(file);
|
||||
BiliLiveDatabase database = new BiliLiveDatabase(LiveRoomConfig.buildConfig("17961"));
|
||||
for (LiveVideoDatabaseBean info : database.getLiveInfos()) {
|
||||
System.out.println(info);
|
||||
}
|
||||
|
||||
WSData data = WSData.parse(JSONObject.parseObject("{\"cmd\":\"GUARD_BUY\",\"data\":{\"uid\":290721462,\"username\":\"BG7NOE型大地鱼干\",\"guard_level\":3,\"num\":1,\"price\":198000,\"gift_id\":10003,\"gift_name\":\"舰长\",\"start_time\":1730462544,\"end_time\":1730462544}}"));
|
||||
System.out.println(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -299,26 +299,14 @@ public class LiveVideoDownloadService {
|
||||
|
||||
}
|
||||
|
||||
public List<VideoFilePath> getAllVideoPath(int page, int limit) {
|
||||
BiliLiveConfigDatabase configDatabase = new BiliLiveConfigDatabase();
|
||||
List<LiveConfigDatabaseBean> list = configDatabase.getConfigs(page, limit);
|
||||
configDatabase.close();
|
||||
List<VideoFilePath> filePathList = new ArrayList<>();
|
||||
for (LiveConfigDatabaseBean bean : list) {
|
||||
filePathList.addAll(getVideoFilePath(bean));
|
||||
}
|
||||
return filePathList;
|
||||
}
|
||||
|
||||
public List<VideoFilePath> getVideoPath(String roomId) {
|
||||
public VideoFilePath getVideoPath(String roomId) {
|
||||
BiliLiveConfigDatabase configDatabase = new BiliLiveConfigDatabase();
|
||||
LiveConfigDatabaseBean bean = configDatabase.getConfig(roomId);
|
||||
configDatabase.close();
|
||||
return new ArrayList<>(getVideoFilePath(bean));
|
||||
return getVideoFilePath(bean);
|
||||
}
|
||||
|
||||
private List<VideoFilePath> getVideoFilePath(LiveConfigDatabaseBean configBean) {
|
||||
List<VideoFilePath> filePathList = new ArrayList<>();
|
||||
private VideoFilePath getVideoFilePath(LiveConfigDatabaseBean configBean) {
|
||||
String recordPath = configBean.getRecordPath() + File.separator + configBean.getAnchorName();
|
||||
File recordDir = new File(recordPath);
|
||||
BiliLiveDatabase database = new BiliLiveDatabase(LiveRoomConfig.buildConfig(configBean.getRoomId()), recordDir.getAbsolutePath());
|
||||
@@ -328,8 +316,7 @@ public class LiveVideoDownloadService {
|
||||
database.close();
|
||||
path.setChildren(getVideoInfo(infos));
|
||||
}
|
||||
filePathList.add(path);
|
||||
return filePathList;
|
||||
return path;
|
||||
}
|
||||
|
||||
private VideoFilePath createVideoRootFilePath(LiveConfigDatabaseBean config, File db) {
|
||||
@@ -343,27 +330,59 @@ public class LiveVideoDownloadService {
|
||||
return path;
|
||||
}
|
||||
|
||||
private List<VideoFilePath> getVideoInfo(List<LiveVideoDatabaseBean> videoList) {
|
||||
List<VideoFilePath> filePathList = new ArrayList<>();
|
||||
private Map<String, List<VideoFilePath>> getVideoInfo(List<LiveVideoDatabaseBean> videoList) {
|
||||
Map<String, List<VideoFilePath>> map = new HashMap<>();
|
||||
for (LiveVideoDatabaseBean bean : videoList) {
|
||||
String date = DateFormatUtils.format(bean.getSql_time(), "yyyy-MM-dd");
|
||||
if (!map.containsKey(date)) {
|
||||
map.put(date, new ArrayList<>());
|
||||
}
|
||||
VideoFilePath path = new VideoFilePath();
|
||||
LiveRoomInfo roomInfo = JSONObject.parseObject(bean.getRoomInfoJson(), LiveRoomInfo.class);
|
||||
path.setRoomId(roomInfo.getRoomId());
|
||||
path.setName(roomInfo.getTitle());
|
||||
path.setUid(roomInfo.getUid());
|
||||
path.setPath(DateFormatUtils.format(bean.getSql_time()));
|
||||
path.setPath(String.valueOf(bean.getSql_time().getTime()));
|
||||
path.setCover(roomInfo.getKeyframe());
|
||||
path.setParent(false);
|
||||
path.setChildren(null);
|
||||
filePathList.add(path);
|
||||
map.get(date).add(path);
|
||||
}
|
||||
return filePathList;
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getVideoPlay(String roomId, String videoId) {
|
||||
String ffmpegPath = ConfigTools.load(ConfigTools.CONFIG, "ffmpeg", String.class);
|
||||
BiliLiveConfigDatabase configDatabase = new BiliLiveConfigDatabase();
|
||||
LiveConfigDatabaseBean config = configDatabase.getConfig(roomId);
|
||||
String recordPath = config.getRecordPath() + File.separator + config.getAnchorName();
|
||||
configDatabase.close();
|
||||
LiveVideoDatabaseBean videoInfo = null;
|
||||
BiliLiveDatabase liveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig(roomId), new File(recordPath).getAbsolutePath());
|
||||
for (LiveVideoDatabaseBean info : liveDatabase.getLiveInfos()) {
|
||||
if (videoId.trim().equals(String.valueOf(info.getSql_time().getTime()))) {
|
||||
videoInfo = info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(videoInfo != null) {
|
||||
FFmpegUtils ffmpeg = FFmpegUtils.segment(videoId, ffmpegPath, new File(videoInfo.getPath()), ConfigTools.load(ConfigTools.CONFIG, "outVideoPath", String.class));
|
||||
System.out.println(ffmpeg.getCommand());
|
||||
ffmpeg.start(new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(File file) {
|
||||
super.onDownload(file);
|
||||
|
||||
}
|
||||
});
|
||||
return ffmpeg.getOutputFilePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LiveVideoDownloadService service = new LiveVideoDownloadService();
|
||||
List<VideoFilePath> path = service.getAllVideoPath(1, 8);
|
||||
Log.i("path.size() = " + path.size());
|
||||
Log.i(JSONArray.toJSONString(path));
|
||||
LiveVideoDownloadService service=new LiveVideoDownloadService();
|
||||
String play = service.getVideoPlay("17961", "1730363029293");
|
||||
System.out.println(play);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user