From 4d4a4a67272ed6b8fe93e6e5a367bd8de71532cf Mon Sep 17 00:00:00 2001 From: suifeng <369202865@qq.com> Date: Fri, 4 Aug 2023 11:47:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=97=E9=B1=BC=E5=BD=95=E6=92=AD=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/jarRepositories.xml | 5 + .idea/libraries/Msc.xml | 9 - .idea/libraries/json_jena_1_0.xml | 1 + .idea/misc.xml | 2 +- AccountModule/pom.xml | 5 + BarrageModule/pom.xml | 5 + CreeperModule/pom.xml | 5 + .../BarrageSaveFileAutoCreateTest.java | 42 +-- FileModule/pom.xml | 5 + .../java/org/example/cache/FileCacheTest.java | 246 +++++++++--------- .../java/org/example/util/FileUtilTest.java | 48 ++-- .../org/example/util/JsonFileUtilTest.java | 164 ++++++------ HotModule/pom.xml | 5 + .../org/example/config/HotModuleSetting.java | 2 +- .../lib/selenium-java-4.11.0-SNAPSHOT.jar | Bin 0 -> 870 bytes LiveRecordModule/pom.xml | 105 ++++++++ .../main/java/org/example/LiveStreamTest.java | 4 +- .../java/org/example/api/DouyuRecordApi.java | 41 +++ .../example/core/component/M3U8Handle.java | 53 ++++ .../example/core/component/SimpleRequest.java | 73 ++++++ .../example/core/factory/LiveTaskFactory.java | 12 +- .../org/example/core/manager/TaskManager.java | 2 +- .../core/parser/PlatformFlvUrlParser.java | 13 - .../core/parser/PlatformVideoUrlParser.java | 13 + .../parser/impl/BilibiliFlvUrlParser.java | 10 +- .../core/parser/impl/DouyuM3u8UrlParser.java | 76 ++++++ .../BilibiliLiveConfig.java | 10 +- .../example/pojo/live/DouyuRecordConfig.java | 22 ++ .../pojo/{liveConfig => live}/LiveConfig.java | 8 +- .../example/pojo/record/RecordDayEntry.java | 29 +++ .../org/example/pojo/record/RecordEntry.java | 36 +++ .../org/example/pojo/record/RecordList.java | 20 ++ .../main/java/org/example/pool/ConstPool.java | 11 + .../java/org/example/utils/DriverUtil.java | 25 ++ .../java/org/example/utils/FromatUtil.java | 31 +++ .../org/example/utils/VideoConverter.java | 4 +- PublishModule/pom.xml | 5 + SectionModule/pom.xml | 5 + SectionWorkModule/pom.xml | 5 + VideoSectionModule/pom.xml | 5 + .../java/org/example/constpool/ConstPool.java | 1 + console/pom.xml | 5 + pom.xml | 5 + 43 files changed, 877 insertions(+), 296 deletions(-) delete mode 100644 .idea/libraries/Msc.xml create mode 100644 LiveRecordModule/lib/selenium-java-4.11.0-SNAPSHOT.jar create mode 100644 LiveRecordModule/src/main/java/org/example/api/DouyuRecordApi.java create mode 100644 LiveRecordModule/src/main/java/org/example/core/component/M3U8Handle.java create mode 100644 LiveRecordModule/src/main/java/org/example/core/component/SimpleRequest.java delete mode 100644 LiveRecordModule/src/main/java/org/example/core/parser/PlatformFlvUrlParser.java create mode 100644 LiveRecordModule/src/main/java/org/example/core/parser/PlatformVideoUrlParser.java create mode 100644 LiveRecordModule/src/main/java/org/example/core/parser/impl/DouyuM3u8UrlParser.java rename LiveRecordModule/src/main/java/org/example/pojo/{liveConfig => live}/BilibiliLiveConfig.java (56%) create mode 100644 LiveRecordModule/src/main/java/org/example/pojo/live/DouyuRecordConfig.java rename LiveRecordModule/src/main/java/org/example/pojo/{liveConfig => live}/LiveConfig.java (65%) create mode 100644 LiveRecordModule/src/main/java/org/example/pojo/record/RecordDayEntry.java create mode 100644 LiveRecordModule/src/main/java/org/example/pojo/record/RecordEntry.java create mode 100644 LiveRecordModule/src/main/java/org/example/pojo/record/RecordList.java create mode 100644 LiveRecordModule/src/main/java/org/example/pool/ConstPool.java create mode 100644 LiveRecordModule/src/main/java/org/example/utils/DriverUtil.java create mode 100644 LiveRecordModule/src/main/java/org/example/utils/FromatUtil.java diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index 38fd58e..f1e415e 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -1,6 +1,11 @@ + + - + diff --git a/AccountModule/pom.xml b/AccountModule/pom.xml index 8cc4680..0684b36 100644 --- a/AccountModule/pom.xml +++ b/AccountModule/pom.xml @@ -24,5 +24,10 @@ 3.8.1 test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/BarrageModule/pom.xml b/BarrageModule/pom.xml index 42a520a..5348eeb 100644 --- a/BarrageModule/pom.xml +++ b/BarrageModule/pom.xml @@ -51,5 +51,10 @@ 0.11.5 compile + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/CreeperModule/pom.xml b/CreeperModule/pom.xml index 8827524..aa1b022 100644 --- a/CreeperModule/pom.xml +++ b/CreeperModule/pom.xml @@ -69,6 +69,11 @@ json 20210307 + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/CreeperModule/src/test/java/org/example/BarrageSaveFileAutoCreateTest.java b/CreeperModule/src/test/java/org/example/BarrageSaveFileAutoCreateTest.java index d1cee2a..5cc65ac 100644 --- a/CreeperModule/src/test/java/org/example/BarrageSaveFileAutoCreateTest.java +++ b/CreeperModule/src/test/java/org/example/BarrageSaveFileAutoCreateTest.java @@ -1,21 +1,21 @@ -package org.example; - -import org.example.exception.FileCacheException; -import org.example.pojo.configfile.BarrageSaveFile; -import org.example.pojo.download.LoadBarrageConfig; -import org.junit.jupiter.api.Test; - -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @author Genius - * @date 2023/05/06 04:07 - **/ -public class BarrageSaveFileAutoCreateTest { - - @Test - public void test() throws FileCacheException { - LoadBarrageConfig loadBarrageConfig = new LoadBarrageConfig("斗鱼","Post","大司马"); - BarrageSaveFile barrageSaveFile = new BarrageSaveFile(loadBarrageConfig,new ConcurrentLinkedQueue<>()); - } -} +//package org.example; +// +//import org.example.exception.FileCacheException; +//import org.example.pojo.configfile.BarrageSaveFile; +//import org.example.pojo.download.LoadBarrageConfig; +//import org.junit.jupiter.api.Test; +// +//import java.util.concurrent.ConcurrentLinkedQueue; +// +///** +// * @author Genius +// * @date 2023/05/06 04:07 +// **/ +//public class BarrageSaveFileAutoCreateTest { +// +// @Test +// public void test() throws FileCacheException { +// LoadBarrageConfig loadBarrageConfig = new LoadBarrageConfig("斗鱼","Post","大司马"); +// BarrageSaveFile barrageSaveFile = new BarrageSaveFile(loadBarrageConfig,new ConcurrentLinkedQueue<>()); +// } +//} diff --git a/FileModule/pom.xml b/FileModule/pom.xml index 7bfd12e..ccfe008 100644 --- a/FileModule/pom.xml +++ b/FileModule/pom.xml @@ -51,5 +51,10 @@ 1.0-SNAPSHOT compile + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/FileModule/src/test/java/org/example/cache/FileCacheTest.java b/FileModule/src/test/java/org/example/cache/FileCacheTest.java index 62950a7..9a35db0 100644 --- a/FileModule/src/test/java/org/example/cache/FileCacheTest.java +++ b/FileModule/src/test/java/org/example/cache/FileCacheTest.java @@ -1,123 +1,123 @@ -package org.example.cache; - -import org.example.constpool.GlobalFileCache; -import org.example.pojo.Student; -import org.example.pojo.configfile.ChopperBotConfigFile; -import org.example.exception.FileCacheException; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @author Genius - * @date 2023/04/24 03:30 - **/ - -public class FileCacheTest { - static FileCache cache; - - static{ - - try { - cache = new FileCache<>( - new CommonConfigFile( - "E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", - "test.json", - new ConcurrentLinkedQueue() - ) - ); - FileCacheManagerInstance.getInstance().addFileCache(cache); - } catch (FileCacheException e) { - throw new RuntimeException(e); - } - } - - @Test - public void TestFileCache() throws FileCacheException, InterruptedException { - ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); - FileCache fileCache = new FileCache(chopperBotConfigFile); - - FileCacheManager manager = new FileCacheManager(List.of(fileCache)); - manager.start(); - Thread.sleep(500000); - } - - @Test - public void TestFileCacheManager() throws FileCacheException, InterruptedException { - ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); - FileCache fileCache = new FileCache(chopperBotConfigFile); - FileCacheManager manager = new FileCacheManager(List.of(fileCache)); - manager.start(); - Thread.sleep(500000); - } - - @Test - public void TestGet() throws FileCacheException, InterruptedException { - ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); - FileCache fileCache = new FileCache(chopperBotConfigFile); - - FileCacheManager manager = new FileCacheManager(List.of(fileCache)); - manager.start(); - - fileCache.append(1,"barrage","src"); - } - - @Test - public void TestAppend() throws FileCacheException, InterruptedException { - FileCacheManagerInstance.getInstance().start(); - //追加数组的某个元素 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","0"); - } - //追加数组 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","-1"); - } - //追加类中的元素 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.append(i,"barrage","src"); - } - Thread.sleep(500000); - } - - @Test - public void TestWrite() throws FileCacheException,InterruptedException{ - FileCacheManagerInstance.getInstance().start(); - //更改数组元素 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","0"); - } - //追加数组 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","-1"); - } - //更改类中的元素 - for(int i=0;i<10;i++){ - GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"barrage","src"); - } - Thread.sleep(500000); - } - - @Test - public void TestArrayAdd() throws InterruptedException, FileCacheException { - ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); - FileCache fileCache = new FileCache(chopperBotConfigFile); - - FileCacheManager manager = new FileCacheManager(List.of(fileCache)); - manager.start(); - - } - - @Test - public void TestAddCache() throws FileCacheException, InterruptedException { - FileCacheManagerInstance.getInstance().start(); - - for(int i=0;i<10;i++){ - Student student = new Student(Integer.toString(i),i,"jsu"+i,"major"+i,null,null); - cache.writeKeys(student,"-1"); - } - Thread.sleep(500000); - } - -} +//package org.example.cache; +// +//import org.example.constpool.GlobalFileCache; +//import org.example.pojo.Student; +//import org.example.pojo.configfile.ChopperBotConfigFile; +//import org.example.exception.FileCacheException; +//import org.junit.jupiter.api.Test; +// +//import java.util.List; +//import java.util.concurrent.ConcurrentLinkedQueue; +// +///** +// * @author Genius +// * @date 2023/04/24 03:30 +// **/ +// +//public class FileCacheTest { +// static FileCache cache; +// +// static{ +// +// try { +// cache = new FileCache<>( +// new CommonConfigFile( +// "E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", +// "test.json", +// new ConcurrentLinkedQueue() +// ) +// ); +// FileCacheManagerInstance.getInstance().addFileCache(cache); +// } catch (FileCacheException e) { +// throw new RuntimeException(e); +// } +// } +// +// @Test +// public void TestFileCache() throws FileCacheException, InterruptedException { +// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); +// FileCache fileCache = new FileCache(chopperBotConfigFile); +// +// FileCacheManager manager = new FileCacheManager(List.of(fileCache)); +// manager.start(); +// Thread.sleep(500000); +// } +// +// @Test +// public void TestFileCacheManager() throws FileCacheException, InterruptedException { +// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); +// FileCache fileCache = new FileCache(chopperBotConfigFile); +// FileCacheManager manager = new FileCacheManager(List.of(fileCache)); +// manager.start(); +// Thread.sleep(500000); +// } +// +// @Test +// public void TestGet() throws FileCacheException, InterruptedException { +// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); +// FileCache fileCache = new FileCache(chopperBotConfigFile); +// +// FileCacheManager manager = new FileCacheManager(List.of(fileCache)); +// manager.start(); +// +// fileCache.append(1,"barrage","src"); +// } +// +// @Test +// public void TestAppend() throws FileCacheException, InterruptedException { +// FileCacheManagerInstance.getInstance().start(); +// //追加数组的某个元素 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","0"); +// } +// //追加数组 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","-1"); +// } +// //追加类中的元素 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.append(i,"barrage","src"); +// } +// Thread.sleep(500000); +// } +// +// @Test +// public void TestWrite() throws FileCacheException,InterruptedException{ +// FileCacheManagerInstance.getInstance().start(); +// //更改数组元素 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","0"); +// } +// //追加数组 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","-1"); +// } +// //更改类中的元素 +// for(int i=0;i<10;i++){ +// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"barrage","src"); +// } +// Thread.sleep(500000); +// } +// +// @Test +// public void TestArrayAdd() throws InterruptedException, FileCacheException { +// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile(); +// FileCache fileCache = new FileCache(chopperBotConfigFile); +// +// FileCacheManager manager = new FileCacheManager(List.of(fileCache)); +// manager.start(); +// +// } +// +// @Test +// public void TestAddCache() throws FileCacheException, InterruptedException { +// FileCacheManagerInstance.getInstance().start(); +// +// for(int i=0;i<10;i++){ +// Student student = new Student(Integer.toString(i),i,"jsu"+i,"major"+i,null,null); +// cache.writeKeys(student,"-1"); +// } +// Thread.sleep(500000); +// } +// +//} diff --git a/FileModule/src/test/java/org/example/util/FileUtilTest.java b/FileModule/src/test/java/org/example/util/FileUtilTest.java index b052951..e180931 100644 --- a/FileModule/src/test/java/org/example/util/FileUtilTest.java +++ b/FileModule/src/test/java/org/example/util/FileUtilTest.java @@ -1,24 +1,24 @@ -package org.example.util; - -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -/** - * @author Genius - * @date 2023/04/20 14:15 - **/ -public class FileUtilTest { - - @Test - public void testDelete() throws IOException { - FileUtil.deleteDirectory("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\trash"); - } - - @Test - public void testCreate() throws IOException { - Files.createDirectories(Paths.get("./Hello")); - } -} +//package org.example.util; +// +//import org.junit.jupiter.api.Test; +// +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +// +///** +// * @author Genius +// * @date 2023/04/20 14:15 +// **/ +//public class FileUtilTest { +// +// @Test +// public void testDelete() throws IOException { +// FileUtil.deleteDirectory("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\trash"); +// } +// +// @Test +// public void testCreate() throws IOException { +// Files.createDirectories(Paths.get("./Hello")); +// } +//} diff --git a/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java b/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java index 6941707..520e560 100644 --- a/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java +++ b/FileModule/src/test/java/org/example/util/JsonFileUtilTest.java @@ -1,82 +1,82 @@ -package org.example.util; - -import org.example.pojo.Student; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; - -/** - * @author Genius - * @date 2023/04/20 11:43 - **/ - -public class JsonFileUtilTest { - - @Test - public void writeMapObj() throws IOException { - Student student = new Student( - "Genius", - 18, - "HUST", - "CS", - List.of("Coding", "Reading", "Playing"), - Map.of("QQ", "123456789", "WeChat", "987654321") - ); - JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", - Map.of("Student", student,"hello","11234")); - Map stringObjectMap = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json"); - stringObjectMap.forEach( - (k,v)->{ - System.out.println(k); - System.out.println(v.getClass()); - } - ); - } - - - @Test - public void writeClassInJsonFile() { - Student student = new Student( - "Genius", - 18, - "HUST", - "CS", - List.of("Coding", "Reading", "Playing"), - Map.of("QQ", "123456789", "WeChat", "987654321") - ); - JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "student.json", student); - JsonFileUtil.writeBigJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", List.of(student)); - JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student3.json", student); - - System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student.json", Student.class)); - System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",List.class)); - } - - @Test - public void readJsonFile() { - Map maps = JsonFileUtil.readJsonFile("../config/", "moduleConfig.json"); - Object test = maps.get("module"); - System.out.println(test); - System.out.println(maps); - } - - @Test - public void writeJsonFile() { - Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json"); - JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test2.json", maps); - JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json", maps); - } - - @Test - public void writeJsonFileByJsonWriter() throws IOException { - Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json"); - Path dir = Paths.get("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json"); - JsonFileUtil.writeBigJsonFile(dir.toString(),maps); - } - - -} +//package org.example.util; +// +//import org.example.pojo.Student; +//import org.junit.jupiter.api.Test; +// +//import java.io.IOException; +//import java.nio.file.Path; +//import java.nio.file.Paths; +//import java.util.List; +//import java.util.Map; +// +///** +// * @author Genius +// * @date 2023/04/20 11:43 +// **/ +// +//public class JsonFileUtilTest { +// +// @Test +// public void writeMapObj() throws IOException { +// Student student = new Student( +// "Genius", +// 18, +// "HUST", +// "CS", +// List.of("Coding", "Reading", "Playing"), +// Map.of("QQ", "123456789", "WeChat", "987654321") +// ); +// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", +// Map.of("Student", student,"hello","11234")); +// Map stringObjectMap = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json"); +// stringObjectMap.forEach( +// (k,v)->{ +// System.out.println(k); +// System.out.println(v.getClass()); +// } +// ); +// } +// +// +// @Test +// public void writeClassInJsonFile() { +// Student student = new Student( +// "Genius", +// 18, +// "HUST", +// "CS", +// List.of("Coding", "Reading", "Playing"), +// Map.of("QQ", "123456789", "WeChat", "987654321") +// ); +// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "student.json", student); +// JsonFileUtil.writeBigJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", List.of(student)); +// JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student3.json", student); +// +// System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student.json", Student.class)); +// System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",List.class)); +// } +// +// @Test +// public void readJsonFile() { +// Map maps = JsonFileUtil.readJsonFile("../config/", "moduleConfig.json"); +// Object test = maps.get("module"); +// System.out.println(test); +// System.out.println(maps); +// } +// +// @Test +// public void writeJsonFile() { +// Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json"); +// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test2.json", maps); +// JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json", maps); +// } +// +// @Test +// public void writeJsonFileByJsonWriter() throws IOException { +// Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json"); +// Path dir = Paths.get("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json"); +// JsonFileUtil.writeBigJsonFile(dir.toString(),maps); +// } +// +// +//} diff --git a/HotModule/pom.xml b/HotModule/pom.xml index 288e9df..99cc2bf 100644 --- a/HotModule/pom.xml +++ b/HotModule/pom.xml @@ -29,5 +29,10 @@ 3.8.1 test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/HotModule/src/main/java/org/example/config/HotModuleSetting.java b/HotModule/src/main/java/org/example/config/HotModuleSetting.java index 01f5e29..6339085 100644 --- a/HotModule/src/main/java/org/example/config/HotModuleSetting.java +++ b/HotModule/src/main/java/org/example/config/HotModuleSetting.java @@ -12,7 +12,7 @@ import java.util.List; **/ @Data @AllArgsConstructor -public class HotModuleSetting { +public class HotModuleSetting { private String platform; //平台 diff --git a/LiveRecordModule/lib/selenium-java-4.11.0-SNAPSHOT.jar b/LiveRecordModule/lib/selenium-java-4.11.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..a63e635ce1cdb848ee32d4f83e189a687826a28d GIT binary patch literal 870 zcmWIWW@Zs#;Nak3U|?|M0upe*$-u(k>l)&y>*?pF|L+t712aQ_H#> zep`byG_`!6J}uJo^40P5y;!Ncl{r`ToVj$T$H^jCUwflY;EcwZ z6B~t(T=MqP@e@r;NKHxj%sTtRfddDQFfjMoSonR3MY1sigf}1test + + com.google.code.gson + gson + 2.9.1 + + + + cn.hutool + hutool-all + 5.7.19 + + org.json json 20210307 + + org.apache.poi + poi-ooxml + 5.0.0 + + + + org.example + CreeperModule + 1.0-SNAPSHOT + compile + + + + org.seleniumhq.selenium + selenium-java + 4.11.0 + + + + org.seleniumhq.selenium + selenium-api + 4.11.0 + + + org.seleniumhq.selenium + selenium-chrome-driver + 4.11.0 + + + org.seleniumhq.selenium + selenium-devtools-v113 + 4.11.0 + + + org.seleniumhq.selenium + selenium-devtools-v114 + 4.11.0 + + + org.seleniumhq.selenium + selenium-devtools-v115 + 4.11.0 + + + org.seleniumhq.selenium + selenium-devtools-v85 + 4.11.0 + + + org.seleniumhq.selenium + selenium-edge-driver + 4.11.0 + + + org.seleniumhq.selenium + selenium-firefox-driver + 4.11.0 + + + org.seleniumhq.selenium + selenium-ie-driver + 4.11.0 + + + org.seleniumhq.selenium + selenium-remote-driver + 4.11.0 + + + org.seleniumhq.selenium + selenium-safari-driver + 4.11.0 + + + + org.seleniumhq.selenium + selenium-support + 4.11.0 + + + + com.browserup + browserup-proxy-core + 2.1.1 + + + + net.lightbody.bmp + browsermob-core + 2.1.5 + test + diff --git a/LiveRecordModule/src/main/java/org/example/LiveStreamTest.java b/LiveRecordModule/src/main/java/org/example/LiveStreamTest.java index 5833c2c..e47bbb2 100644 --- a/LiveRecordModule/src/main/java/org/example/LiveStreamTest.java +++ b/LiveRecordModule/src/main/java/org/example/LiveStreamTest.java @@ -1,14 +1,14 @@ package org.example; import org.example.core.manager.TaskManager; -import org.example.pojo.liveConfig.BilibiliLiveConfig; +import org.example.pojo.live.BilibiliLiveConfig; public class LiveStreamTest { private static final int THREAD_NUM = 10; public static void main(String[] args) { // 创建直播配置 - BilibiliLiveConfig liveConfig = new BilibiliLiveConfig("732", "F:\\"); + BilibiliLiveConfig liveConfig = new BilibiliLiveConfig("732", "D:\\", "猪猪公主"); // 创建下载任务管理器 TaskManager taskManager = new TaskManager(THREAD_NUM); diff --git a/LiveRecordModule/src/main/java/org/example/api/DouyuRecordApi.java b/LiveRecordModule/src/main/java/org/example/api/DouyuRecordApi.java new file mode 100644 index 0000000..ef2e980 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/api/DouyuRecordApi.java @@ -0,0 +1,41 @@ +package org.example.api; + +import org.example.core.component.M3U8Handle; +import org.example.core.component.SimpleRequest; +import org.example.core.parser.impl.DouyuM3u8UrlParser; +import org.example.pojo.live.DouyuRecordConfig; +import org.example.pojo.record.RecordList; + +/** + * 斗鱼录播api + * @author 燧枫 + * @date 2023/8/1 21:53 + */ +public class DouyuRecordApi { + + // 根据主播id首次获取录播列表(默认为第一页,每页数量为20) + public static RecordList getRecordList(String upId) { + return getRecordList(upId, 1); + } + + // 指定页数获取录播列表 + public static RecordList getRecordList(String upId, int index) { + return SimpleRequest.getRecordList(upId, index); + } + + // 根据vid获取一场录播的M3U8下载链接 + public static String getM3U8ByVid(String vid) { + return new DouyuM3u8UrlParser().getUrl(new DouyuRecordConfig(vid, null, null, null,null)); + } + + // 根据M3U8链接,开始时间,结束时间,保存位置,文件名下载一个录播视频 + public static void downloadVideoByM3U8(String url, String startTime, String endTime, String downloadLocation, String outputFileName) { + M3U8Handle.downloadAndCutVideo(url, startTime, endTime, downloadLocation, outputFileName); + } + + public static void main(String[] args) { + String vid = "wLjGvLxr8yPvmO90"; + String url = getM3U8ByVid(vid); + downloadVideoByM3U8(url, "00:00:00", "00:10:00", "D://", "test.mp4"); + } +} diff --git a/LiveRecordModule/src/main/java/org/example/core/component/M3U8Handle.java b/LiveRecordModule/src/main/java/org/example/core/component/M3U8Handle.java new file mode 100644 index 0000000..0001088 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/core/component/M3U8Handle.java @@ -0,0 +1,53 @@ +package org.example.core.component; + +import org.example.pool.ConstPool; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.file.Paths; + +/** + * M3U8流处理器 + * @author 燧枫 + * @date 2023/8/3 12:47 + */ +public class M3U8Handle { + + // 指定开始时间与结束时间下载某个m3u8视频 + public static void downloadAndCutVideo(String url, String startTime, String endTime, String downloadLocation, String outputFileName) { + String outputFilePath = Paths.get(downloadLocation, outputFileName).toString(); + handleProcess(url, startTime, endTime, outputFilePath); + } + public static void downloadAndCutVideo(String url, long startTime, long endTime, String downloadLocation, String outputFileName) { + String outputFilePath = Paths.get(downloadLocation, outputFileName).toString(); + handleProcess(url, String.valueOf(startTime), String.valueOf(endTime), outputFilePath); + } + private static void handleProcess(String url, String startTime, String endTime, String outputFilePath) { + System.out.println("Starting video download and processing..."); + ProcessBuilder processBuilder = new ProcessBuilder( + ConstPool.FFMEPEG_PATH, + "-i", url, + "-ss", startTime, + "-to", endTime, + "-c", "copy", + "-y", + outputFilePath + ); + processBuilder.redirectErrorStream(true); + try { + Process process = processBuilder.start(); + try (BufferedReader inputReader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + String line; + while ((line = inputReader.readLine()) != null) { + System.out.println("FFmpeg output: " + line); + } + } + int exitCode = process.waitFor(); + System.out.println("Exit code: " + exitCode); + } catch (IOException | InterruptedException e) { + System.err.println("Error during video processing: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/LiveRecordModule/src/main/java/org/example/core/component/SimpleRequest.java b/LiveRecordModule/src/main/java/org/example/core/component/SimpleRequest.java new file mode 100644 index 0000000..27a0860 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/core/component/SimpleRequest.java @@ -0,0 +1,73 @@ +package org.example.core.component; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.example.pojo.record.RecordDayEntry; +import org.example.pojo.record.RecordEntry; +import org.example.pojo.record.RecordList; +import org.example.utils.HttpClientUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * 简单请求 + * @author 燧枫 + * @date 2023/8/1 22:19 + */ +public class SimpleRequest { + + // 斗鱼录播列表请求url + private static String DOUYU_RECORD_LIST = "https://v.douyu.com/wgapi/vod/center/authorShowVideoList?page=%S&limit=20&up_id=%s"; + + // 斗鱼指定天的录播列表 + private static String DOUYU_RECORD_DAY_LIST = "https://v.douyu.com/wgapi/vod/center/getShowReplayList?vid=%s&up_id=%s"; + + // 指定页数获取录播列表 + public static RecordList getRecordList(String upId, int index) { + String url = String.format(DOUYU_RECORD_LIST, index, upId); + JSONObject data = JSON.parseObject(HttpClientUtil.get(url)).getJSONObject("data"); + JSONArray recordListArray = data.getJSONArray("list"); + int count = data.getInteger("count"); + List recordDayEntryList = new ArrayList<>(); + recordListArray.forEach(o -> { + // 更新每天的数据 + JSONObject enter = (JSONObject) o; + RecordDayEntry recordDayEntry = new RecordDayEntry(); + recordDayEntry.setTitle(enter.getString("title")); + JSONObject temp = (JSONObject) enter.getJSONArray("video_list").get(0); + recordDayEntry.setAuthor(temp.getString("author")); + String hash_id = temp.getString("hash_id"); + recordDayEntry.setHashId(hash_id); + // 再更新单场的列表 + List recordEntryList = new ArrayList<>(); + String day_url = String.format(DOUYU_RECORD_DAY_LIST, hash_id, upId); + JSONObject day = JSON.parseObject(HttpClientUtil.get(day_url)).getJSONObject("data"); + recordDayEntry.setDate(day.getString("date")); + + JSONArray recordDayListArray = day.getJSONArray("list"); + recordDayListArray.forEach(single -> { + JSONObject one = (JSONObject) single; + RecordEntry recordEntry = new RecordEntry(); + recordEntry.setDuration(one.getString("video_duration")); + recordEntry.setViewNum(one.getInteger("view_num")); + recordEntry.setCover(one.getString("cover")); + recordEntry.setShowRemark(one.getString("show_remark")); + recordEntry.setShowId(one.getString("show_id")); + recordEntry.setAuthor(one.getString("nickname")); + recordEntry.setTitle(one.getString("title")); + recordEntry.setHashId(one.getString("hash_id")); + recordEntryList.add(recordEntry); + }); + recordDayEntry.setRecordEntryList(recordEntryList); + recordDayEntryList.add(recordDayEntry); + }); + RecordList recordList = new RecordList(); + recordList.setRecordDayCount(count); + recordList.setRecordDayEntryList(recordDayEntryList); + return recordList; + } + + +} diff --git a/LiveRecordModule/src/main/java/org/example/core/factory/LiveTaskFactory.java b/LiveRecordModule/src/main/java/org/example/core/factory/LiveTaskFactory.java index 2a3d6e0..bdfc91d 100644 --- a/LiveRecordModule/src/main/java/org/example/core/factory/LiveTaskFactory.java +++ b/LiveRecordModule/src/main/java/org/example/core/factory/LiveTaskFactory.java @@ -1,10 +1,10 @@ package org.example.core.factory; -import org.example.core.parser.PlatformFlvUrlParser; +import org.example.core.parser.PlatformVideoUrlParser; import org.example.core.parser.impl.BilibiliFlvUrlParser; import org.example.core.component.LiveStreamTask; -import org.example.pojo.liveConfig.BilibiliLiveConfig; -import org.example.pojo.liveConfig.LiveConfig; +import org.example.pojo.live.BilibiliLiveConfig; +import org.example.pojo.live.LiveConfig; import java.util.HashMap; import java.util.Map; @@ -16,7 +16,7 @@ import java.util.Map; */ public class LiveTaskFactory { - private final Map, PlatformFlvUrlParser> parserMap; + private final Map, PlatformVideoUrlParser> parserMap; public LiveTaskFactory() { this.parserMap = new HashMap<>(); @@ -27,12 +27,12 @@ public class LiveTaskFactory { // 根据LiveConfig去创建下载任务 public LiveStreamTask create(LiveConfig liveConfig) { - PlatformFlvUrlParser parser = this.parserMap.get(liveConfig.getClass()); + PlatformVideoUrlParser parser = this.parserMap.get(liveConfig.getClass()); if (parser == null) { throw new IllegalArgumentException("Unsupported live config type: " + liveConfig.getClass()); } try { - String flvUrl = parser.getFlvUrl(liveConfig); + String flvUrl = parser.getUrl(liveConfig); LiveStreamTask task = new LiveStreamTask(); task.setUrl(flvUrl); // 为任务添加请求头 diff --git a/LiveRecordModule/src/main/java/org/example/core/manager/TaskManager.java b/LiveRecordModule/src/main/java/org/example/core/manager/TaskManager.java index b989d64..5b76580 100644 --- a/LiveRecordModule/src/main/java/org/example/core/manager/TaskManager.java +++ b/LiveRecordModule/src/main/java/org/example/core/manager/TaskManager.java @@ -3,7 +3,7 @@ package org.example.core.manager; import org.example.core.component.LiveStreamTask; import org.example.core.component.StatusMonitor; import org.example.core.factory.LiveTaskFactory; -import org.example.pojo.liveConfig.LiveConfig; +import org.example.pojo.live.LiveConfig; import org.example.utils.VideoConverter; import java.io.FileNotFoundException; diff --git a/LiveRecordModule/src/main/java/org/example/core/parser/PlatformFlvUrlParser.java b/LiveRecordModule/src/main/java/org/example/core/parser/PlatformFlvUrlParser.java deleted file mode 100644 index ee7fa4b..0000000 --- a/LiveRecordModule/src/main/java/org/example/core/parser/PlatformFlvUrlParser.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.example.core.parser; - -import org.example.pojo.liveConfig.LiveConfig; - -/** - * 全直播平台flv链接解析接口 - * @author 燧枫 - * @date 2023/5/19 17:09 -*/ -public interface PlatformFlvUrlParser { - - String getFlvUrl(LiveConfig liveConfig) throws Exception; -} \ No newline at end of file diff --git a/LiveRecordModule/src/main/java/org/example/core/parser/PlatformVideoUrlParser.java b/LiveRecordModule/src/main/java/org/example/core/parser/PlatformVideoUrlParser.java new file mode 100644 index 0000000..012f878 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/core/parser/PlatformVideoUrlParser.java @@ -0,0 +1,13 @@ +package org.example.core.parser; + +import org.example.pojo.live.LiveConfig; + +/** + * 全直播平台flv链接解析接口 + * @author 燧枫 + * @date 2023/5/19 17:09 +*/ +public interface PlatformVideoUrlParser { + + String getUrl(LiveConfig liveConfig) throws Exception; +} \ No newline at end of file diff --git a/LiveRecordModule/src/main/java/org/example/core/parser/impl/BilibiliFlvUrlParser.java b/LiveRecordModule/src/main/java/org/example/core/parser/impl/BilibiliFlvUrlParser.java index d877a6b..70ef9e2 100644 --- a/LiveRecordModule/src/main/java/org/example/core/parser/impl/BilibiliFlvUrlParser.java +++ b/LiveRecordModule/src/main/java/org/example/core/parser/impl/BilibiliFlvUrlParser.java @@ -1,8 +1,8 @@ package org.example.core.parser.impl; -import org.example.core.parser.PlatformFlvUrlParser; -import org.example.pojo.liveConfig.BilibiliLiveConfig; -import org.example.pojo.liveConfig.LiveConfig; +import org.example.core.parser.PlatformVideoUrlParser; +import org.example.pojo.live.BilibiliLiveConfig; +import org.example.pojo.live.LiveConfig; import org.example.utils.HttpClientUtil; import org.json.JSONArray; import org.json.JSONObject; @@ -12,12 +12,12 @@ import org.json.JSONObject; * @author 燧枫 * @date 2023/5/16 20:42 */ -public class BilibiliFlvUrlParser implements PlatformFlvUrlParser { +public class BilibiliFlvUrlParser implements PlatformVideoUrlParser { String urlFormat = "https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=%s&protocol=0,1&format=0,1,2&codec=0,1&qn=%d&platform=web&ptype=8"; // 通过房间号roomId,clarity(画质,10000为原画画质),得到flv链接 - public String getFlvUrl(LiveConfig liveConfig) throws Exception { + public String getUrl(LiveConfig liveConfig) throws Exception { BilibiliLiveConfig bilibiliLiveConfig = (BilibiliLiveConfig) liveConfig; String roomId = bilibiliLiveConfig.getRoomId(); int clarity = bilibiliLiveConfig.getClarity(); diff --git a/LiveRecordModule/src/main/java/org/example/core/parser/impl/DouyuM3u8UrlParser.java b/LiveRecordModule/src/main/java/org/example/core/parser/impl/DouyuM3u8UrlParser.java new file mode 100644 index 0000000..e35138c --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/core/parser/impl/DouyuM3u8UrlParser.java @@ -0,0 +1,76 @@ +package org.example.core.parser.impl; + +import org.example.core.parser.PlatformVideoUrlParser; +import org.example.pojo.live.LiveConfig; +import org.openqa.selenium.devtools.DevTools; +import org.openqa.selenium.devtools.v115.network.Network; +import org.openqa.selenium.devtools.v115.network.model.Response; +import org.openqa.selenium.edge.EdgeDriver; +import org.openqa.selenium.edge.EdgeOptions; + +import java.util.Optional; +import java.util.logging.Logger; + +/** + * 斗鱼M3u8链接解析 + * @author 燧枫 + * @date 2023/8/3 21:52 + */ +public class DouyuM3u8UrlParser implements PlatformVideoUrlParser { + + private static String DOUYE_RECORD_M3U8 = "https://v.douyu.com/show/%s"; + + private static final Logger logger = Logger.getLogger(DouyuM3u8UrlParser.class.getName()); + + @Override + public String getUrl(LiveConfig liveConfig) { + + // 设置 WebDriver 的路径 + System.setProperty("webdriver.edge.driver", "E:\\edgDriver\\msedgedriver.exe"); + + // 创建 EdgeOptions 实例 + EdgeOptions edgeOptions = new EdgeOptions(); + // 设置为无头模式 + edgeOptions.addArguments("--headless"); + + // 创建 WebDriver + EdgeDriver driver = new EdgeDriver(edgeOptions); + + // 创建 DevTools 并建立会话 + DevTools devTools = driver.getDevTools(); + devTools.createSession(); + + // 启用 Network + devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); + + // 创建一个数组来存储获取到的视频链接 + final String[] videoUrl = new String[1]; + + // 添加监听器,监听 HTTP 响应 + devTools.addListener(Network.responseReceived(), response -> { + Response responseReceived = response.getResponse(); + String url = responseReceived.getUrl(); + if (url.contains("https://play-tx-recpub.douyucdn2.cn/live/") && url.contains("m3u8")) { + videoUrl[0] = url; + } + }); + + // 打开网页 + driver.get(String.format(DOUYE_RECORD_M3U8, liveConfig.getRoomId())); + logger.info("成功打开网页"); + + // 添加延迟以便获取链接 + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // 关闭浏览器和驱动 + driver.quit(); + + logger.info("获取到视频链接: " + videoUrl[0]); + + return videoUrl[0]; + } +} diff --git a/LiveRecordModule/src/main/java/org/example/pojo/liveConfig/BilibiliLiveConfig.java b/LiveRecordModule/src/main/java/org/example/pojo/live/BilibiliLiveConfig.java similarity index 56% rename from LiveRecordModule/src/main/java/org/example/pojo/liveConfig/BilibiliLiveConfig.java rename to LiveRecordModule/src/main/java/org/example/pojo/live/BilibiliLiveConfig.java index 6b5adbf..58ec12f 100644 --- a/LiveRecordModule/src/main/java/org/example/pojo/liveConfig/BilibiliLiveConfig.java +++ b/LiveRecordModule/src/main/java/org/example/pojo/live/BilibiliLiveConfig.java @@ -1,4 +1,4 @@ -package org.example.pojo.liveConfig; +package org.example.pojo.live; import lombok.Data; @@ -13,13 +13,13 @@ public class BilibiliLiveConfig extends LiveConfig { // 清晰度,10000为原画画质 private int clarity; - public BilibiliLiveConfig(String roomId, int clarity, String videoPath, boolean convertToMp4) { - super(roomId, videoPath, convertToMp4); + public BilibiliLiveConfig(String roomId, int clarity, String videoPath, String videoName, boolean convertToMp4) { + super(roomId, videoPath, videoName, convertToMp4); this.clarity = clarity; } - public BilibiliLiveConfig(String roomId, String videoPath) { - super(roomId, videoPath, true); + public BilibiliLiveConfig(String roomId, String videoPath, String videoName) { + super(roomId, videoPath, videoName, true); this.clarity = 10000; } } diff --git a/LiveRecordModule/src/main/java/org/example/pojo/live/DouyuRecordConfig.java b/LiveRecordModule/src/main/java/org/example/pojo/live/DouyuRecordConfig.java new file mode 100644 index 0000000..4dca4a1 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/pojo/live/DouyuRecordConfig.java @@ -0,0 +1,22 @@ +package org.example.pojo.live; + +import lombok.Data; + +/** + * + * @author 燧枫 + * @date 2023/8/3 22:23 + */ +@Data +public class DouyuRecordConfig extends LiveConfig { + + private String startTime; + + private String endTime; + + public DouyuRecordConfig(String roomId, String videoPath, String videoName, String startTime, String endTime) { + super(roomId, videoPath, videoName, false); + this.startTime = startTime; + this.endTime = endTime; + } +} diff --git a/LiveRecordModule/src/main/java/org/example/pojo/liveConfig/LiveConfig.java b/LiveRecordModule/src/main/java/org/example/pojo/live/LiveConfig.java similarity index 65% rename from LiveRecordModule/src/main/java/org/example/pojo/liveConfig/LiveConfig.java rename to LiveRecordModule/src/main/java/org/example/pojo/live/LiveConfig.java index bed8671..bad3ede 100644 --- a/LiveRecordModule/src/main/java/org/example/pojo/liveConfig/LiveConfig.java +++ b/LiveRecordModule/src/main/java/org/example/pojo/live/LiveConfig.java @@ -1,4 +1,4 @@ -package org.example.pojo.liveConfig; +package org.example.pojo.live; import lombok.Data; @@ -16,12 +16,16 @@ public class LiveConfig { // 视频保存路径 private String videoPath; + // 视频保存名称 + private String videoName; + // 是否自动转换为mp4格式 private boolean convertToMp4; - public LiveConfig(String roomId, String videoPath, boolean convertToMp4) { + public LiveConfig(String roomId, String videoPath, String videoName, boolean convertToMp4) { this.roomId = roomId; this.videoPath = videoPath; + this.videoName = videoName; this.convertToMp4 = convertToMp4; } } diff --git a/LiveRecordModule/src/main/java/org/example/pojo/record/RecordDayEntry.java b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordDayEntry.java new file mode 100644 index 0000000..4a446f9 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordDayEntry.java @@ -0,0 +1,29 @@ +package org.example.pojo.record; + +import lombok.Data; + +import java.util.List; + +/** + * 单天录播 + * @author 燧枫 + * @date 2023/8/1 22:09 + */ +@Data +public class RecordDayEntry { + + // 主播名 + private String author; + + // 录播的hashId + private String hashId; + + // 录播的标题 + private String title; + + // 录播的日期时间 + private String date; + + // 当天的列表 + private List recordEntryList; +} diff --git a/LiveRecordModule/src/main/java/org/example/pojo/record/RecordEntry.java b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordEntry.java new file mode 100644 index 0000000..b11d984 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordEntry.java @@ -0,0 +1,36 @@ +package org.example.pojo.record; + +import lombok.Data; + +/** + * 单场录播 + * @author 燧枫 + * @date 2023/8/2 12:47 + */ +@Data +public class RecordEntry { + + // 主播名 + private String author; + + // 录播的hashId + private String hashId; + + // show_id + private String showId; + + // 标题 + private String title; + + // 场次 + private String showRemark; + + // 时长 + private String duration; + + // 封面 + private String cover; + + // 观看人次 + private int viewNum; +} diff --git a/LiveRecordModule/src/main/java/org/example/pojo/record/RecordList.java b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordList.java new file mode 100644 index 0000000..bd1ba0d --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/pojo/record/RecordList.java @@ -0,0 +1,20 @@ +package org.example.pojo.record; + +import lombok.Data; + +import java.util.List; + +/** + * 录播列表 + * @author 燧枫 + * @date 2023/8/1 21:59 + */ +@Data +public class RecordList { + + // 主播录播总天数 + private int recordDayCount = 0; + + // 录播列表 + private List recordDayEntryList; +} diff --git a/LiveRecordModule/src/main/java/org/example/pool/ConstPool.java b/LiveRecordModule/src/main/java/org/example/pool/ConstPool.java new file mode 100644 index 0000000..a94ad44 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/pool/ConstPool.java @@ -0,0 +1,11 @@ +package org.example.pool; + +/** + * 常量池 + * @author 燧枫 + * @date 2023/8/3 14:03 + */ +public class ConstPool { + + public static String FFMEPEG_PATH = "D:\\test\\ffmpeg.exe"; +} diff --git a/LiveRecordModule/src/main/java/org/example/utils/DriverUtil.java b/LiveRecordModule/src/main/java/org/example/utils/DriverUtil.java new file mode 100644 index 0000000..f220328 --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/utils/DriverUtil.java @@ -0,0 +1,25 @@ +package org.example.utils; + +import java.util.Random; + +/** + * + * @author 燧枫 + * @date 2023/8/3 21:33 + */ +public class DriverUtil { + + static Random random = new Random(); + + // 随机暂停一段时间 + public static void randomSleep(int minTimeInSeconds, int maxTimeInSeconds) { + try { + int sleepTimeInMillis = (minTimeInSeconds + random.nextInt(maxTimeInSeconds - minTimeInSeconds + 1)) * 1000; + Thread.sleep(sleepTimeInMillis); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + +} diff --git a/LiveRecordModule/src/main/java/org/example/utils/FromatUtil.java b/LiveRecordModule/src/main/java/org/example/utils/FromatUtil.java new file mode 100644 index 0000000..bb07a1e --- /dev/null +++ b/LiveRecordModule/src/main/java/org/example/utils/FromatUtil.java @@ -0,0 +1,31 @@ +package org.example.utils; + +import java.time.Duration; +import java.util.regex.Pattern; + +/** + * 格式工具类 + * @author 燧枫 + * @date 2023/8/3 12:51 + */ +public class FromatUtil { + + private static final Pattern TIME_PATTERN = Pattern.compile("^\\d{2}:\\d{2}:\\d{2}$"); + + // 00:25:44->1544,01:45:24->6324 + public static long convertToSeconds(String timeString) { + if (TIME_PATTERN.matcher(timeString).matches()) { + String[] parts = timeString.split(":"); + long hours = Long.parseLong(parts[0]); + long minutes = Long.parseLong(parts[1]); + long seconds = Long.parseLong(parts[2]); + return Duration.ofHours(hours).plusMinutes(minutes).plusSeconds(seconds).getSeconds(); + } else { + try { + return Long.parseLong(timeString); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Invalid time format: " + timeString); + } + } + } +} diff --git a/LiveRecordModule/src/main/java/org/example/utils/VideoConverter.java b/LiveRecordModule/src/main/java/org/example/utils/VideoConverter.java index e3c845f..5a9ca4d 100644 --- a/LiveRecordModule/src/main/java/org/example/utils/VideoConverter.java +++ b/LiveRecordModule/src/main/java/org/example/utils/VideoConverter.java @@ -1,5 +1,7 @@ package org.example.utils; +import org.example.pool.ConstPool; + import java.io.IOException; /** @@ -10,7 +12,7 @@ import java.io.IOException; public class VideoConverter { public static void convertFlvToMp4(String inputPath, String outputPath) { - ProcessBuilder processBuilder = new ProcessBuilder("ffmpeg", "-i", inputPath, "-codec", "copy", outputPath); + ProcessBuilder processBuilder = new ProcessBuilder(ConstPool.FFMEPEG_PATH, "-i", inputPath, "-codec", "copy", outputPath); try { Process process = processBuilder.start(); process.waitFor(); diff --git a/PublishModule/pom.xml b/PublishModule/pom.xml index f023f82..0d4b221 100644 --- a/PublishModule/pom.xml +++ b/PublishModule/pom.xml @@ -24,5 +24,10 @@ 3.8.1 test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/SectionModule/pom.xml b/SectionModule/pom.xml index 34879d3..b8d4aa3 100644 --- a/SectionModule/pom.xml +++ b/SectionModule/pom.xml @@ -108,5 +108,10 @@ spring-boot-starter-test test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/SectionWorkModule/pom.xml b/SectionWorkModule/pom.xml index 72536a2..2b37c92 100644 --- a/SectionWorkModule/pom.xml +++ b/SectionWorkModule/pom.xml @@ -24,5 +24,10 @@ 3.8.1 test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/VideoSectionModule/pom.xml b/VideoSectionModule/pom.xml index 4dd9639..7f09268 100644 --- a/VideoSectionModule/pom.xml +++ b/VideoSectionModule/pom.xml @@ -24,5 +24,10 @@ 3.8.1 test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/common/src/main/java/org/example/constpool/ConstPool.java b/common/src/main/java/org/example/constpool/ConstPool.java index ec139c3..615573d 100644 --- a/common/src/main/java/org/example/constpool/ConstPool.java +++ b/common/src/main/java/org/example/constpool/ConstPool.java @@ -20,6 +20,7 @@ public class ConstPool { public static final String SECTION_WORK = "SectionWork"; public static final String HOT = "Hot"; public static final String PUBLISH = "Publish"; + public static final String LIVE_RECORD = "liveRecord"; /**其他**/ public static final String NULL_TIME = "nil"; diff --git a/console/pom.xml b/console/pom.xml index 72c0757..8b53e76 100644 --- a/console/pom.xml +++ b/console/pom.xml @@ -53,6 +53,11 @@ spring-boot-starter-test test + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 + diff --git a/pom.xml b/pom.xml index 65704c9..80d9a05 100644 --- a/pom.xml +++ b/pom.xml @@ -59,5 +59,10 @@ org.springframework.boot spring-boot-starter-web + + com.akamai.edgegrid + edgegrid-signer-core + 5.0.0 +