From c1fd29232eb6c4517e24efb73fd7f2ed4999ec48 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Mon, 9 May 2022 11:55:12 +0800 Subject: [PATCH] =?UTF-8?q?B=E7=AB=99=E6=A8=A1=E5=9D=97=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AD=97=E5=B9=95=E8=BF=87=E5=A4=A7=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20B=E7=AB=99=E6=A8=A1=E5=9D=97=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BB=85=E4=B8=8B=E8=BD=BD=E5=89=8D6=E5=88=86?= =?UTF-8?q?=E9=92=9F=E5=AD=97=E5=B9=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/qqbot/QQBotApplication.java | 2 +- .../com/yutou/qqbot/bilibili/AssTools.java | 16 ++++++------- .../qqbot/models/BiliBili/BiliVideo.java | 24 +++++++++++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index 777e3ce..de64df1 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class QQBotApplication { - public static final String version="QQBot v.1.2.27"; + public static final String version="QQBot v.1.2.28"; public static void main(String[] args) { System.out.println("version = " + version); SpringApplication.run(QQBotApplication.class, args); diff --git a/src/main/java/com/yutou/qqbot/bilibili/AssTools.java b/src/main/java/com/yutou/qqbot/bilibili/AssTools.java index f6c1153..899e2b2 100644 --- a/src/main/java/com/yutou/qqbot/bilibili/AssTools.java +++ b/src/main/java/com/yutou/qqbot/bilibili/AssTools.java @@ -49,15 +49,15 @@ public class AssTools { addBuilder("Original Script: 本字幕由@yutou生成"); addBuilder("ScriptType: v4.00+"); addBuilder("Collisions: Normal"); - addBuilder("PlayResX: 560"); - addBuilder("PlayResY: 420"); + addBuilder("PlayResX: 1920"); + addBuilder("PlayResY: 1080"); addBuilder("Timer: 10.0000"); addBuilder(""); addBuilder("[V4+ Styles]"); addBuilder("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, "); addBuilder("MarginL, MarginR, MarginV, Encoding"); - addBuilder("Style: Fix,Microsoft YaHei UI,25,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,1,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0"); - addBuilder("Style: R2L,Microsoft YaHei UI,14,&H00FFFFFF,&H000000FF,&H00161616,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,20,20,20,1"); + addBuilder("Style: Fix,Microsoft YaHei UI,45,&H66FFFFFF,&H66FFFFFF,&H66000000,&H66000000,1,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0"); + addBuilder("Style: R2L,Microsoft YaHei UI,45,&H00FFFFFF,&H000000FF,&H00161616,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,20,20,20,1"); addBuilder(""); addBuilder("[Events]"); addBuilder("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"); @@ -141,7 +141,7 @@ public class AssTools { new DecimalFormat("00").format(m), new DecimalFormat("00").format(s)); float x1, x2; - x1 = 560 + (danmuData.getDanmu().length() * 12.5f); + x1 = 1920 + (danmuData.getDanmu().length() * 12.5f); x2 = 0 - (danmuData.getDanmu().length() * 12.5f); String ass = String.format("Dialogue: 0,%s,%s,R2L,,20,20,2,,{\\move(%.1f,%d,%.1f,%d)\\c&%s\\alpha&H%s}%s", @@ -160,9 +160,9 @@ public class AssTools { private void addY() { - y += 25; - if (y >= 420) { - y = 25; + y += 30; + if (y >= 1080) { + y = 30; } } diff --git a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java index 57b88ff..9a47e33 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java @@ -154,12 +154,15 @@ public class BiliVideo extends Model { json.put("oid", cid); json.put("avid", avid); json.put("segment_index", segment_index); - byte[] http = BiliBiliUtils.http("https://api.bilibili.com/x/v2/dm/web/seg.so?" + HttpTools.toUrlParams(json), BiliBiliUtils.HTTP.GET, null, BiliBiliUtils.RET_MODEL.BYTE); try { - VideoDanMu.DmSegMobileReply parse = VideoDanMu.DmSegMobileReply.parseFrom(http); + List tmp, danmuList = new ArrayList<>(); + while (!(tmp = getDanmu(json)).isEmpty()) { + danmuList.addAll(tmp); + json.put("segment_index",++segment_index); + } AssTools tools = new AssTools(title); List list = new ArrayList<>(); - for (VideoDanMu.DanmakuElem elem : parse.getElemsList()) { + for (VideoDanMu.DanmakuElem elem : danmuList) { DanmuData danmuData = new DanmuData(); danmuData.setDanmu(elem.getContent()); danmuData.setFontSize(elem.getFontsize()); @@ -176,6 +179,18 @@ public class BiliVideo extends Model { } } + private List getDanmu(JSONObject json) { + try { + byte[] http = BiliBiliUtils.http("https://api.bilibili.com/x/v2/dm/web/seg.so?" + HttpTools.toUrlParams(json), BiliBiliUtils.HTTP.GET, null, BiliBiliUtils.RET_MODEL.BYTE); + VideoDanMu.DmSegMobileReply parse = VideoDanMu.DmSegMobileReply.parseFrom(http); + return parse.getElemsList(); + } catch (Exception e) { + e.printStackTrace(); + } + return new ArrayList<>(); + + } + private void save(String name, File videoFile, File audioFile) { List urls = new ArrayList<>(); @@ -263,9 +278,10 @@ public class BiliVideo extends Model { //video.downVideo("https://www.bilibili.com/video/BV1qF411T7Vf?spm_id_from=444.41.list.card_archive.click"); //唐诱正片 //video.downVideo("https://www.bilibili.com/video/BV1L44y147zR?spm_id_from=333.337.search-card.all.click"); - video.downVideo("https://www.bilibili.com/video/BV18L4y1H7rz?spm_id_from=333.999.0.0"); + // video.downVideo("https://www.bilibili.com/video/BV18L4y1H7rz?spm_id_from=333.999.0.0"); // int a=16|2048; // System.out.println("a = " + a); //video.downDanmu(428855000L,976216102L,"【都市_情感】《唐可可的诱惑》第一集",1); + video.downDanmu(711506339L, 641094440L, "泡泡", 1); } }