fix:异常优化及下载上传异步处理
This commit is contained in:
parent
2cbce1a574
commit
0a51d7e5e8
|
|
@ -8,8 +8,7 @@ EXPOSE 24803
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 创建 bin 目录
|
# 创建 bin 目录
|
||||||
RUN mkdir -p bin \
|
RUN mkdir -p config \
|
||||||
&& mkdir -p config \
|
|
||||||
&& mkdir -p lib \
|
&& mkdir -p lib \
|
||||||
&& mkdir -p log
|
&& mkdir -p log
|
||||||
|
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>com.bcrjl.rss</groupId>
|
<groupId>com.bcrjl.rss</groupId>
|
||||||
<artifactId>rss-reader</artifactId>
|
<artifactId>rss-reader</artifactId>
|
||||||
<version>0.4.0</version>
|
<version>0.4.2</version>
|
||||||
<name>RSS订阅阅读器</name>
|
<name>RSS订阅阅读器</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class FileMonitor {
|
||||||
"## 配置订阅频率\n" +
|
"## 配置订阅频率\n" +
|
||||||
"refresh = 5\n" +
|
"refresh = 5\n" +
|
||||||
"## 保存微博图片\n" +
|
"## 保存微博图片\n" +
|
||||||
"saveWeiBoImages=false" +
|
"saveWeiBoImages=false\n" +
|
||||||
"## 保存微博视频\n" +
|
"## 保存微博视频\n" +
|
||||||
"saveWeiBoVideo=true\n" +
|
"saveWeiBoVideo=true\n" +
|
||||||
"## 上传图片到AList\n" +
|
"## 上传图片到AList\n" +
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.file.FileWriter;
|
import cn.hutool.core.io.file.FileWriter;
|
||||||
import cn.hutool.core.io.resource.ResourceUtil;
|
import cn.hutool.core.io.resource.ResourceUtil;
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.extra.mail.MailAccount;
|
import cn.hutool.extra.mail.MailAccount;
|
||||||
import cn.hutool.extra.mail.MailUtil;
|
import cn.hutool.extra.mail.MailUtil;
|
||||||
|
|
@ -90,7 +91,12 @@ public class RssJob {
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
Setting setting = new Setting(CONFIG_PATH, CharsetUtil.CHARSET_UTF_8, true);
|
Setting setting = new Setting(CONFIG_PATH, CharsetUtil.CHARSET_UTF_8, true);
|
||||||
Setting emailSetting = setting.getSetting(SET_MAIL);
|
Setting emailSetting = setting.getSetting(SET_MAIL);
|
||||||
saveWeiBoImagesOrUpdateAList(list);
|
ThreadUtil.execAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
saveWeiBoImagesOrUpdateAList(list);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (emailSetting.getBool(MAIL_CONFIG_ENABLE) && emailSetting.getBool("sendUpdate")) {
|
if (emailSetting.getBool(MAIL_CONFIG_ENABLE) && emailSetting.getBool("sendUpdate")) {
|
||||||
// 如果邮箱开启且发送更新邮件开启 则推送通知
|
// 如果邮箱开启且发送更新邮件开启 则推送通知
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
|
@ -141,8 +147,8 @@ public class RssJob {
|
||||||
if(CollUtil.isNotEmpty(videoList)){
|
if(CollUtil.isNotEmpty(videoList)){
|
||||||
videoList.forEach(videoObj -> {
|
videoList.forEach(videoObj -> {
|
||||||
String fileName = HtmlUtils.getFileName(videoObj);
|
String fileName = HtmlUtils.getFileName(videoObj);
|
||||||
HttpResponse weiBoImagesHttpRequest = HtmlUtils.getWeiBoVideoHttpRequest(videoObj);
|
HttpResponse weiBoVideoHttpRequest = HtmlUtils.getWeiBoVideoHttpRequest(videoObj);
|
||||||
byte[] bytes = weiBoImagesHttpRequest.bodyBytes();
|
byte[] bytes = weiBoVideoHttpRequest.bodyBytes();
|
||||||
FileUtil.writeBytes(bytes, new File(VIDEO_PATH + fileName));
|
FileUtil.writeBytes(bytes, new File(VIDEO_PATH + fileName));
|
||||||
if (uploadAList) {
|
if (uploadAList) {
|
||||||
AListUtils.uploadFile(bytes, fileName);
|
AListUtils.uploadFile(bytes, fileName);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,10 @@ class HtmlUtilsTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void getWeiBoImagesHttpRequest() {
|
void getWeiBoImagesHttpRequest() {
|
||||||
|
String url="https://f.video.weibocdn.com/o0/Eglhl42Glx08hlnyHMZa01041200fr9J0E010.mp4?label=mp4_720p&template=720x1280.24.0&ori=0&ps=1CwnkDw1GXwCQx&Expires=1724122135&ssig=KmPchkXSzw&KID=unistore,video";
|
||||||
|
HttpResponse weiBoVideoHttpRequest = HtmlUtils.getWeiBoVideoHttpRequest(url);
|
||||||
|
byte[] bytes = weiBoVideoHttpRequest.bodyBytes();
|
||||||
|
FileUtil.writeBytes(bytes, new File(IMAGES_PATH + "Eglhl42Glx08hlnyHMZa01041200fr9J0E010.mp4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,14 +57,13 @@ class HtmlUtilsTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void getWeiBoVideosHttpRequest() {
|
void getWeiBoVideosHttpRequest() {
|
||||||
String url = "https://f.video.weibocdn.com/o0/KjwJ3CYwlx08hlyj0a8001041200ah0h0E010.mp4" +
|
String url="https://f.video.weibocdn.com/o0/Eglhl42Glx08hlnyHMZa01041200fr9J0E010.mp4?label=mp4_720p&template=720x1280.24.0&ori=0&ps=1CwnkDw1GXwCQx&Expires=1724122135&ssig=KmPchkXSzw&KID=unistore,video";
|
||||||
"?label=mp4_720p&template=720x960.24.0&ori=0&ps=1CwnkDw1GXwCQx&Expires=1724122135&ssig=Gd1gjIz05D&KID=unistore,video";
|
|
||||||
HttpRequest request = HttpRequest.get(url)
|
HttpRequest request = HttpRequest.get(url)
|
||||||
.header(Header.REFERER, "https://weibo.com/")
|
.header(Header.REFERER, "https://weibo.com/")
|
||||||
.header(Header.USER_AGENT, USER_AGENT)
|
.header(Header.USER_AGENT, USER_AGENT)
|
||||||
.timeout(20000);
|
.timeout(20000);
|
||||||
HttpResponse httpResponse = request.executeAsync();
|
HttpResponse httpResponse = request.executeAsync();
|
||||||
byte[] bytes = httpResponse.bodyBytes();
|
byte[] bytes = httpResponse.bodyBytes();
|
||||||
FileUtil.writeBytes(bytes, new File(IMAGES_PATH + "KjwJ3CYwlx08hlyj0a8001041200ah0h0E010.mp4"));
|
FileUtil.writeBytes(bytes, new File(IMAGES_PATH + "Eglhl42Glx08hlnyHMZa01041200fr9J0E010.mp4"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue