账号模块完成对b站的登录保存cookie操作,推送模块的获取cookie登录推送视频操作

This commit is contained in:
welsir
2023-09-25 08:15:55 +08:00
parent 607b17242d
commit 6e1e3db348
43 changed files with 1027 additions and 361 deletions
+2 -2
View File
@@ -38,7 +38,7 @@
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="ChopperBot" options="" />
<module name="ChopperBot" options="-parameters" />
<module name="chopperbot-account" options="-parameters" />
<module name="chopperbot-barrage" options="-parameters" />
<module name="chopperbot-common" options="-parameters" />
@@ -53,4 +53,4 @@
<module name="chopperbot-test" options="-parameters" />
</option>
</component>
</project>
</project>
-27
View File
@@ -1,27 +0,0 @@
w
Gchopperbot-hot/src/main/java/org/example/core/guard/HotModuleGuard.java,a\0\a041720980ce8572991a33b197c3d81b7cb2e69d
q
Achopperbot-live/src/main/java/org/example/api/DouyuRecordApi.java,8\f\8f191dc97b4e0d2571f649a1600c703d34ad26c2
x
Hchopperbot-common/src/main/java/org/example/init/InitPluginRegister.java,5\a\5a133c519459ad4a22878928f82def26862acd31
{
Kdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/03.热度监控æ’ä»¶.md,c\4\c4fa3a693a39c9b1847c5eaf7059cca997527b45
{
Kdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/01.文件缓存æ’ä»¶.md,c\1\c1323f01e0736fea6d2fb87e88e904a79a9a30a8
p
@chopperbot-account/src/main/java/org/example/core/VideoType.java,2\6\265ab5b7137a542213410da8195b02b06a7692d0

Qdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/04.爬虫任务中心æ’ä»¶.md,e\8\e83a2fa7f8f76b2daf1183cff7572f224a44ac6b

Vchopperbot-barrage/src/main/java/org/example/init/module/BarrageModuleInitMachine.java,a\f\af71a49d825f2b79243dc2df9f134a7cb4640b2e
n
>chopperbot-hot/src/main/java/org/example/config/FollowDog.java,7\4\74b76b9d2bd43d07054d9e6eb36e9ee4507da3e1
t
Dchopperbot-console/src/main/java/org/example/ConsoleApplication.java,a\b\abdd1c60a367131d127a01ca5bc834e95020a4e3
O
config/Hot/hotModuleConfig.json,5\0\50eb6bdb4a00f0b15b783cfc947a7a759c934449
v
Fchopperbot-creeper/src/main/java/org/example/api/MonitorCenterApi.java,5\c\5c440003ab53fc4466023bd8249cb4898ddeb5d8
w
Gchopperbot-creeper/src/main/java/org/example/api/CreeperManagerApi.java,5\d\5d5897de24b870055a6792786f1de4b6fe558b74
-27
View File
@@ -1,27 +0,0 @@
w
Gchopperbot-hot/src/main/java/org/example/core/guard/HotModuleGuard.java,a\0\a041720980ce8572991a33b197c3d81b7cb2e69d
q
Achopperbot-live/src/main/java/org/example/api/DouyuRecordApi.java,8\f\8f191dc97b4e0d2571f649a1600c703d34ad26c2
x
Hchopperbot-common/src/main/java/org/example/init/InitPluginRegister.java,5\a\5a133c519459ad4a22878928f82def26862acd31
p
@chopperbot-account/src/main/java/org/example/core/VideoType.java,2\6\265ab5b7137a542213410da8195b02b06a7692d0
{
Kdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/01.文件缓存æ’ä»¶.md,c\1\c1323f01e0736fea6d2fb87e88e904a79a9a30a8
{
Kdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/03.热度监控æ’ä»¶.md,c\4\c4fa3a693a39c9b1847c5eaf7059cca997527b45

Qdoc/docs/01.指å—/01.开呿Œ‡å—/02.系统æ’ä»¶/04.爬虫任务中心æ’ä»¶.md,e\8\e83a2fa7f8f76b2daf1183cff7572f224a44ac6b

Vchopperbot-barrage/src/main/java/org/example/init/module/BarrageModuleInitMachine.java,a\f\af71a49d825f2b79243dc2df9f134a7cb4640b2e
t
Dchopperbot-console/src/main/java/org/example/ConsoleApplication.java,a\b\abdd1c60a367131d127a01ca5bc834e95020a4e3
n
>chopperbot-hot/src/main/java/org/example/config/FollowDog.java,7\4\74b76b9d2bd43d07054d9e6eb36e9ee4507da3e1
O
config/Hot/hotModuleConfig.json,5\0\50eb6bdb4a00f0b15b783cfc947a7a759c934449
v
Fchopperbot-creeper/src/main/java/org/example/api/MonitorCenterApi.java,5\c\5c440003ab53fc4466023bd8249cb4898ddeb5d8
w
Gchopperbot-creeper/src/main/java/org/example/api/CreeperManagerApi.java,5\d\5d5897de24b870055a6792786f1de4b6fe558b74
+30 -12
View File
@@ -24,22 +24,12 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-core</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>chopperbot-common</artifactId>
@@ -53,8 +43,36 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>portable-1.7.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.5.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -1,13 +1,19 @@
package org.example;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Hello world!
*
*/
public class App
@SpringBootApplication
@MapperScan(value = {"org.example.core.mapper.*"})
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
SpringApplication.run(App.class, args);
}
}
@@ -0,0 +1,34 @@
package org.example.api;
import org.example.core.account.Impl.AccountOperator;
import org.example.pojo.Account;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description
* @Author welsir
* @Date 2023/9/22 14:11
*/
@RestController
@RequestMapping("account")
public class AccountApi {
@Resource
private AccountOperator accountOperator;
@PostMapping("/addUser/{uid}")
public void addAccount(@PathVariable int uid){
accountOperator.insertAccount(uid);
}
@GetMapping("/getUser/{platformId}")
public List<Account> getAllUsers(@PathVariable int platformId){
return accountOperator.getAllUsers(platformId);
}
}
@@ -1,60 +0,0 @@
package org.example.api;
import org.example.cache.FileCacheManager;
import org.example.constpool.ConstPool;
import org.example.constpool.GlobalFileCache;
import org.example.constpool.PluginName;
import org.example.init.InitPluginRegister;
import org.example.plugin.CommonPlugin;
import org.junit.Test;
import java.io.File;
import java.security.Key;
import java.util.*;
/**
* @Description
* @Author welsir
* @Date 2023/9/9 12:36
*/
public class BarrageApi {
private static final String BARRAGE_FILE_ROOT_PATH = (String) GlobalFileCache.ModuleSrcConfigFile.get("src", ConstPool.BARRAGE);
private static final HashMap<String,List<File>> barrageFileMap = new HashMap<>();
private static final String[] platForms = {"bilibili","douyu","douyin","huya","tiktok","twitch"};
public HashMap getAllBarrageFile(){
for (String plathForm : platForms) {
File platformDir = new File(BARRAGE_FILE_ROOT_PATH + "/" + plathForm);
for (File anchorDir : Objects.requireNonNull(platformDir.listFiles())) {
if(anchorDir.isDirectory()){
String anchor = anchorDir.getName();
List<File> fileList = new ArrayList<>(Arrays.asList(Objects.requireNonNull(anchorDir.listFiles())));
barrageFileMap.put(anchor, fileList);
}
}
}
return barrageFileMap;
}
public boolean deleteFile(String fileName,String platForm){
String delFilePath = BARRAGE_FILE_ROOT_PATH+"/"+platForm+"/"+fileName;
File file = new File(delFilePath);
try {
if(file.exists()){
return file.delete();
}else {
System.out.println("file path is error, please check parameters are correct!");
return false;
}
}catch (SecurityException e) {
System.out.println("删除文件时发生安全异常: " + e.getMessage());
return false;
}
}
}
@@ -21,10 +21,4 @@ public class VideoPublishApi {
}
}
public static void main(String[] args) {
pushVideo("hello");
}
}
@@ -0,0 +1,18 @@
package org.example.core.account;
import org.example.pojo.Account;
import java.util.List;
/**
* @Description
* @Author welsir
* @Date 2023/9/23 14:02
*/
public interface AccountCenter {
void insertAccount(int platformId);
List<Account> getAllUsers(int id);
}
@@ -0,0 +1,31 @@
package org.example.core.account.Impl;
import org.example.core.account.AccountCenter;
import org.example.core.factory.PlatformFactory;
import org.example.core.mapper.AccountMapper;
import org.example.pojo.Account;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description
* @Author welsir
* @Date 2023/9/23 14:04
*/
@Component
public class AccountOperator implements AccountCenter {
@Resource
private AccountMapper accountMapper;
@Override
public void insertAccount(int platformId) {
PlatformFactory.createPlatformOperation(platformId);
}
@Override
public List<Account> getAllUsers(int id) {
return accountMapper.getUserByPlatform(id);
}
}
@@ -16,11 +16,10 @@ public class Exchange {
}
public void bind(VideoQueue queue, String routingKey) {
this.bindings.putIfAbsent(routingKey, new ArrayList());
this.bindings.get(routingKey).add(queue);
this.bindings.putIfAbsent(routingKey, new ArrayList<>());
this.bindings.get(routingKey).add(queue);
}
public void publish(String routingKey, Object message) {
if (this.bindings.containsKey(routingKey)) {
List<VideoQueue> queues = this.bindings.get(routingKey);
@@ -0,0 +1,25 @@
package org.example.core.factory;
import org.example.core.platform.Bilibili;
import org.example.pojo.PlatformType;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 21:16
*/
public class PlatformFactory {
public static void createPlatformOperation(int platformId) {
switch (PlatformType.getPlatform(platformId)){
case BILIBILI:
new Bilibili();
return;
case DOUYU:
case DOUYIN:
return;
default:
throw new RuntimeException();
}
}
}
@@ -0,0 +1,13 @@
package org.example.core.factory;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 21:17
*/
public interface PlatformOperation {
void operation(int id);
}
@@ -2,12 +2,18 @@ package org.example.core.guard;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.example.core.VideoType;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.pojo.VideoType;
import org.example.core.exchange.Exchange;
import org.example.core.mapper.AccountMapper;
import org.example.core.mapper.AccountTypeMapper;
import org.example.plugin.GuardPlugin;
import org.example.pojo.Account;
import org.example.pojo.AccountType;
import org.example.pojo.Video;
import org.example.pojo.VideoQueue;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -27,9 +33,15 @@ import java.util.regex.Pattern;
*/
public class VideoPushGuard extends GuardPlugin {
private static Exchange exchange;
private static String PATH = "config/Account/account.json";
private static BlockingQueue<Object> receiveVideo;
private Exchange exchange;
private static final String ACCOUNT_PATH = "config/Account/account.json";
private BlockingQueue<Object> receiveVideo;
@Resource
private AccountMapper accountMapper;
@Resource
private AccountTypeMapper accountTypeMapper;
public VideoPushGuard(String module, String pluginName, List<String> needPlugins, boolean isAutoStart) {
super(module, pluginName, needPlugins, isAutoStart);
@@ -37,64 +49,18 @@ public class VideoPushGuard extends GuardPlugin {
@Override
public boolean init() {
// exchange = new Exchange();
// try {
// String jsonData = Files.readString(Path.of(PATH));
// JSONObject jsonObject = JSON.parseObject(jsonData);
//
// for (Map.Entry<String, Object> platformEntry : jsonObject.entrySet()) {
// String platform = platformEntry.getKey();
// JSONObject platformData = (JSONObject) platformEntry.getValue();
//
// System.out.println("Platform: " + platform);
// System.out.println("platformData: " + platformData);
//
// String types = getStringValueOrDefault(platformData, "type", "");
// boolean isMatch = getBooleanValueOrDefault(platformData, "isMatch", false);
//
// Pattern pattern = Pattern.compile("\"([^\"]+)\"");
// Matcher matcher = pattern.matcher(types);
//
// while (matcher.find()) {
// String type = matcher.group(1);
// for (String queueName : platformData.keySet()) {
// exchange.bind(new VideoQueue(platform + "-" + queueName, isMatch), type);
// }
// }
// }
//
// receiveVideo = new ArrayBlockingQueue<>(1024);
return true;
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
}
@Override
public void start() {
// try {
// Object videoMsg = receiveVideo.poll(5, TimeUnit.SECONDS);
// if (videoMsg instanceof Video) {
// Video video = (Video)videoMsg;
// Iterator<VideoType> iterator = video.getVideoType().iterator();
// while(iterator.hasNext()) {
// VideoType videoType = iterator.next();
// exchange.publish(videoType.toString(), video.getMessage());
// }
// }
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
}
public void sendVideo(Object msg) {
receiveVideo.offer(msg);
}
public static void main(String[] args) {
exchange = new Exchange();
try {
String jsonData = Files.readString(Path.of(PATH));
List<Account> accountList = accountMapper.selectList(null);
for (Account account : accountList) {
List<AccountType> accountTypes = accountTypeMapper.selectList(new QueryWrapper<AccountType>().eq("uid",account.getId()));
}
String jsonData = Files.readString(Path.of(ACCOUNT_PATH));
JSONObject jsonObject = JSON.parseObject(jsonData);
for (Map.Entry<String, Object> platformEntry : jsonObject.entrySet()) {
@@ -117,18 +83,39 @@ public class VideoPushGuard extends GuardPlugin {
}
}
}
receiveVideo = new ArrayBlockingQueue<>(1024);
return true;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static String getStringValueOrDefault(JSONObject jsonObject, String key, String defaultValue) {
@Override
public void start() {
try {
Object videoMsg = receiveVideo.poll(5, TimeUnit.SECONDS);
if (videoMsg instanceof Video) {
Video video = (Video)videoMsg;
Iterator<VideoType> iterator = video.getVideoType().iterator();
while(iterator.hasNext()) {
VideoType videoType = iterator.next();
exchange.publish(videoType.toString(), video.getMessage());
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
public void sendVideo(Object msg) {
receiveVideo.offer(msg);
}
private String getStringValueOrDefault(JSONObject jsonObject, String key, String defaultValue) {
Object value = jsonObject.get(key);
return value != null ? value.toString() : defaultValue;
}
private static boolean getBooleanValueOrDefault(JSONObject jsonObject, String key, boolean defaultValue) {
private boolean getBooleanValueOrDefault(JSONObject jsonObject, String key, boolean defaultValue) {
Object value = jsonObject.get(key);
return value != null ? (boolean) value : defaultValue;
}
@@ -0,0 +1,19 @@
package org.example.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.Account;
import java.util.List;
/**
* @Description
* @Author welsir
* @Date 2023/9/23 14:15
*/
public interface AccountMapper extends BaseMapper<Account> {
@Select("select * from account a join platform pf on a.platformId=pf.id where pf.id = #{id}")
List<Account> getUserByPlatform(int id);
}
@@ -0,0 +1,12 @@
package org.example.core.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.pojo.AccountType;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 16:08
*/
public interface AccountTypeMapper extends BaseMapper<AccountType> {
}
@@ -0,0 +1,53 @@
package org.example.core.platform;
import org.example.core.factory.PlatformOperation;
import org.example.core.mapper.AccountMapper;
import org.example.pojo.Account;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import javax.annotation.Resource;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 21:18
*/
public class Bilibili implements PlatformOperation {
@Resource
private AccountMapper accountMapper;
Set<Cookie> cookies;
@Override
public void operation(int id) {
try {
//设置driver驱动,<-记得更改为自己的本地路径!!->
System.setProperty("webdriver.chrome.driver", "D:\\downLoad\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
//同理
options.setBinary("C:\\Program Files (x86)\\Chromebrowser\\Chrome.exe");
ChromeDriver webDriver = new ChromeDriver(options);
//b站网址
String url = "https://www.bilibili.com/";
webDriver.get(url);
//与浏览器同步非常重要,必须等待浏览器加载完毕
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//中间完成登录操作
Scanner scanner = new Scanner(System.in);
scanner.next();
//获取cookie
cookies = webDriver.manage().getCookies();
Account account = new Account();
account.setCookie(cookies);
account.setPlatformId(id);
accountMapper.insert(account);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@@ -1,18 +1,30 @@
package org.example.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.openqa.selenium.Cookie;
import java.util.Set;
/**
* @Description
* @Author welsir
* @Date 2023/9/4 22:08
*/
@TableName(value = "account")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Account {
private String password;
private String videoType;
public Account() {
}
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long uid;
private Set<Cookie> cookie;
private boolean isCompleteMatch;
private int platformId;
public String toString() {
return "Account{password='" + this.password + "', videoType='" + this.videoType + "'}";
}
}
@@ -0,0 +1,23 @@
package org.example.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 16:04
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "account_type")
public class AccountType {
private String uid;
private List<VideoType> videoTypes;
}
@@ -1,34 +0,0 @@
package org.example.pojo;
/**
* @Description
* @Author welsir
* @Date 2023/9/4 22:08
*/
public class Platform {
private String platName;
private Account account;
public Platform() {
}
public String toString() {
return "Platform{platName='" + this.platName + "', account=" + this.account + "}";
}
public String getPlatName() {
return this.platName;
}
public void setPlatName(String platName) {
this.platName = platName;
}
public Account getAccount() {
return this.account;
}
public void setAccount(Account account) {
this.account = account;
}
}
@@ -0,0 +1,32 @@
package org.example.pojo;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 19:28
*/
public enum PlatformType {
DOUYU(1),
BILIBILI(2),
DOUYIN(3);
private final int index;
public int getId() {
return index;
}
public static PlatformType getPlatform(int id) {
for (PlatformType platform : values()) {
if (platform.index == id) {
return platform;
}
}
throw new IllegalArgumentException("Invalid platform id: " + id);
}
PlatformType(int index){
this.index = index;
}
}
@@ -1,7 +1,5 @@
package org.example.pojo;
import org.example.core.VideoType;
import java.util.List;
/**
@@ -1,7 +1,5 @@
package org.example.pojo;
import org.example.core.VideoType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -1,4 +1,4 @@
package org.example.core;
package org.example.pojo;
/**
* @Description
@@ -0,0 +1,14 @@
{
"Douyu": {
"accountInfo": [
{"id": "test01",
"password": 123456,
"VideoType": [],
"cookies": ""
}
]
},
"Douyin": {
"accountInfo": []
}
}
@@ -0,0 +1,5 @@
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://localhost:3306/database?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8
@@ -0,0 +1,27 @@
package org.example;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.model.crf.CRFLexicalAnalyzer;
import com.hankcs.hanlp.tokenizer.NLPTokenizer;
import org.junit.jupiter.api.Test;
import java.io.IOException;
/**
* @Description
* @Author welsir
* @Date 2023/9/18 8:08
*/
public class BarrageTest {
@Test
public void test() throws IOException {
// System.out.println(NLPTokenizer.segment(""));
//// 注意观察下面两个“希望”的词性、两个“晚霞”的词性
// System.out.println(NLPTokenizer.analyze("你是?").translateLabels());
// System.out.println(NLPTokenizer.analyze("支援臺灣正體香港繁體:微软公司於1975年由比爾·蓋茲和保羅·艾倫創立。"));
CRFLexicalAnalyzer analyzer = new CRFLexicalAnalyzer();
System.out.println(analyzer.analyze("你是?"));
}
}
@@ -0,0 +1,16 @@
package org.example;
/**
* @Description
* @Author welsir
* @Date 2023/9/18 8:24
*/
public class FileZipTest {
public void test(){
}
}
@@ -39,7 +39,7 @@ public class FileConfigProcessor {
}
public static void barrageFileLoadingProcessor(Map<String,List<Barrage>> barrageMap){
File file = new File(BarrageModuleConstPool.BARRAGE_ROOT_PATH);
File file = new File(BarrageModuleConstPool.BARRAGE_ROOT_PATH+"/barrageScoreConfig");
for (File listFile : Objects.requireNonNull(file.listFiles())) {
if(!"barrageScoreConfig".equals(listFile.getName())){
for (File barrageFile : Objects.requireNonNull(listFile.listFiles())) {
@@ -94,7 +94,7 @@ public class JsonFileUtil {
try{
if (FileUtil.isFileExist(dir.toString())) {
String res = Files.readString(dir, StandardCharsets.UTF_8);
// logger.debug("读取json文件成功, 文件内容为: {}", res);
logger.debug("读取json文件成功, 文件内容为: {}", res);
t = JSON.parseArray(res, clazz);
}
+30
View File
@@ -59,6 +59,28 @@
<artifactId>Java-WebSocket</artifactId>
<version>1.5.1</version> <!-- 使用最新版本 -->
</dependency>
<!-- only this origin -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
<!-- add belows for these dependencies version is not 4.0.0 when automatically generated -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
@@ -72,5 +94,13 @@
<artifactId>jcommon</artifactId>
<version>1.0.23</version> <!-- 版本号根据你需要的版本进行修改 -->
</dependency>
<!-- https://mvnrepository.com/artifact/com.hankcs/hanlp -->
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>portable-1.7.8</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,76 @@
package org.example.account;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @Description
* @Author welsir
* @Date 2023/9/24 16:51
*/
public class bilibiliTest {
public static void getcookies() throws Exception {
System.setProperty("webdriver.chrome.driver", "D:\\downLoad\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Chromebrowser\\Chrome.exe");
ChromeDriver webDriver = new ChromeDriver(options);
String url = "https://www.bilibili.com/";
webDriver.get(url);
// 与浏览器同步非常重要,必须等待浏览器加载完毕
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//中间完成登录操作
Scanner scanner = new Scanner(System.in);
scanner.next();
// 获取cookie,再通过baocun函数进行序列化操作
Set<Cookie> cookies = webDriver.manage().getCookies();
System.out.println(cookies);
baocun(cookies);
}
//把登录后得到的cookie序列化到硬盘中
public static void baocun(Set<Cookie> cookies) throws Exception {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("d:\\4.txt"));
objectOutputStream.writeObject(cookies);
}
public static void main(String[] args) throws Exception {
// System.setProperty("webdriver.chrome.driver", "D:\\downLoad\\chromedriver_win32\\chromedriver.exe");
// ChromeOptions options = new ChromeOptions();
// Map<String, Object> prefs = new HashMap<>();
// prefs.put("download.default_directory", "d:\\");
// options.setExperimentalOption("prefs", prefs);
// options.setBinary("C:\\Program Files (x86)\\Chromebrowser\\Chrome.exe");
// ChromeDriver webDriver = new ChromeDriver(options);
//// WangyiUtils.get cookies();
// Set<Cookie> read = read();
//
//
// String url = "https://www.bilibili.com/";
// webDriver.get(url); //
// webDriver.manage().deleteAllCookies();
// for (Cookie cookie : read) {
// webDriver.manage().addCookie(cookie);
// }
// // 与浏览器同步非常重要,必须等待浏览器加载完毕
// webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// webDriver.navigate().refresh();
getcookies();
}
//读取硬盘cookie的操作
public static Set<Cookie> read() throws Exception {
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("d:\\4.txt"));
HashSet<Cookie> cookies = (HashSet<Cookie>) objectInputStream.readObject();
return cookies;
}
}
@@ -0,0 +1,35 @@
package org.example.barrage;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import com.hankcs.hanlp.summary.TextRankKeyword;
import com.hankcs.hanlp.tokenizer.NLPTokenizer;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description
* @Author welsir
* @Date 2023/9/14 19:48
*/
public class KeywordDdaptationTest {
public static void main(String[] args) {
String text = "?????";
// 使用TextRank算法提取关键词
List<String> keywords = TextRankKeyword.getKeywordList(text, 5);
// 对文本进行分词
List<Term> termList = HanLP.segment(text);
System.out.println("分词结果:" + termList);
System.out.println(NLPTokenizer.segment("我新造一个词叫幻想乡你能识别并标注正确词性吗?"));
// 注意观察下面两个“希望”的词性、两个“晚霞”的词性
System.out.println(NLPTokenizer.analyze("我的希望是希望张晚霞的背影被晚霞映红").translateLabels());
System.out.println(NLPTokenizer.analyze("支援臺灣正體香港繁體:微软公司於1975年由比爾·蓋茲和保羅·艾倫創立。"));
}
}
@@ -1,111 +1,111 @@
package org.example.ws;
import org.example.bean.barrage.DouyuBarrage;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import javax.net.ssl.SSLSocketFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import static org.example.ws.DouyuProtoctl.*;
/**
* @author Genius
* @date 2023/09/04 19:53
**/
public class WebSocketTest {
public static WebSocketClient openClient(String roomId) throws InterruptedException {
String serverUri = "wss://danmuproxy.douyu.com:8502/"; // WebSocket服务器的地址
long startTime = System.currentTimeMillis();
WebSocketClient client = null;
try {
client = new WebSocketClient(new URI(serverUri), new Draft_6456()) {
@Override
public void onOpen(ServerHandshake handshakedata) {
System.out.println("WebSocket connection opened");
// 发送二进制数据
this.send(loginReq(roomId,"visitor4162168","1145012856","20220825","218101901","0"));
this.send(joinGroup(roomId,"1"));
this.send(heartBeat());
}
@Override
public void onMessage(String s) {
System.out.println("Received binary data: " + s);
}
@Override
public void onMessage(ByteBuffer buffer) {
// 处理二进制消息
DouyuBarrage douyuBarrage = wrapperBarrage(buffer, startTime);
if(douyuBarrage!=null){
System.out.println(roomId+":"+douyuBarrage);
}
}
@Override
public void onClose(int code, String reason, boolean remote) {
this.close();
System.out.println(code);
System.out.println(reason);
System.out.println("WebSocket connection closed");
}
@Override
public void onError(Exception ex) {
ex.printStackTrace();
}
};
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
client.setSocketFactory(sslSocketFactory);
client.connect(); // 连接到WebSocket服务器
} catch (URISyntaxException e) {
e.printStackTrace();
}
return client;
}
public static void main(String[] args) throws InterruptedException {
WebSocketClient client = openClient("4520630");
WebSocketClient client2 = openClient("101367");
if(client==null||client.isClosed()){
}else{
while (true){
Thread.sleep(60*1000);
System.out.println("heartBeat");
client.send(heartBeat());
client2.send(heartBeat());
if(client.isClosed()){
break;
}
}
}
}
// 将十六进制字符串转换为字节数组
private static byte[] hexStringToByteArray(String hex) {
int len = hex.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4)
+ Character.digit(hex.charAt(i + 1), 16));
}
return data;
}
// 发送二进制数据
private static void sendBinaryData(byte[] data) {
ByteBuffer buffer = ByteBuffer.wrap(data);
}
// 发送二进制数据
}
//package org.example.ws;
//
//import org.example.bean.barrage.DouyuBarrage;
//import org.java_websocket.client.WebSocketClient;
//
//import org.java_websocket.handshake.ServerHandshake;
//
//import javax.net.ssl.SSLSocketFactory;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.nio.ByteBuffer;
//
//import static org.example.ws.DouyuProtoctl.*;
//
//
///**
// * @author Genius
// * @date 2023/09/04 19:53
// **/
//public class WebSocketTest {
//
//
// public static WebSocketClient openClient(String roomId) throws InterruptedException {
// String serverUri = "wss://danmuproxy.douyu.com:8502/"; // WebSocket服务器的地址
// long startTime = System.currentTimeMillis();
// WebSocketClient client = null;
// try {
// client = new WebSocketClient(new URI(serverUri), new Draft_6456()) {
// @Override
// public void onOpen(ServerHandshake handshakedata) {
// System.out.println("WebSocket connection opened");
// // 发送二进制数据
// this.send(loginReq(roomId,"visitor4162168","1145012856","20220825","218101901","0"));
// this.send(joinGroup(roomId,"1"));
// this.send(heartBeat());
// }
//
// @Override
// public void onMessage(String s) {
// System.out.println("Received binary data: " + s);
// }
//
// @Override
// public void onMessage(ByteBuffer buffer) {
// // 处理二进制消息
// DouyuBarrage douyuBarrage = wrapperBarrage(buffer, startTime);
// if(douyuBarrage!=null){
// System.out.println(roomId+":"+douyuBarrage);
// }
// }
//
// @Override
// public void onClose(int code, String reason, boolean remote) {
// this.close();
// System.out.println(code);
// System.out.println(reason);
// System.out.println("WebSocket connection closed");
// }
//
// @Override
// public void onError(Exception ex) {
// ex.printStackTrace();
// }
// };
// SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
// client.setSocketFactory(sslSocketFactory);
// client.connect(); // 连接到WebSocket服务器
//
// } catch (URISyntaxException e) {
// e.printStackTrace();
// }
// return client;
// }
// public static void main(String[] args) throws InterruptedException {
// WebSocketClient client = openClient("4520630");
// WebSocketClient client2 = openClient("101367");
//
// if(client==null||client.isClosed()){
//
// }else{
// while (true){
// Thread.sleep(60*1000);
// System.out.println("heartBeat");
// client.send(heartBeat());
// client2.send(heartBeat());
// if(client.isClosed()){
// break;
// }
// }
// }
// }
//
// // 将十六进制字符串转换为字节数组
// private static byte[] hexStringToByteArray(String hex) {
// int len = hex.length();
// byte[] data = new byte[len / 2];
// for (int i = 0; i < len; i += 2) {
// data[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4)
// + Character.digit(hex.charAt(i + 1), 16));
// }
// return data;
// }
//
// // 发送二进制数据
// private static void sendBinaryData(byte[] data) {
// ByteBuffer buffer = ByteBuffer.wrap(data);
// }
//
// // 发送二进制数据
//}
//
+14
View File
@@ -0,0 +1,14 @@
{
"Douyu": {
"accountInfo": [
{"id": "test01",
"password": 123456,
"VideoType": ["HAPPY","SAD"],
"cookies": ""
}
]
},
"Douyin": {
"accountInfo": []
}
}
@@ -0,0 +1,185 @@
{
"data":[
{
"timeIndex":0,
"timeReal":1694406025000,
"mid":"505A3D52",
"content":"讨厌的度不够[妙]"
},
{
"timeIndex":0,
"timeReal":1694406009000,
"mid":"CE8384B",
"content":"能让我更讨厌点吗[妙]"
},
{
"timeIndex":0,
"timeReal":1694405976000,
"mid":"BDAF1DDC",
"content":"我只给讨厌的人刷[妙]"
},
{
"timeIndex":0,
"timeReal":1694405972000,
"mid":"7C575710",
"content":"好"
},
{
"timeIndex":0,
"timeReal":1694405960000,
"mid":"4F17D7DD",
"content":"这个8号我很讨厌"
},
{
"timeIndex":0,
"timeReal":1694405931000,
"mid":"5559EB9E",
"content":"我喜欢一号 拜拜[妙]"
},
{
"timeIndex":0,
"timeReal":1694405907000,
"mid":"62A15C4B",
"content":"嗯?"
},
{
"timeIndex":0,
"timeReal":1694405054000,
"mid":"1F404546",
"content":"泪目"
},
{
"timeIndex":0,
"timeReal":1694405050000,
"mid":"BF7F549F",
"content":"我选择饿着"
},
{
"timeIndex":0,
"timeReal":1694405045000,
"mid":"8399B434",
"content":"我放弃了"
},
{
"timeIndex":0,
"timeReal":1694408415000,
"mid":"AA6B4EB0",
"content":"有吗"
},
{
"timeIndex":0,
"timeReal":1694408401000,
"mid":"F5B4172D",
"content":"妙啊"
},
{
"timeIndex":0,
"timeReal":1694406025000,
"mid":"505A3D52",
"content":"讨厌的度不够[妙]"
},
{
"timeIndex":0,
"timeReal":1694406009000,
"mid":"CE8384B",
"content":"能让我更讨厌点吗[妙]"
},
{
"timeIndex":0,
"timeReal":1694405976000,
"mid":"BDAF1DDC",
"content":"我只给讨厌的人刷[妙]"
},
{
"timeIndex":0,
"timeReal":1694405972000,
"mid":"7C575710",
"content":"好"
},
{
"timeIndex":0,
"timeReal":1694405960000,
"mid":"4F17D7DD",
"content":"这个8号我很讨厌"
},
{
"timeIndex":0,
"timeReal":1694405931000,
"mid":"5559EB9E",
"content":"我喜欢一号 拜拜[妙]"
},
{
"timeIndex":0,
"timeReal":1694405907000,
"mid":"62A15C4B",
"content":"嗯?"
},
{
"timeIndex":0,
"timeReal":1694405054000,
"mid":"1F404546",
"content":"泪目"
},
{
"timeIndex":0,
"timeReal":1694409452000,
"mid":"2BA079CA",
"content":"好的好的 快去吃饭吧"
},
{
"timeIndex":0,
"timeReal":1694409412000,
"mid":"1BED79F6",
"content":"吃饭了兄弟们"
},
{
"timeIndex":0,
"timeReal":1694408415000,
"mid":"AA6B4EB0",
"content":"有吗"
},
{
"timeIndex":0,
"timeReal":1694408401000,
"mid":"F5B4172D",
"content":"妙啊"
},
{
"timeIndex":0,
"timeReal":1694406025000,
"mid":"505A3D52",
"content":"讨厌的度不够[妙]"
},
{
"timeIndex":0,
"timeReal":1694406009000,
"mid":"CE8384B",
"content":"能让我更讨厌点吗[妙]"
},
{
"timeIndex":0,
"timeReal":1694405976000,
"mid":"BDAF1DDC",
"content":"我只给讨厌的人刷[妙]"
},
{
"timeIndex":0,
"timeReal":1694405972000,
"mid":"7C575710",
"content":"好"
},
{
"timeIndex":0,
"timeReal":1694405960000,
"mid":"4F17D7DD",
"content":"这个8号我很讨厌"
},
{
"timeIndex":0,
"timeReal":1694405931000,
"mid":"5559EB9E",
"content":"我喜欢一号 拜拜[妙]"
}
],
"updateTime":"2023-09-11 13:20:14"
}
+28
View File
@@ -0,0 +1,28 @@
{
"updateTime":"2023-09-11 12:56:39",
"data":{
"spiderConfig":{
"bilibili":{
"emptySleepTime":100,
"retrySleepTime":100,
"retryTimes":3,
"sleepTime":100,
"threadCnt":5,
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.48"
},
"douyu":{
"emptySleepTime":100,
"retrySleepTime":100,
"retryTimes":3,
"sleepTime":100,
"threadCnt":5,
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.48"
}
},
"taskCenter":{
"queueCapacity":50,
"threads":10,
"waitingTime":1000
}
}
}
+61
View File
@@ -0,0 +1,61 @@
{
"data":{
"task":[
{
"startTime":"2023-09-11 12:56:40",
"endTime":"2023-09-11 12:56:41",
"type":"finish",
"taskId":"74aa62f7-a273-422f-bf1b-2b4e26bfa912"
},
{
"startTime":"2023-09-11 12:56:41",
"endTime":"nil",
"type":"running",
"taskId":"live_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
},
{
"startTime":"2023-09-11 12:56:41",
"endTime":"nil",
"type":"running",
"taskId":"barrage_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
},
{
"startTime":"2023-09-11 13:12:21",
"endTime":"2023-09-11 13:12:22",
"type":"finish",
"taskId":"7d256ef1-3021-4916-9b83-dd8e7031510a"
},
{
"startTime":"2023-09-11 13:12:22",
"endTime":"nil",
"type":"running",
"taskId":"live_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
},
{
"startTime":"2023-09-11 13:12:22",
"endTime":"nil",
"type":"running",
"taskId":"barrage_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
},
{
"startTime":"2023-09-11 13:20:13",
"endTime":"2023-09-11 13:20:14",
"type":"finish",
"taskId":"7c8f74b1-2921-45a1-9339-7627d1d3e4ec"
},
{
"startTime":"2023-09-11 13:20:14",
"endTime":"nil",
"type":"running",
"taskId":"live_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
},
{
"startTime":"2023-09-11 13:20:14",
"endTime":"nil",
"type":"running",
"taskId":"barrage_online_bilibili_不期而遇-飞鸟冠_2023-09-11 08:55:56"
}
]
},
"updateTime":"2023-09-11 13:20:33"
}
+14
View File
@@ -0,0 +1,14 @@
{
"updateTime":"2023-09-11 12:56:40",
"data":{
"LiverFollower":{
"checkTime":60000,
"focusLive":1,
"focusRecord":1,
"focusBarrage":1
},
"HotGuard":{
"GuardNum":10
}
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"updateTime":"2023-09-11 12:56:39",
"data":{
"LiveDownload":{
"showDownloadTable":false
}
}
}
+29
View File
@@ -0,0 +1,29 @@
{
"data":{
"src":{
"Account":"./config/Account",
"Creeper":"./config/Creeper",
"LiveRecord":"./config/LiveRecord",
"SectionWork":"./config/SectionWork",
"Hot":"./config/Hot",
"Section":"./config/Section",
"Barrage":"./config/Barrage",
"Publish":"./config/Publish"
},
"pluginStart":{
"HotGuard":true,
"CreeperManager":true,
"FileCacheManager":true,
"LiverFollower":true,
"TaskMonitor":true,
"HotConfig":true,
"BarrageFileListen":true,
"TaskCenter":true,
"CreeperConfig":true,
"LiveDownLoadManager":true,
"LiveConfig":true,
"HotRecommendation":true
}
},
"updateTime":"2023-09-11 13:20:23"
}
BIN
View File
Binary file not shown.