update
This commit is contained in:
parent
51f961b054
commit
3b190b8a44
@ -119,8 +119,8 @@
|
|||||||
layui.use(['laytpl', 'laypage'], function () {
|
layui.use(['laytpl', 'laypage'], function () {
|
||||||
var laytpl = layui.laytpl;
|
var laytpl = layui.laytpl;
|
||||||
var laypage = layui.laypage;
|
var laypage = layui.laypage;
|
||||||
var pageIndex = 0;
|
var pageIndex = 1;
|
||||||
var pageMax = 8;
|
var pageMax = 16;
|
||||||
var listCount=10;
|
var listCount=10;
|
||||||
var listMax=pageMax;
|
var listMax=pageMax;
|
||||||
var initPage=true;
|
var initPage=true;
|
||||||
@ -150,8 +150,8 @@
|
|||||||
function initPageView(){
|
function initPageView(){
|
||||||
laypage.render({
|
laypage.render({
|
||||||
elem: 'page',
|
elem: 'page',
|
||||||
limit: 8,
|
limit: 16,
|
||||||
curr: pageIndex + 1,
|
curr: pageIndex,
|
||||||
limits: [4, 8, 16, 24, 32, 40],
|
limits: [4, 8, 16, 24, 32, 40],
|
||||||
layout: ['prev', 'page', 'next', 'limit'],
|
layout: ['prev', 'page', 'next', 'limit'],
|
||||||
count: listCount, // 数据总数
|
count: listCount, // 数据总数
|
||||||
|
@ -8,6 +8,9 @@ import com.yutou.common.okhttp.HttpBody;
|
|||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.*;
|
import retrofit2.http.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直播间相关API
|
* 直播间相关API
|
||||||
* <a href="https://socialsisteryi.github.io/bilibili-API-collect/docs/live/info.html#%E8%8E%B7%E5%8F%96%E7%9B%B4%E6%92%AD%E9%97%B4%E4%BF%A1%E6%81%AF">文档地址</a>
|
* <a href="https://socialsisteryi.github.io/bilibili-API-collect/docs/live/info.html#%E8%8E%B7%E5%8F%96%E7%9B%B4%E6%92%AD%E9%97%B4%E4%BF%A1%E6%81%AF">文档地址</a>
|
||||||
@ -55,8 +58,13 @@ public interface LiveApi {
|
|||||||
@GET("/xlive/web-room/v1/giftPanel/giftConfig?platform=pc")
|
@GET("/xlive/web-room/v1/giftPanel/giftConfig?platform=pc")
|
||||||
Call<HttpBody<BaseBean>> getLiveGiftConfig();
|
Call<HttpBody<BaseBean>> getLiveGiftConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询直播间状态
|
||||||
|
* @param uids 要查询的主播 mid
|
||||||
|
* @return <a href="https://socialsisteryi.github.io/bilibili-API-collect/docs/live/info.html#%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E7%9B%B4%E6%92%AD%E9%97%B4%E7%8A%B6%E6%80%81">文档</a>
|
||||||
|
*/
|
||||||
@POST("/room/v1/Room/get_status_info_by_uids")
|
@POST("/room/v1/Room/get_status_info_by_uids")
|
||||||
Call<HttpBody<BaseBean>> getLiveRoomStatus( @Body
|
Call<HttpBody<Map<String,LiveAnchorInfo>>> getLiveRoomStatus(@Body
|
||||||
JSONObject uids);
|
JSONObject uids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yutou.biliapi.databases;
|
package com.yutou.biliapi.databases;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.util.DateUtils;
|
import com.alibaba.fastjson2.util.DateUtils;
|
||||||
import com.yutou.biliapi.bean.live.*;
|
import com.yutou.biliapi.bean.live.*;
|
||||||
import com.yutou.biliapi.bean.live.database.*;
|
import com.yutou.biliapi.bean.live.database.*;
|
||||||
@ -66,7 +67,8 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
new LiveInteractWordDatabaseBean(),
|
new LiveInteractWordDatabaseBean(),
|
||||||
new LiveSuperChatDatabaseBean(),
|
new LiveSuperChatDatabaseBean(),
|
||||||
new LiveSourceDatabaseBean(),
|
new LiveSourceDatabaseBean(),
|
||||||
new LiveVideoDatabaseBean()
|
new LiveVideoDatabaseBean(),
|
||||||
|
new LiveGuardBuyBean()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,19 +138,31 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
}
|
}
|
||||||
return super.get(tableName, where, clazz);
|
return super.get(tableName, where, clazz);
|
||||||
}
|
}
|
||||||
|
public void resetSQL(){
|
||||||
public static void main(String[] args) {
|
|
||||||
BiliLiveDatabase biliLiveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig("5265"));
|
|
||||||
List<AbsDatabasesBean> list = List.of(
|
List<AbsDatabasesBean> list = List.of(
|
||||||
new LiveInfoDatabaseBean(),
|
new LiveInfoDatabaseBean(),
|
||||||
new LiveDanmuDatabaseBean(),
|
new LiveDanmuDatabaseBean(),
|
||||||
new LiveGiftDatabaseBean(),
|
new LiveGiftDatabaseBean(),
|
||||||
|
new LiveGuardBuyBean(),
|
||||||
new LiveInteractWordDatabaseBean(),
|
new LiveInteractWordDatabaseBean(),
|
||||||
new LiveSuperChatDatabaseBean()
|
new LiveSuperChatDatabaseBean()
|
||||||
);
|
);
|
||||||
for (AbsDatabasesBean item : list) {
|
for (AbsDatabasesBean item : list) {
|
||||||
biliLiveDatabase.clearTable(item.getTableName());
|
clearTable(item.getTableName());
|
||||||
}
|
}
|
||||||
|
recreateSql(list);
|
||||||
|
}
|
||||||
|
public void resetData(){
|
||||||
|
List<LiveSourceDatabaseBean> list = get(new LiveSourceDatabaseBean().getTableName(), LiveSourceDatabaseBean.class);
|
||||||
|
for (LiveSourceDatabaseBean item : list) {
|
||||||
|
WSData data = WSData.parse(JSONObject.parseObject(item.getJson()));
|
||||||
|
addData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
BiliLiveDatabase biliLiveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig("5265"));
|
||||||
|
// biliLiveDatabase.resetSQL();
|
||||||
|
biliLiveDatabase.resetData();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ public class VideoFileController {
|
|||||||
public String getTmpImg(String url) {
|
public String getTmpImg(String url) {
|
||||||
try {
|
try {
|
||||||
// 获取图片流
|
// 获取图片流
|
||||||
|
System.out.println("url = " + url);
|
||||||
InputStream inputStream = new URL(url).openStream();
|
InputStream inputStream = new URL(url).openStream();
|
||||||
|
|
||||||
// 将输入流转换为字节数组
|
// 将输入流转换为字节数组
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
package com.yutou.bilibili.services;
|
package com.yutou.bilibili.services;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.yutou.biliapi.api.LiveApi;
|
import com.yutou.biliapi.api.LiveApi;
|
||||||
|
import com.yutou.biliapi.bean.live.LiveAnchorInfo;
|
||||||
import com.yutou.biliapi.bean.live.LiveRoomInfo;
|
import com.yutou.biliapi.bean.live.LiveRoomInfo;
|
||||||
|
import com.yutou.biliapi.bean.live.LiveRoomPlayInfo;
|
||||||
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
||||||
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
|
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
|
||||||
import com.yutou.biliapi.net.BiliLiveNetApiManager;
|
import com.yutou.biliapi.net.BiliLiveNetApiManager;
|
||||||
import com.yutou.bilibili.datas.web.LiveData;
|
import com.yutou.bilibili.datas.web.LiveData;
|
||||||
|
import com.yutou.common.okhttp.BaseBean;
|
||||||
|
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||||
import com.yutou.common.utils.Log;
|
import com.yutou.common.utils.Log;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LiveService {
|
public class LiveService {
|
||||||
@ -32,33 +40,61 @@ public class LiveService {
|
|||||||
return liveConfigDatabase.getAllConfig().size();
|
return liveConfigDatabase.getAllConfig().size();
|
||||||
}
|
}
|
||||||
public List<LiveData> getLiveList(int page,int limit) {
|
public List<LiveData> getLiveList(int page,int limit) {
|
||||||
List<LiveConfigDatabaseBean> allConfig = liveConfigDatabase.getConfigs(page,limit);
|
List<LiveConfigDatabaseBean> allConfig = liveConfigDatabase.getAllConfig();
|
||||||
List<LiveData> liveDataList = new ArrayList<>();
|
List<LiveData> liveDataList = new ArrayList<>();
|
||||||
for (LiveConfigDatabaseBean config : allConfig) {
|
JSONArray uids=new JSONArray();
|
||||||
LiveData liveData = new LiveData();
|
JSONObject param=new JSONObject();
|
||||||
liveData.setRoomId(config.getRoomId());
|
for (LiveConfigDatabaseBean bean : allConfig) {
|
||||||
liveData.setAnchorUid(config.getAnchorUid());
|
uids.add(bean.getAnchorUid());
|
||||||
liveData.setAnchorName(config.getAnchorName());
|
}
|
||||||
liveData.setAnchorFace(config.getAnchorFace());
|
param.put("uids",uids);
|
||||||
liveData.setDownloadVideo(videoDownloadService.checkDownload(config.getRoomId()));
|
try {
|
||||||
liveData.setDanmu(danmuService.check(config.getRoomId()));
|
Map<String, LiveAnchorInfo> map = api.getLiveRoomStatus(param).execute().body().getData();
|
||||||
try {
|
List<LiveAnchorInfo> onlineList = new ArrayList<>();
|
||||||
LiveRoomInfo body = api.getRoomInfo(config.getRoomId()).execute().body().getData();
|
List<LiveAnchorInfo> offlineList = new ArrayList<>();
|
||||||
if (body != null) {
|
for (LiveAnchorInfo info : map.values()) {
|
||||||
liveData.setTitle(body.getTitle());
|
if(info.getLiveStatus()==1){
|
||||||
liveData.setLive(body.getLiveStatus() == 1);
|
onlineList.add(info);
|
||||||
if (body.getLiveStatus() == 1) {
|
}else{
|
||||||
liveData.setCover(body.getKeyframe());
|
offlineList.add(info);
|
||||||
} else {
|
}
|
||||||
liveData.setCover(body.getUserCover());
|
}
|
||||||
}
|
onlineList.addAll(offlineList);
|
||||||
|
int totalSize = onlineList.size();
|
||||||
|
int fromIndex = (page - 1) * limit;
|
||||||
|
int toIndex = Math.min(fromIndex + limit, totalSize);
|
||||||
|
if (fromIndex >= totalSize) {
|
||||||
|
return new ArrayList<>(); // 返回空列表
|
||||||
|
}
|
||||||
|
List<LiveAnchorInfo> list = onlineList.subList(fromIndex, toIndex);
|
||||||
|
for (LiveAnchorInfo info : list) {
|
||||||
|
LiveData liveData = new LiveData();
|
||||||
|
liveData.setRoomId(info.getRoomId());
|
||||||
|
liveData.setAnchorUid(info.getUid());
|
||||||
|
liveData.setAnchorName(info.getUname());
|
||||||
|
liveData.setAnchorFace(info.getFace());
|
||||||
|
liveData.setDownloadVideo(videoDownloadService.checkDownload(info.getRoomId()));
|
||||||
|
liveData.setDanmu(danmuService.check(info.getRoomId()));
|
||||||
|
liveData.setTitle(info.getTitle());
|
||||||
|
liveData.setLive(info.getLiveStatus() == 1);
|
||||||
|
if (info.getLiveStatus() == 1 && StringUtils.hasText(info.getKeyframe())) {
|
||||||
|
liveData.setCover(info.getKeyframe());
|
||||||
|
} else {
|
||||||
|
liveData.setCover(info.getCoverFromUser());
|
||||||
}
|
}
|
||||||
liveDataList.add(liveData);
|
liveDataList.add(liveData);
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
liveDataList.sort(Comparator.comparing(LiveData::isLive).reversed());
|
|
||||||
return liveDataList;
|
return liveDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
HttpLoggingInterceptor.setLog(true);
|
||||||
|
LiveService service=new LiveService();
|
||||||
|
List<LiveData> data = service.getLiveList(1, 16);
|
||||||
|
System.out.println(data.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,17 @@ public class LiveVideoDownloadService {
|
|||||||
config.setRoomInfo(roomInfo);
|
config.setRoomInfo(roomInfo);
|
||||||
config.setRootPath(bean.getRecordPath());
|
config.setRootPath(bean.getRecordPath());
|
||||||
database = new BiliLiveDatabase(config);
|
database = new BiliLiveDatabase(config);
|
||||||
HttpDownloadUtils.download(new HttpDownloadUtils.Builder().setUrl(roomInfo.getKeyframe())
|
try {
|
||||||
.setPath(rootPath.getAbsolutePath())
|
var keyframe = roomInfo.getKeyframe();
|
||||||
.setFileName("poster.jpg"));
|
if(!StringUtils.hasText(keyframe)){
|
||||||
LiveInfoNfoTools.saveLiveInfoNfo(roomInfo, rootPath.getAbsolutePath(), new File(savePath).getName().replace(".flv", ".nfo"));
|
keyframe= roomInfo.getUserCover();
|
||||||
|
}
|
||||||
|
HttpDownloadUtils.download(new HttpDownloadUtils.Builder().setUrl(keyframe)
|
||||||
|
.setPath(rootPath.getAbsolutePath())
|
||||||
|
.setFileName("poster.jpg"));
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
saveLiveInfo(roomInfo);
|
saveLiveInfo(roomInfo);
|
||||||
api.getLiveRoomPlayInfo(
|
api.getLiveRoomPlayInfo(
|
||||||
bean.getRoomId().toString(),
|
bean.getRoomId().toString(),
|
||||||
@ -292,6 +299,8 @@ public class LiveVideoDownloadService {
|
|||||||
videoDatabaseBean.setRoomInfoJson(JSONObject.toJSONString(roomInfo));
|
videoDatabaseBean.setRoomInfoJson(JSONObject.toJSONString(roomInfo));
|
||||||
videoDatabaseBean.setStartTime(new Date());
|
videoDatabaseBean.setStartTime(new Date());
|
||||||
database.addLiveInfo(videoDatabaseBean);
|
database.addLiveInfo(videoDatabaseBean);
|
||||||
|
LiveInfoNfoTools.saveLiveInfoNfo(roomInfo, rootPath.getAbsolutePath(), new File(savePath).getName().replace(".flv", ".nfo"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ public abstract class SQLiteManager {
|
|||||||
|
|
||||||
public abstract String getFileName();
|
public abstract String getFileName();
|
||||||
|
|
||||||
public void init() {
|
private BuildSql createBuildSQL(List<AbsDatabasesBean> data){
|
||||||
List<AbsDatabasesBean> data = getDataBean();
|
|
||||||
List<BuildSqlItem> items;
|
List<BuildSqlItem> items;
|
||||||
List<BuildSqlTable> tables = new ArrayList<>();
|
List<BuildSqlTable> tables = new ArrayList<>();
|
||||||
for (AbsDatabasesBean bean : data) {
|
for (AbsDatabasesBean bean : data) {
|
||||||
@ -62,12 +61,17 @@ public abstract class SQLiteManager {
|
|||||||
tables.add(BuildSqlTable.create().setName(bean.getTableName()).setItem(items));
|
tables.add(BuildSqlTable.create().setName(bean.getTableName()).setItem(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildSql sql = BuildSql.create()
|
return BuildSql.create()
|
||||||
.setFileName(getFileName())
|
.setFileName(getFileName())
|
||||||
.setTable(tables);
|
.setTable(tables);
|
||||||
build(sql);
|
}
|
||||||
|
public void init() {
|
||||||
|
build(createBuildSQL(getDataBean()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void recreateSql(List<AbsDatabasesBean> beans){
|
||||||
|
createSql(createBuildSQL(beans));
|
||||||
|
}
|
||||||
|
|
||||||
public void startBatch() {
|
public void startBatch() {
|
||||||
try {
|
try {
|
||||||
@ -156,6 +160,13 @@ public abstract class SQLiteManager {
|
|||||||
protected <T extends AbsDatabasesBean> void update(T t) {
|
protected <T extends AbsDatabasesBean> void update(T t) {
|
||||||
try {
|
try {
|
||||||
String id = DateUtils.format(t.getSql_time(), "yyyy-MM-dd HH:mm:ss.SSS");
|
String id = DateUtils.format(t.getSql_time(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
if(id.endsWith("0")){
|
||||||
|
id=id.substring(0,id.length()-1);
|
||||||
|
}else if(id.endsWith("00")){
|
||||||
|
id=id.substring(0,id.length()-2);
|
||||||
|
}else if(id.endsWith("000")){
|
||||||
|
id=id.substring(0,id.length()-4);
|
||||||
|
}
|
||||||
Statement statement = conn.createStatement();
|
Statement statement = conn.createStatement();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("UPDATE `").append(t.getTableName()).append("` ");
|
sb.append("UPDATE `").append(t.getTableName()).append("` ");
|
||||||
@ -294,7 +305,7 @@ public abstract class SQLiteManager {
|
|||||||
*/
|
*/
|
||||||
public void clearTable(String tableName) {
|
public void clearTable(String tableName) {
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM " + tableName;
|
String sql = "DROP TABLE IF EXISTS " + tableName;
|
||||||
try (Statement stmt = conn.createStatement()) {
|
try (Statement stmt = conn.createStatement()) {
|
||||||
int rowsDeleted = stmt.executeUpdate(sql);
|
int rowsDeleted = stmt.executeUpdate(sql);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user