完善BT下载器,机器人可以控制刷新下载了

This commit is contained in:
yutou
2021-04-08 15:40:59 +08:00
parent 07a239ab1e
commit bdc74957aa
17 changed files with 89 additions and 59 deletions

View File

@@ -39,12 +39,18 @@ public class BTDownloadManager implements ApplicationContextAware {
public void start() {
List<BangumiItem> list = bangumiService.getAllBangumi();
AnimationData data = new AnimationData();
for (BangumiItem item : list) {
String url = getRSSUrl(item);
String _json = HttpTools.get(url);
if (!StringUtils.isEmpty(_json)) {
JSONObject json = JSONObject.parseObject(_json);
item.setAuthor(data.nameToValue(item.getAuthor(),true)+"");
item.setCategories(data.nameToValue(item.getCategories(),false)+"");
download(item, json);
}else{
QQBotManager.getInstance().sendMessage(item.getTitle()+"\n下载失败");
Log.i(item.getTitle()+"\n下载失败");
}
}
}
@@ -76,7 +82,7 @@ public class BTDownloadManager implements ApplicationContextAware {
//发通知到QQ
JSONArray array = getDownload(bangumiItem.getTitle());
array.add(item.getString("title"));
RedisTools.set(bangumiItem.getTitle(), item.getString("title"));
RedisTools.set(bangumiItem.getTitle(), array.toJSONString());
if (item.containsKey("thumbnail")) {
HttpTools.download(item.getString("thumbnail"), bangumiItem.getTitle() + ".jpg", new DownloadInterface() {
@Override
@@ -102,8 +108,9 @@ public class BTDownloadManager implements ApplicationContextAware {
}
}
public void onSend(File file, JSONObject item) {
private void onSend(File file, JSONObject item) {
String text = "启动下载器\n已提交到下载:" + item.getString("title");
Log.i(text);
if (file == null) {
QQBotManager.getInstance().sendMessage(text);
} else {
@@ -154,7 +161,7 @@ public class BTDownloadManager implements ApplicationContextAware {
item.setTitle("無職轉生~到了異世界就拿出真本事~");
item.setTitlekey("无职转生");
String url = new BTDownloadManager().getRSSUrl(item);
System.out.println(url);
com.yutou.nas.utils.Log.i(url);
}
@Override
@@ -163,7 +170,7 @@ public class BTDownloadManager implements ApplicationContextAware {
BTDownloadManager.applicationContext = applicationContext;
}
public static <T> T getBean(Class<T> clazz) {
private static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
}