update RedisTools

update BTDownload
This commit is contained in:
2022-10-13 18:11:56 +08:00
parent c3ce37e1b4
commit 32b53a6a16
3 changed files with 94 additions and 2 deletions

View File

@@ -3,9 +3,7 @@ package com.yutou.nas.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.interfaces.ObjectInterface;
import java.io.File;
import java.util.concurrent.TimeUnit;
public class BTDownloadManager {
@@ -37,6 +35,7 @@ public class BTDownloadManager {
//添加到下载器
if (download(title, item.getJSONObject("enclosure").getString("link"))) {
//发通知到QQ
RedisTools.setHashMap("rss",PatternTools.getMagnetHash(item.getJSONObject("enclosure").getString("link")),item.toJSONString());
JSONArray array = getDownload(title);
array.add(item.getString("title"));
RedisTools.set(title, array.toJSONString());
@@ -108,6 +107,16 @@ public class BTDownloadManager {
public synchronized static void done(String path,String filename,String hash1,String hash2,String tid) {
grep(path,filename);
String hash=StringUtils.isEmpty(hash1)?StringUtils.isEmpty(hash2)?null:hash2:hash1;
if(hash!=null){
String map = RedisTools.getHashMap("rss", hash);
JSONObject item=JSON.parseObject(map);
if (item.containsKey("thumbnail")) {
onSend(item.getString("thumbnail"), item,item.getJSONObject("enclosure").getString("link"));
} else {
onSend(null, item,item.getJSONObject("enclosure").getString("link"));
}
}
}
private static void grep(String remoteLocation, String remoteName) {