diff --git a/src/main/java/com/yutou/nas/Controllers/BTDownloadController.java b/src/main/java/com/yutou/nas/Controllers/BTDownloadController.java index ff72a46..295da50 100644 --- a/src/main/java/com/yutou/nas/Controllers/BTDownloadController.java +++ b/src/main/java/com/yutou/nas/Controllers/BTDownloadController.java @@ -11,6 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; @Controller public class BTDownloadController { @@ -19,23 +23,50 @@ public class BTDownloadController { @ResponseBody @RequestMapping("/bt/down.do") - public String bt(){ + public String bt() { DmhyRssDownloadManager.getInstance().start(); AnimRssManager.scan(); return "ok"; } + @ResponseBody @RequestMapping("/bt/done.do") - public String done(String path,String filename,String hash1,String hash2,String tid){ - Log.i("BTDownloadController.done","path = " + path + ", filename = " + filename + ", hash1 = " + hash1 + ", hash2 = " + hash2 + ", tid = " + tid); + public String done(String path, String filename, String hash1, String hash2, String tid) { + Log.i("BTDownloadController.done", "path = " + path + ", filename = " + filename + ", hash1 = " + hash1 + ", hash2 = " + hash2 + ", tid = " + tid); BTDownloadManager.done(path, filename, hash1, hash2, tid); return "ok"; } + @ResponseBody @RequestMapping("/bt/download.do") - public String download(int id,boolean isDownloadNext,String url){ - Log.i("跳过下载","手动下载 id = " + id + ", isDownloadNext = " + isDownloadNext + ", url = " + url); - bangumiService.download(id,isDownloadNext,url); + public String download(int id, boolean isDownloadNext, String url) { + Log.i("跳过下载", "手动下载 id = " + id + ", isDownloadNext = " + isDownloadNext + ", url = " + url); + bangumiService.download(id, isDownloadNext, url); return "1"; } + + @ResponseBody + @RequestMapping("/qq/bt/download.do") + public String download(HttpServletRequest request) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + String title = null; + String url = null; + try { + BufferedInputStream stream = new BufferedInputStream(request.getInputStream()); + byte[] bytes = new byte[1024]; + int len = 0, size; + while ((len = stream.read(bytes)) != -1) { + outputStream.write(bytes, 0, len); + outputStream.flush(); + } + String str = outputStream.toString(); + JSONObject json = JSONObject.parseObject(str); + title = json.getString("title"); + url = json.getString("url"); + } catch (Exception e) { + e.printStackTrace(); + } + Log.i("QQ下载", "手动下载 title = " + title + ", url = " + url); + return "" + BTDownloadManager.download(title, url); + } } diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index 1fe6193..270ba74 100644 --- a/src/main/java/com/yutou/nas/NasApplication.java +++ b/src/main/java/com/yutou/nas/NasApplication.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import; @Import(DmhyRssDownloadManager.class) @SpringBootApplication public class NasApplication { - public static final String version = "1.2.18"; + public static final String version = "1.3"; public static void main(String[] args) { SpringApplication.run(NasApplication.class, args); diff --git a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java index 8cc8a8b..0b1c3b9 100644 --- a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java +++ b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java @@ -14,6 +14,7 @@ import org.slf4j.event.Level; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; public class BTDownloadManager { @@ -80,7 +81,7 @@ public class BTDownloadManager { public static boolean download(String title, String url) { try { - String exec = String.format("qbittorrent-nox --save-path=\"%sanim/%s\" \"%s\"" + /* String exec = String.format("qbittorrent-nox --save-path=\"%sanim/%s\" \"%s\"" , DownloadHomePath , title , url @@ -89,8 +90,20 @@ public class BTDownloadManager { Process process = Runtime.getRuntime().exec(new String[]{"sh" , "-c" , exec}); - process.waitFor(120, TimeUnit.SECONDS); - return true; + process.waitFor(120, TimeUnit.SECONDS);*/ + JSONObject json = new JSONObject(); + json.put("urls", url); + json.put("savepath", "anim/" + title); + + String data="urls="+url+"&savepath=anim/"+title; + String post = HttpTools.http_post_form( + ConfigTools.load(ConfigTools.CONFIG, "Qbittorrent.Url", String.class) + "/api/v2/torrents/add", + data.getBytes(StandardCharsets.UTF_8), + 0, + null + ); + Log.i("BT下载", post); + return post.toLowerCase().contains("ok"); } catch (Exception e) { e.printStackTrace(); } @@ -117,16 +130,16 @@ public class BTDownloadManager { } public synchronized static void done(String path, String filename, String hash1, String hash2, String tid) { - grep(path,filename); + 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); - String text="添加到库:"+item.getString("title")+"\n动漫花园地址:"+item.getString("link"); + String text = "添加到库:" + item.getString("title") + "\n动漫花园地址:" + item.getString("link"); if (!item.containsKey("thumbnail")) { - QQBotManager.getInstance().sendMessage(734332887,text); + QQBotManager.getInstance().sendMessage(734332887, text); } else { - QQBotManager.getInstance().sendMessage(734332887,item.getString("thumbnail"),text); + QQBotManager.getInstance().sendMessage(734332887, item.getString("thumbnail"), text); } } } @@ -145,15 +158,15 @@ public class BTDownloadManager { }, false, true); }*/ //AppTools.exec("/home/yutou/public/servier/tinyMediaManager/tinyMediaManager tvshow -u --scrapeUnscraped", null, false, true); - // AppTools.exec("/home/yutou/public/servier/tinyMediaManager/tinyMediaManager tvshow -u -w --scrapeUnscraped", null, false, true);//由系统脚本处理 + // AppTools.exec("/home/yutou/public/servier/tinyMediaManager/tinyMediaManager tvshow -u -w --scrapeUnscraped", null, false, true);//由系统脚本处理 } - public static String getTorrentFileHash(String magnet) { - String hash=null; + public static String getTorrentFileHash(String magnet) { + String hash = null; try { ProtocolContext.getInstance().register(MagnetProtocol.getInstance()); - ITaskSession session = ProtocolContext.getInstance().buildTaskSession(magnet); - hash=session.getName(); + ITaskSession session = ProtocolContext.getInstance().buildTaskSession(magnet); + hash = session.getName(); Tools.delDir("download"); } catch (DownloadException e) { e.printStackTrace(); @@ -166,7 +179,7 @@ public class BTDownloadManager { //Snail snail = Snail.SnailBuilder.newBuilder().enableAllProtocol().buildSync(); try { ProtocolContext.getInstance().register(MagnetProtocol.getInstance()); - ITaskSession session = ProtocolContext.getInstance().buildTaskSession("magnet:?xt=urn:btih:IQ4GD4AYEJP3PSLB26QTLUP27UDQ4RRX&dn=&tr=http%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=udp%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=http%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker.prq.to%2Fannounce&tr=http%3A%2F%2Fopen.acgtracker.com%3A1096%2Fannounce&tr=https%3A%2F%2Ft-115.rhcloud.com%2Fonly_for_ylbud&tr=http%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=http%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=udp%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftr.bangumi.moe%3A6969%2Fannounce&tr=http%3A%2F%2Ft.nyaatracker.com%2Fannounce&tr=http%3A%2F%2Fopen.nyaatorrents.info%3A6544%2Fannounce&tr=http%3A%2F%2Ft2.popgo.org%3A7456%2Fannonce&tr=http%3A%2F%2Fshare.camoe.cn%3A8080%2Fannounce&tr=http%3A%2F%2Fopentracker.acgnx.se%2Fannounce&tr=http%3A%2F%2Ftracker.acgnx.se%2Fannounce&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=http%3A%2F%2Fsukebei.tracker.wf%3A8888%2Fannounce&tr=http%3A%2F%2Ft.acg.rip%3A6699%2Fannounce&tr=https%3A%2F%2Ftr.bangumi.moe%3A9696%2Fannounce&tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=wss%3A%2F%2Ftracker.openwebtorrent.com%3A443%2Fannounce&tr=http%3A%2F%2F1337.abcvg.info%2Fannounce&tr=http%3A%2F%2F207.241.226.111%3A6969%2Fannounce&tr=http%3A%2F%2F207.241.231.226%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2001%3A1b10%3A1000%3A8101%3A0%3A242%3Aac11%3A2%5D%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2001%3A470%3A1%3A189%3A0%3A1%3A2%3A3%5D%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2a04%3Aac00%3A1%3A3dd8%3A%3A1%3A2710%5D%3A2710%2Fannounce&tr=http%3A%2F%2Fbt.okmp3.ru%3A2710%2Fannounce&tr=http%3A%2F%2Ffxtt.ru%2Fannounce&tr=http%3A%2F%2Fhome.yxgz.vip%3A6969%2Fannounce&tr=http%3A%2F%2Fmediaclub.tv%2Fannounce.php&tr=http%3A%2F%2Fmilanesitracker.tekcities.com%2Fannounce&tr=http%3A%2F%2Fopen.acgnxtracker.com%2Fannounce&tr=http%3A%2F%2Fopen.tracker.ink%3A6969%2Fannounce&tr=http%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=http%3A%2F%2Fopentracker.xyz%2Fannounce&tr=http%3A%2F%2Fretracker.hotplug.ru%3A2710%2Fannounce&tr=http%3A%2F%2Ft.overflow.biz%3A6969%2Fannounce&tr=http%3A%2F%2Ft.publictracker.xyz%3A6969%2Fannounce&tr=http%3A%2F%2Ftorrenttracker.nwc.acsalaska.net%3A6969%2Fannounce&tr=http%3A%2F%2Ftr.cili001.com%3A8070%2Fannounce&tr=http%3A%2F%2Ftracker.birkenwald.de%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.bt4g.com%3A2095%2Fannounce&tr=http%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.files.fm%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.gbitt.info%2Fannounce&tr=http%3A%2F%2Ftracker.hiyj.cn%2Fannounce&tr=http%3A%2F%2Ftracker.ipv6tracker.ru%2Fannounce&tr=http%3A%2F%2Ftracker.lelux.fi%2Fannounce&tr=http%3A%2F%2Ftracker.mywaifu.best%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.srv00.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.zerobytes.xyz%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker2.dler.org%2Fannounce&tr=http%3A%2F%2Fvps02.net.orel.ru%2Fannounce&tr=https%3A%2F%2F1337.abcvg.info%2Fannounce&tr=https%3A%2F%2Fcarbon-bonsai-621.appspot.com%2Fannounce&tr=https%3A%2F%2Fchihaya-heroku.120181311.xyz%2Fannounce&tr=https%3A%2F%2Fopentracker.cc%2Fannounce&tr=https%3A%2F%2Fopentracker.i2p.rocks%2Fannounce&tr=https%3A%2F%2Ftp.m-team.cc%2Fannounce.php&tr=https%3A%2F%2Ftr.abiir.top%2Fannounce&tr=https%3A%2F%2Ftr.abir.ga%2Fannounce&tr=https%3A%2F%2Ftr.abirxo.cf%2Fannounce&tr=https%3A%2F%2Ftr.burnabyhighstar.com%2Fannounce&tr=https%3A%2F%2Ftr.doogh.club%2Fannounce&tr=https%3A%2F%2Ftr.fuckbitcoin.xyz%2Fannounce&tr=https%3A%2F%2Ftr.highstar.shop%2Fannounce&tr=https%3A%2F%2Ftr.ready4.icu%2Fannounce&tr=https%3A%2F%2Ftr.torland.ga%2Fannounce&tr=https%3A%2F%2Ftracker.babico.name.tr%2Fannounce&tr=https%3A%2F%2Ftracker.imgoingto.icu%2Fannounce&tr=https%3A%2F%2Ftracker.iriseden.fr%2Fannounce&tr=https%3A%2F%2Ftracker.kuroy.me%2Fannounce&tr=https%3A%2F%2Ftracker.lelux.fi%2Fannounce&tr=https%3A%2F%2Ftracker.lilithraws.cf%2Fannounce&tr=https%3A%2F%2Ftracker.lilithraws.org%2Fannounce&tr=https%3A%2F%2Ftracker.nanoha.org%2Fannounce&tr=https%3A%2F%2Ftracker.nitrix.me%2Fannounce&tr=https%3A%2F%2Ftracker.yarr.pt%2Fannounce&tr=https%3A%2F%2Ftrackme.theom.nz%2Fannounce&tr=ws%3A%2F%2Fhub.bugout.link%3A80%2Fannounce&tr=http%3A%2F%2Fretracker.joxnet.ru%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce&tr=http%3A%2F%2Ftracker.skyts.net%3A6969%2Fannounce&tr=https%3A%2F%2Fabir0dev.github.io%2Fannounce&tr=https%3A%2F%2Ftracker.foreverpirates.co%2Fannounce&tr=http%3A%2F%2Ftracker.loadbt.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.swarm3.network%3A6969%2Fannounce&tr=http%3A%2F%2Fopenbittorrent.com%2Fannounce&tr=http%3A%2F%2Fpow7.com%2Fannounce&tr=http%3A%2F%2Fbuny.uk%3A6969%2Fannounce&tr=http%3A%2F%2Ffosstorrents.com%3A6969%2Fannounce&tr=http%3A%2F%2Fftp.pet%3A7777%2Fannounce&tr=http%3A%2F%2Frt.optizone.ru%2Fannounce&tr=http%3A%2F%2Ftracker.merded.xyz%3A8000%2Fannounce&tr=http%3A%2F%2Ftracker1.bt.moack.co.kr%2Fannounce&tr=https%3A%2F%2Ftracker.moeblog.cn%2Fannounce&tr=https%3A%2F%2Ftracker.tamersunion.org%2Fannounce&tr=http%3A%2F%2Fipv6.1337.cx%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.govt.hu%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.k.vu%3A6969%2Fannounce&tr=https%3A%2F%2Ftracker.feb217.tk%3A8443%2Fannounce&tr=https%3A%2F%2Ftracker.m-team.cc%2Fannounce.php"); + ITaskSession session = ProtocolContext.getInstance().buildTaskSession("magnet:?xt=urn:btih:IQ4GD4AYEJP3PSLB26QTLUP27UDQ4RRX&dn=&tr=http%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=udp%3A%2F%2F104.143.10.186%3A8000%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=http%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&tr=http%3A%2F%2Ftracker.prq.to%2Fannounce&tr=http%3A%2F%2Fopen.acgtracker.com%3A1096%2Fannounce&tr=https%3A%2F%2Ft-115.rhcloud.com%2Fonly_for_ylbud&tr=http%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=http%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&tr=udp%3A%2F%2Ftracker2.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker3.itzmx.com%3A6961%2Fannounce&tr=udp%3A%2F%2Ftracker4.itzmx.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftr.bangumi.moe%3A6969%2Fannounce&tr=http%3A%2F%2Ft.nyaatracker.com%2Fannounce&tr=http%3A%2F%2Fopen.nyaatorrents.info%3A6544%2Fannounce&tr=http%3A%2F%2Ft2.popgo.org%3A7456%2Fannonce&tr=http%3A%2F%2Fshare.camoe.cn%3A8080%2Fannounce&tr=http%3A%2F%2Fopentracker.acgnx.se%2Fannounce&tr=http%3A%2F%2Ftracker.acgnx.se%2Fannounce&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=http%3A%2F%2Fsukebei.tracker.wf%3A8888%2Fannounce&tr=http%3A%2F%2Ft.acg.rip%3A6699%2Fannounce&tr=https%3A%2F%2Ftr.bangumi.moe%3A9696%2Fannounce&tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=wss%3A%2F%2Ftracker.openwebtorrent.com%3A443%2Fannounce&tr=http%3A%2F%2F1337.abcvg.info%2Fannounce&tr=http%3A%2F%2F207.241.226.111%3A6969%2Fannounce&tr=http%3A%2F%2F207.241.231.226%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2001%3A1b10%3A1000%3A8101%3A0%3A242%3Aac11%3A2%5D%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2001%3A470%3A1%3A189%3A0%3A1%3A2%3A3%5D%3A6969%2Fannounce&tr=http%3A%2F%2F%5B2a04%3Aac00%3A1%3A3dd8%3A%3A1%3A2710%5D%3A2710%2Fannounce&tr=http%3A%2F%2Fbt.okmp3.ru%3A2710%2Fannounce&tr=http%3A%2F%2Ffxtt.ru%2Fannounce&tr=http%3A%2F%2Fhome.yxgz.vip%3A6969%2Fannounce&tr=http%3A%2F%2Fmediaclub.tv%2Fannounce.php&tr=http%3A%2F%2Fmilanesitracker.tekcities.com%2Fannounce&tr=http%3A%2F%2Fopen.acgnxtracker.com%2Fannounce&tr=http%3A%2F%2Fopen.tracker.ink%3A6969%2Fannounce&tr=http%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=http%3A%2F%2Fopentracker.xyz%2Fannounce&tr=http%3A%2F%2Fretracker.hotplug.ru%3A2710%2Fannounce&tr=http%3A%2F%2Ft.overflow.biz%3A6969%2Fannounce&tr=http%3A%2F%2Ft.publictracker.xyz%3A6969%2Fannounce&tr=http%3A%2F%2Ftorrenttracker.nwc.acsalaska.net%3A6969%2Fannounce&tr=http%3A%2F%2Ftr.cili001.com%3A8070%2Fannounce&tr=http%3A%2F%2Ftracker.birkenwald.de%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.bt4g.com%3A2095%2Fannounce&tr=http%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.files.fm%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.gbitt.info%2Fannounce&tr=http%3A%2F%2Ftracker.hiyj.cn%2Fannounce&tr=http%3A%2F%2Ftracker.ipv6tracker.ru%2Fannounce&tr=http%3A%2F%2Ftracker.lelux.fi%2Fannounce&tr=http%3A%2F%2Ftracker.mywaifu.best%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.srv00.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.zerobytes.xyz%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker2.dler.org%2Fannounce&tr=http%3A%2F%2Fvps02.net.orel.ru%2Fannounce&tr=https%3A%2F%2F1337.abcvg.info%2Fannounce&tr=https%3A%2F%2Fcarbon-bonsai-621.appspot.com%2Fannounce&tr=https%3A%2F%2Fchihaya-heroku.120181311.xyz%2Fannounce&tr=https%3A%2F%2Fopentracker.cc%2Fannounce&tr=https%3A%2F%2Fopentracker.i2p.rocks%2Fannounce&tr=https%3A%2F%2Ftp.m-team.cc%2Fannounce.php&tr=https%3A%2F%2Ftr.abiir.top%2Fannounce&tr=https%3A%2F%2Ftr.abir.ga%2Fannounce&tr=https%3A%2F%2Ftr.abirxo.cf%2Fannounce&tr=https%3A%2F%2Ftr.burnabyhighstar.com%2Fannounce&tr=https%3A%2F%2Ftr.doogh.club%2Fannounce&tr=https%3A%2F%2Ftr.fuckbitcoin.xyz%2Fannounce&tr=https%3A%2F%2Ftr.highstar.shop%2Fannounce&tr=https%3A%2F%2Ftr.ready4.icu%2Fannounce&tr=https%3A%2F%2Ftr.torland.ga%2Fannounce&tr=https%3A%2F%2Ftracker.babico.name.tr%2Fannounce&tr=https%3A%2F%2Ftracker.imgoingto.icu%2Fannounce&tr=https%3A%2F%2Ftracker.iriseden.fr%2Fannounce&tr=https%3A%2F%2Ftracker.kuroy.me%2Fannounce&tr=https%3A%2F%2Ftracker.lelux.fi%2Fannounce&tr=https%3A%2F%2Ftracker.lilithraws.cf%2Fannounce&tr=https%3A%2F%2Ftracker.lilithraws.org%2Fannounce&tr=https%3A%2F%2Ftracker.nanoha.org%2Fannounce&tr=https%3A%2F%2Ftracker.nitrix.me%2Fannounce&tr=https%3A%2F%2Ftracker.yarr.pt%2Fannounce&tr=https%3A%2F%2Ftrackme.theom.nz%2Fannounce&tr=ws%3A%2F%2Fhub.bugout.link%3A80%2Fannounce&tr=http%3A%2F%2Fretracker.joxnet.ru%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce&tr=http%3A%2F%2Ftracker.skyts.net%3A6969%2Fannounce&tr=https%3A%2F%2Fabir0dev.github.io%2Fannounce&tr=https%3A%2F%2Ftracker.foreverpirates.co%2Fannounce&tr=http%3A%2F%2Ftracker.loadbt.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.swarm3.network%3A6969%2Fannounce&tr=http%3A%2F%2Fopenbittorrent.com%2Fannounce&tr=http%3A%2F%2Fpow7.com%2Fannounce&tr=http%3A%2F%2Fbuny.uk%3A6969%2Fannounce&tr=http%3A%2F%2Ffosstorrents.com%3A6969%2Fannounce&tr=http%3A%2F%2Fftp.pet%3A7777%2Fannounce&tr=http%3A%2F%2Frt.optizone.ru%2Fannounce&tr=http%3A%2F%2Ftracker.merded.xyz%3A8000%2Fannounce&tr=http%3A%2F%2Ftracker1.bt.moack.co.kr%2Fannounce&tr=https%3A%2F%2Ftracker.moeblog.cn%2Fannounce&tr=https%3A%2F%2Ftracker.tamersunion.org%2Fannounce&tr=http%3A%2F%2Fipv6.1337.cx%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.govt.hu%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.k.vu%3A6969%2Fannounce&tr=https%3A%2F%2Ftracker.feb217.tk%3A8443%2Fannounce&tr=https%3A%2F%2Ftracker.m-team.cc%2Fannounce.php"); System.out.println(session.getName()); Tools.delDir("download"); } catch (DownloadException e) { diff --git a/src/main/java/com/yutou/nas/utils/HttpTools.java b/src/main/java/com/yutou/nas/utils/HttpTools.java index ec2a2a1..9537289 100644 --- a/src/main/java/com/yutou/nas/utils/HttpTools.java +++ b/src/main/java/com/yutou/nas/utils/HttpTools.java @@ -8,6 +8,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Set; @@ -74,7 +75,7 @@ public class HttpTools { connection.setReadTimeout(10 * 1000); //connection.addRequestProperty("Connection", "keep-alive"); //connection.addRequestProperty("User-Agent", getExtUa()); - //connection.addRequestProperty("content-type", "application/json"); + connection.addRequestProperty("content-type", "application/json"); connection.addRequestProperty("charset", "UTF-8"); OutputStream outputStream = connection.getOutputStream(); //System.out.println(new String(body)); @@ -100,6 +101,56 @@ public class HttpTools { } } } + public static String http_post_form(String url, byte[] body, int index, Map headers) { + String tmp; + StringBuilder str = new StringBuilder(); + try { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setRequestMethod("POST"); + if (headers != null) { + for (String key : headers.keySet()) { + connection.addRequestProperty(key, headers.get(key)); + } + } + if(body==null){ + body="".getBytes(); + } + connection.setDoOutput(true); + connection.setDoInput(true); + connection.addRequestProperty("User-Agent", getUa()); + connection.setConnectTimeout(5 * 1000); + connection.setReadTimeout(10 * 1000); + connection.setRequestProperty( "Content-Type", "multipart/form-data;"); + connection.setRequestProperty( "charset", "utf-8"); + connection.setRequestProperty( "Accept-Encoding", "gzip, deflate, br"); + + //connection.addRequestProperty("Connection", "keep-alive"); + //connection.addRequestProperty("User-Agent", getExtUa()); + //connection.addRequestProperty("content-type", "application/json"); + OutputStream outputStream = connection.getOutputStream(); + //System.out.println(new String(body)); + outputStream.write(body); + outputStream.flush(); + outputStream.close(); + connection.connect(); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + while ((tmp = reader.readLine()) != null) { + str.append(tmp); + } + String finalStr = str.toString(); + + connection.disconnect(); + reader.close(); + return finalStr; + } catch (Exception e) { + if (index < HttpRequestIndex) { + return http_post(url, body, index + 1, headers); + } else { + e.printStackTrace(); + return null; + } + } + } public static String getUa() { return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"; @@ -134,11 +185,12 @@ public class HttpTools { JSONObject json = new JSONObject(); json.put("pid", "102"); json.put("gid", "100584"); - json.put("gameKey", "0gha58u1c9FjZkeAsEmYIzTvp"); - json.put("access_token", "659c-S1gV0DwMXdYjPDlSrSLNYOvA8qUoCSvmdFEHvZugKgNX4Z2BCwF18A7W2gRdG7WiWfKsbZgF6YssZHhaozksI9RBn2QQFTXzmAHtbMd4ginEEtwdKmPCM4JbJGg1ollqoNE0PcGENpa4F3e7EdSOa_JFyE6XyUQN1iurJU3F8MZfLlTIcTR9USYoHX15vsAkCht_0mrapZblkeY1_8HFrmK8rlenbZLxccy7PrMz5eZ9uPPDJL5OYiEahyrtLENB8SVmlGofJfQw8wUjN8_XVZSfLMujdwz24"); - String url = "http://192.168.1.156:9020/Faxing/reg?" + - "&tpyeCode=dimai" + - "®ParamJson=" + json.toJSONString(); + json.put("message", "0gha58u1c9FjZkeAsEmYIzTvp"); + // json.put("access_token", "659c-S1gV0DwMXdYjPDlSrSLNYOvA8qUoCSvmdFEHvZugKgNX4Z2BCwF18A7W2gRdG7WiWfKsbZgF6YssZHhaozksI9RBn2QQFTXzmAHtbMd4ginEEtwdKmPCM4JbJGg1ollqoNE0PcGENpa4F3e7EdSOa_JFyE6XyUQN1iurJU3F8MZfLlTIcTR9USYoHX15vsAkCht_0mrapZblkeY1_8HFrmK8rlenbZLxccy7PrMz5eZ9uPPDJL5OYiEahyrtLENB8SVmlGofJfQw8wUjN8_XVZSfLMujdwz24"); + String url = "http://127.0.0.1:8002/qq/send.do"; + String data="data=abc&codd=1"; + data=json.toString(); + http_post(url,data.getBytes(StandardCharsets.UTF_8),0,null); /* ExecutorService service= Executors.newCachedThreadPool(); for (int i = 0; i < 3000; i++) { service.submit(new Runnable() { diff --git a/src/main/java/com/yutou/nas/utils/QQBotManager.java b/src/main/java/com/yutou/nas/utils/QQBotManager.java index a2dffa0..37d85c3 100644 --- a/src/main/java/com/yutou/nas/utils/QQBotManager.java +++ b/src/main/java/com/yutou/nas/utils/QQBotManager.java @@ -35,7 +35,7 @@ public class QQBotManager { json.put("message",text); Map header = new HashMap<>(); header.put("content-type", "application/json"); - return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+":802/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); + return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+"/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); } public String sendMessage(long qq,String text) { @@ -44,7 +44,7 @@ public class QQBotManager { json.put("message",text); Map header = new HashMap<>(); header.put("content-type", "application/json"); - return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+":802/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); + return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+"/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); } public String sendMessage(String imageUrl, String message) { @@ -57,7 +57,7 @@ public class QQBotManager { json.put("image", imageUrl); Map header = new HashMap<>(); header.put("content-type", "application/json"); - return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+":802/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); + return HttpTools.http_post("http://"+ConfigTools.load(ConfigTools.CONFIG,"nas_ip",String.class)+"/qq/send.do", json.toString().getBytes(StandardCharsets.UTF_8), 1, header); } diff --git a/src/main/java/com/yutou/nas/utils/RedisTools.java b/src/main/java/com/yutou/nas/utils/RedisTools.java index 787f20f..77d9d27 100644 --- a/src/main/java/com/yutou/nas/utils/RedisTools.java +++ b/src/main/java/com/yutou/nas/utils/RedisTools.java @@ -263,9 +263,9 @@ public class RedisTools { new Thread(new Runnable() { @Override public void run() { - Jedis jedis = getPoolRedis(); - if (jedis != null) - jedis.psubscribe(new Consumer(), "*"); +// Jedis jedis = getPoolRedis(); +// if (jedis != null) +// jedis.psubscribe(new Consumer(), "*"); } }).start();