mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-06-21 06:26:06 +08:00
新增爬虫配置文件构造器
新增斗鱼弹幕爬虫测试类
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package org.example.core.creeper.builder;
|
||||
|
||||
import org.example.bean.Live;
|
||||
import org.example.bean.live.BiliBiliLive;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.core.creeper.loadconfig.BilibiliLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.LoadLiveConfig;
|
||||
import org.example.core.manager.CommonLoadConfigBuilder;
|
||||
import org.example.pool.LiveModuleConstPool;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/09/05 19:18
|
||||
**/
|
||||
public class BiliBiliLiveLoadConfigBuilder extends CommonLoadConfigBuilder<BilibiliLiveOnlineConfig> {
|
||||
@Override
|
||||
public BilibiliLiveOnlineConfig build(Object obj) {
|
||||
if(obj instanceof BiliBiliLive){
|
||||
String liveId = ((BiliBiliLive) obj).getLiveId();
|
||||
String liver = ((BiliBiliLive) obj).getLiver();
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.BILIBILI);
|
||||
BilibiliLiveOnlineConfig bilibiliLiveOnlineConfig = new BilibiliLiveOnlineConfig(liveId, path, LoadLiveConfig.fileName(liveId, liver), true);
|
||||
bilibiliLiveOnlineConfig.setShowDownloadTable(true);
|
||||
bilibiliLiveOnlineConfig.setLiverName(liver);
|
||||
return bilibiliLiveOnlineConfig;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.example.core.creeper.builder;
|
||||
|
||||
import org.example.bean.live.BiliBiliLive;
|
||||
import org.example.bean.live.DouyuLive;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.core.creeper.loadconfig.BilibiliLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.DouyuLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.LoadLiveConfig;
|
||||
import org.example.core.manager.CommonLoadConfigBuilder;
|
||||
import org.example.pool.LiveModuleConstPool;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/09/05 19:27
|
||||
**/
|
||||
public class DouyuLiveLoadConfigBuilder extends CommonLoadConfigBuilder<DouyuLiveOnlineConfig> {
|
||||
|
||||
@Override
|
||||
public DouyuLiveOnlineConfig build(Object obj) {
|
||||
if(obj instanceof DouyuLive){
|
||||
String liveId = ((DouyuLive) obj).getLiveId();
|
||||
String liver = ((DouyuLive) obj).getLiver();
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.BILIBILI);
|
||||
DouyuLiveOnlineConfig douyuLiveOnlineConfig = new DouyuLiveOnlineConfig(liveId, path, LoadLiveConfig.fileName(liveId, liver), true);
|
||||
|
||||
douyuLiveOnlineConfig.setShowDownloadTable(true);
|
||||
douyuLiveOnlineConfig.setLiverName(liver);
|
||||
return douyuLiveOnlineConfig;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.example.core.creeper.loadconfig;
|
||||
|
||||
import lombok.Data;
|
||||
import org.example.core.creeper.builder.BiliBiliLiveLoadConfigBuilder;
|
||||
import org.example.core.creeper.loadtask.BilibiliLiveOnlineLoadTask;
|
||||
import org.example.core.creeper.loadtask.DouyuLiveOnlineLoadTask;
|
||||
import org.example.core.creeper.loadtask.DouyuRecordLoadTask;
|
||||
import org.example.core.manager.annotation.Creeper;
|
||||
import org.example.core.manager.Creeper;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/08/30 18:05
|
||||
**/
|
||||
@Data
|
||||
@Creeper(creeperName = "bilibili_live",loadTask = BilibiliLiveOnlineLoadTask.class,creeperDescription = "B站直播爬取")
|
||||
@Creeper(creeperName = "bilibili_live",
|
||||
loadTask = BilibiliLiveOnlineLoadTask.class,
|
||||
builder = BiliBiliLiveLoadConfigBuilder.class,
|
||||
creeperDescription = "B站直播爬取")
|
||||
public class BilibiliLiveOnlineConfig extends LoadLiveConfig{
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.example.core.creeper.loadconfig;
|
||||
|
||||
import lombok.Data;
|
||||
import org.example.bean.live.DouyuLive;
|
||||
import org.example.core.creeper.builder.DouyuLiveLoadConfigBuilder;
|
||||
import org.example.core.creeper.loadtask.DouyuLiveOnlineLoadTask;
|
||||
import org.example.core.creeper.loadtask.DouyuRecordLoadTask;
|
||||
import org.example.core.manager.annotation.Creeper;
|
||||
import org.example.core.manager.Creeper;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/07/28 23:17
|
||||
**/
|
||||
@Data
|
||||
@Creeper(creeperName = "douyu_live",loadTask = DouyuLiveOnlineLoadTask.class,creeperDescription = "斗鱼直播爬取")
|
||||
@Creeper(creeperName = "douyu_live",
|
||||
loadTask = DouyuLiveOnlineLoadTask.class,
|
||||
builder = DouyuLiveLoadConfigBuilder.class,
|
||||
creeperDescription = "斗鱼直播爬取")
|
||||
public class DouyuLiveOnlineConfig extends LoadLiveConfig {
|
||||
public DouyuLiveOnlineConfig(String roomId, String videoPath, String videoName,int clarity) {
|
||||
super(roomId, videoPath, videoName, false);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package org.example.core.creeper.loadconfig;
|
||||
|
||||
import lombok.Data;
|
||||
import org.example.core.VideoType;
|
||||
import org.example.core.creeper.loadtask.DouyuRecordLoadTask;
|
||||
import org.example.core.manager.annotation.Creeper;
|
||||
import org.example.core.manager.Creeper;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package org.example.core.factory;
|
||||
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.core.creeper.loadconfig.BilibiliLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.DouyuLiveOnlineConfig;
|
||||
import org.example.core.creeper.loadconfig.LoadLiveConfig;
|
||||
import org.example.pool.LiveModuleConstPool;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/08/31 23:57
|
||||
**/
|
||||
public class LiveLoadConfigFactory {
|
||||
|
||||
public static <T extends LoadLiveConfig> T buildLiveConfig(String platform, String roomId, String liver,
|
||||
boolean convertMp4, boolean showDownloadTable){
|
||||
platform = platform.toLowerCase();
|
||||
|
||||
if(platform.equals(ConstPool.PLATFORM.DOUYU.getName())){
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.DOUYU);
|
||||
DouyuLiveOnlineConfig config = new DouyuLiveOnlineConfig(roomId, path, LoadLiveConfig.fileName(roomId, liver), convertMp4);
|
||||
config.setShowDownloadTable(showDownloadTable);
|
||||
config.setLiverName(liver);
|
||||
return (T) config;
|
||||
}else if(platform.equals(ConstPool.PLATFORM.BILIBILI.getName())){
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.BILIBILI);
|
||||
BilibiliLiveOnlineConfig config = new BilibiliLiveOnlineConfig(roomId, path, LoadLiveConfig.fileName(roomId, liver), convertMp4);
|
||||
config.setShowDownloadTable(showDownloadTable);
|
||||
config.setLiverName(liver);
|
||||
return (T) config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T extends LoadLiveConfig> T buildLiveConfig(String platform, String roomId,String liver,
|
||||
int clarity,boolean showDownloadTable){
|
||||
platform = platform.toLowerCase();
|
||||
if(platform.equals(ConstPool.PLATFORM.DOUYU.getName())){
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.DOUYU);
|
||||
DouyuLiveOnlineConfig config = new DouyuLiveOnlineConfig(roomId, path, LoadLiveConfig.fileName(roomId, liver), clarity);
|
||||
config.setShowDownloadTable(showDownloadTable);
|
||||
config.setLiverName(liver);
|
||||
return (T) config;
|
||||
}else if(platform.equals(ConstPool.PLATFORM.BILIBILI.getName())){
|
||||
String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.BILIBILI);
|
||||
BilibiliLiveOnlineConfig config = new BilibiliLiveOnlineConfig(roomId, path, LoadLiveConfig.fileName(roomId, liver), clarity);
|
||||
config.setShowDownloadTable(showDownloadTable);
|
||||
config.setLiverName(liver);
|
||||
return (T) config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user