修复账号模块和推送模块的依赖问题,重构账号模块

This commit is contained in:
welsir
2023-10-16 17:14:43 +08:00
parent a100583bc4
commit 67e9e19c51
35 changed files with 225 additions and 84 deletions
+1 -1
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" />
+6 -7
View File
@@ -11,7 +11,6 @@
<packaging>jar</packaging>
<name>chopperbot-account</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -42,6 +41,12 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>chopperbot-publish</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
@@ -85,12 +90,6 @@
<version>20210307</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>chopperbot-publish</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.squareup.okhttp3</groupId>-->
<!-- <artifactId>okhttp</artifactId>-->
@@ -1,8 +1,8 @@
package org.example.api;
import org.example.core.account.Impl.AccountOperator;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountVO;
import org.example.pojo.Account;
import org.example.pojo.AccountVO;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
@@ -1,8 +1,8 @@
package org.example.core.account;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountVO;
import org.example.pojo.Account;
import org.example.pojo.AccountVO;
import java.util.List;
@@ -8,9 +8,9 @@ import org.example.core.factory.PlatformOperation;
import org.example.mapper.AccountMapper;
import org.example.mapper.AccountTypeMapper;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountType;
import org.example.core.pojo.AccountVO;
import org.example.pojo.Account;
import org.example.pojo.AccountType;
import org.example.pojo.AccountVO;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@@ -1,12 +1,13 @@
package org.example.core.exchange;
import org.example.api.BilibiliPublishApi;
import org.example.core.pojo.VideoQueue;
import org.example.api.VedioPublishApi;
import org.example.pojo.VideoQueue;
import org.example.pojo.VideoToPublish;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
@@ -36,7 +37,7 @@ public class Exchange {
for (VideoQueue queue : queues) {
Object message = queue.dequeue();
if (message != null) {
BilibiliPublishApi.PublishVideo("xxx","xxx",queue.getCookies().toString(),"xxx");
VedioPublishApi.publishVideo(new VideoToPublish.Buider(message.toString(),queue.getCookies(),1).build());
}
}
}
@@ -2,7 +2,7 @@ package org.example.core.factory;
import org.example.core.platform.Bilibili;
import org.example.core.platform.Douyin;
import org.example.core.pojo.PlatformType;
import org.example.pojo.PlatformType;
/**
@@ -3,7 +3,7 @@ package org.example.core.guard;
import org.example.core.exchange.Exchange;
import org.example.mapper.AccountMapper;
import org.example.plugin.GuardPlugin;
import org.example.core.pojo.*;
import org.example.pojo.*;
import javax.annotation.Resource;
import java.util.List;
@@ -3,8 +3,6 @@ package org.example.core.platform;
import org.example.core.factory.PlatformOperation;
import org.example.mapper.AccountMapper;
import org.example.core.pojo.Account;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebElement;
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
import org.example.core.factory.PlatformOperation;
import org.example.core.pojo.Account;
import org.example.pojo.Account;
import org.example.mapper.AccountMapper;
import org.openqa.selenium.Cookie;
@@ -15,7 +15,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import static org.example.util.GetScriptPath.getScriptPath;
import static org.example.utils.GetScriptPath.getScriptPath;
/**
* @Description
@@ -2,8 +2,8 @@ package org.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountType;
import org.example.pojo.Account;
import org.example.pojo.AccountType;
import org.springframework.stereotype.Component;
import java.util.List;
@@ -1,7 +1,7 @@
package org.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.core.pojo.AccountType;
import org.example.pojo.AccountType;
/**
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
@@ -1,9 +1,8 @@
package org.example.core.pojo;
package org.example.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.core.pojo.AccountType;
import java.util.List;
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
/**
* @Description
@@ -1,6 +1,4 @@
package org.example.core.pojo;
import org.example.core.pojo.VideoType;
package org.example.pojo;
import java.util.List;
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
import lombok.Data;
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
import lombok.Data;
@@ -1,4 +1,4 @@
package org.example.core.pojo;
package org.example.pojo;
/**
* @Description
@@ -1,4 +1,4 @@
package org.example.util;
package org.example.utils;
import java.io.File;
import java.nio.file.Path;
-5
View File
@@ -63,11 +63,6 @@
<version>0.11.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-core</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.tencent.tars</groupId>
<artifactId>tars-client</artifactId>
@@ -1,9 +1,8 @@
package org.example.controller;
import org.apache.tools.ant.taskdefs.Get;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountVO;
import org.example.pojo.Account;
import org.example.pojo.AccountVO;
import org.example.pojo.GPTKey;
import org.example.service.AccountService;
import org.example.util.Result;
@@ -3,9 +3,8 @@ package org.example.service;
import org.example.api.GPTApi;
import org.example.core.gpt.ChatGPTPlugin;
import org.example.core.pojo.Account;
import org.example.core.pojo.AccountVO;
import org.example.pojo.Account;
import org.example.pojo.AccountVO;
import java.util.List;
@@ -3,10 +3,9 @@ package org.example.service.impl;
import org.example.api.AccountApi;
import org.example.api.GPTApi;
import org.example.core.gpt.ChatGPTPlugin;
import org.example.core.pojo.Account;
import org.example.pojo.Account;
import org.example.core.pojo.AccountVO;
import org.example.pojo.AccountVO;
import org.example.service.AccountService;
import org.springframework.stereotype.Service;
-5
View File
@@ -43,10 +43,5 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>chopperbot-account</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@@ -12,21 +12,21 @@ import java.util.List;
* @date 2023/9/18 20:42
*/
public class BilibiliPublishApi {
public static void PublishVideo(String videoPath,String devicePath,String Cookie,String coverPath){
List<String>list = new ArrayList<>();
list.add("音乐");
list.add("助眠");
BilibiliVideoManuscript bilibiliVideoManuscript = new BilibiliVideoManuscript("test","没有简介",130,list);
BilibiliUploader bilibiliUploader = new BilibiliUploader(Cookie,videoPath,coverPath,devicePath,bilibiliVideoManuscript);
BilibiliVideoPublisher bilibiliVideoPublisher = new BilibiliVideoPublisher();
bilibiliVideoPublisher.publishVideo(bilibiliUploader);
}
public static void main(String[] args) {
PublishVideo(
"C:\\Users\\admin\\Downloads\\test.mp4", //视频路径
"C:\\Users\\admin\\Desktop\\video_bin\\", //分割后视频存放路径
"", //b站Cookie
"C:\\Users\\admin\\Desktop\\OIP-C.jpg"); //封面路径
}
// public static void PublishVideo(String videoPath,String devicePath,String Cookie,String coverPath){
// List<String>list = new ArrayList<>();
// list.add("音乐");
// list.add("助眠");
// BilibiliVideoManuscript bilibiliVideoManuscript = new BilibiliVideoManuscript("test","没有简介",130,list);
// BilibiliUploader bilibiliUploader = new BilibiliUploader(Cookie,videoPath,coverPath,devicePath,bilibiliVideoManuscript);
// BilibiliVideoPublisher bilibiliVideoPublisher = new BilibiliVideoPublisher();
// bilibiliVideoPublisher.publishVideo(bilibiliUploader);
// }
//
// public static void main(String[] args) {
// PublishVideo(
// "C:\\Users\\admin\\Downloads\\test.mp4", //视频路径
// "C:\\Users\\admin\\Desktop\\video_bin\\", //分割后视频存放路径
// "", //b站Cookie
// "C:\\Users\\admin\\Desktop\\OIP-C.jpg"); //封面路径
// }
}
@@ -1,8 +1,8 @@
package org.example.api;
import org.example.core.factory.platformSelectionFactory;
import org.example.core.pojo.VideoToPublish;
import org.example.core.publisher.PlatformVideoPublisher;
import org.example.pojo.VideoToPublish;
/**
* @Description
@@ -1,6 +1,7 @@
package org.example.core.publisher;
import org.example.core.pojo.VideoToPublish;
import org.example.pojo.VideoToPublish;
/**
* @author dhx
@@ -11,11 +11,10 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.example.core.constpool.BilibiliURL;
import org.example.core.pojo.VideoToPublish;
import org.example.core.publisher.PlatformVideoPublisher;
import org.example.exception.ChopperBotException;
import org.example.pojo.BilibiliUploader;
import org.example.pojo.VideoToPublish;
import org.example.utils.CookieUtil;
import org.example.utils.FileUtil;
import org.example.utils.HttpClientUtil;
@@ -1,13 +1,13 @@
package org.example.core.publisher.impl;
import org.example.core.pojo.VideoToPublish;
import org.example.core.publisher.PlatformVideoPublisher;
import org.example.pojo.VideoToPublish;
import org.example.utils.GetScriptPath;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static org.example.util.GetScriptPath.getScriptPath;
/**
* @Description
@@ -23,7 +23,7 @@ public class DouyinVideoPublisher implements PlatformVideoPublisher {
try {
List<String> command = new ArrayList<>();
command.add("python"); // Python 解释器
command.add(getScriptPath(DOUYIN_PUBLISH_VIDEO).toString()); // 要运行的 Python 脚本文件名
command.add(GetScriptPath.getScriptPath(DOUYIN_PUBLISH_VIDEO).toString()); // 要运行的 Python 脚本文件名
//目前默认只有三个参数
command.add(video.getCookies());
command.add(video.getVideoPath());
@@ -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;
}
}
@@ -0,0 +1,108 @@
package org.example.pojo;
import lombok.Data;
/**
* @Description
* @Author welsir
* @Date 2023/10/13 19:02
*/
@Data
public class VideoToPublish {
private String videoPath;
private String cookies;
private PlatformType platform;
private String coverPath;
private String devicePath;
private String tag;
private String title;
private String type;
private VideoToPublish(Buider buider){
this.videoPath = buider.videoPath;
this.cookies = buider.cookies;
this.coverPath = buider.coverPath;
this.devicePath = buider.devicePath;
this.tag = buider.tag;
this.title = buider.title;
this.type = buider.type;
}
public static class Buider{
private String videoPath;
private String cookies;
private PlatformType platform;
private String coverPath;
private String devicePath;
private String tag;
private String title;
private String type;
public Buider(String videoPath,String cookies,int platform){
this.videoPath = videoPath;
this.cookies = cookies;
this.platform = PlatformType.getPlatform(platform);
}
public Buider setCoverPath(String coverPath) {
this.coverPath = coverPath;
return this;
}
public Buider setDevicePath(String devicePath) {
this.devicePath = devicePath;
return this;
}
public Buider setTag(String tag) {
this.tag = tag;
return this;
}
public Buider setTitle(String title) {
this.title = title;
return this;
}
public Buider setType(String type) {
this.type = type;
return this;
}
public String getVideoPath() {
return videoPath;
}
public String getCookies() {
return cookies;
}
public String getCoverPath() {
return coverPath;
}
public String getDevicePath() {
return devicePath;
}
public String getTag() {
return tag;
}
public String getTitle() {
return title;
}
public String getType() {
return type;
}
public VideoToPublish build(){
return new VideoToPublish(this);
}
}
}
@@ -0,0 +1,19 @@
package org.example.utils;
import java.io.File;
import java.nio.file.Path;
/**
* @Description
* @Author welsir
* @Date 2023/10/15 20:43
*/
public class GetScriptPath {
public static Path getScriptPath(String path){
// 构建绝对路径
File scriptFile = new File(path);
return Path.of(scriptFile.getAbsolutePath());
}
}
+1 -1
View File
@@ -32,5 +32,5 @@
"CreeperConfig":true
}
},
"updateTime":"2023-10-15 23:25:00"
"updateTime":"2023-10-16 17:13:50"
}