From a6b9e4a6ac71925419baf666a71aa9c937d1be6d Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 21 Oct 2021 12:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9Jellyfin=E7=9A=84?= =?UTF-8?q?=E6=90=9C=E5=88=AE=EF=BC=88=E4=BD=86=E6=9C=AA=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=EF=BC=89=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=9F=B3=E4=B9=90=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DBT=E4=B8=8B=E8=BD=BD=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nas/Controllers/MusicController.java | 45 +++- .../java/com/yutou/nas/NasApplication.java | 2 +- .../yutou/nas/utils/BTDownloadManager.java | 5 +- .../java/com/yutou/nas/utils/ConfigTools.java | 21 ++ .../yutou/nas/utils/JellyfinAPIManager.java | 196 ++++++++++++++++-- .../com/yutou/nas/utils/QQBotManager.java | 6 +- src/main/java/com/yutou/nas/utils/Tools.java | 5 + 7 files changed, 251 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/yutou/nas/Controllers/MusicController.java b/src/main/java/com/yutou/nas/Controllers/MusicController.java index 22e2ae2..cb342cd 100644 --- a/src/main/java/com/yutou/nas/Controllers/MusicController.java +++ b/src/main/java/com/yutou/nas/Controllers/MusicController.java @@ -3,14 +3,12 @@ package com.yutou.nas.Controllers; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yutou.nas.mybatis.model.MusicData; -import com.yutou.nas.utils.ConfigTools; +import com.yutou.nas.utils.*; import com.yutou.nas.Services.impl.MusicToolsServiceImpl; -import com.yutou.nas.utils.Tools; import org.springframework.core.io.FileSystemResource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import com.yutou.nas.utils.StringUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -21,6 +19,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Base64; import java.util.List; +import java.util.UUID; import static com.yutou.nas.Datas.AppData.defaultMusicPath; @@ -209,5 +208,45 @@ public class MusicController { return null; } } + @RequestMapping("/nas/music/share.do") + @ResponseBody + public JSONObject share(@RequestBody JSONObject data){ + System.out.println(data); + String file=data.getString("file"); + String token=data.getString("token"); + JSONObject json=new JSONObject(); + File music=new File(file); + if(music.exists()){ + String key=Tools.getMD5(UUID.randomUUID().toString()+music.getAbsolutePath()); + RedisTools.set(key,file,3600); + JSONObject item=new JSONObject(); + item.put("share",key); + json.put("code",1); + json.put("msg","ok"); + json.put("data",item); + }else{ + json.put("code",-1); + json.put("msg","文件不存在"); + json.put("data","{}"); + } + return json; + } + @RequestMapping("/nas/music/playShare.do") + @ResponseBody + public JSONObject playShare(String token) throws UnsupportedEncodingException { + JSONObject json=new JSONObject(); + String redis=RedisTools.get(token); + if(redis!=null&&!"-999".equals(token)){ + String file=redis; + JSONObject item=new JSONObject(); + item.put("file",file); + json.put("code",0); + json.put("data",item); + }else{ + json.put("code",-1); + json.put("msg","分享已过期"); + } + return json; + } } diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index f7f0a6a..f411cbd 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(BTDownloadManager.class) @SpringBootApplication public class NasApplication { - public static final String version="1.1.9"; + public static final String version="1.2"; public static void main(String[] args) { SpringApplication.run(NasApplication.class, args); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); diff --git a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java index b60b38e..57d1457 100644 --- a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java +++ b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; +import java.util.concurrent.TimeUnit; public class BTDownloadManager implements ApplicationContextAware { private static String tmpJson = "{\"status\":\"ok\",\"feed\":{\"url\":\"http://share.dmhy.org/topics/rss/page/1/rss.xml?keyword=无职转生&order=date-desc&sort_id=2&team_id=604\",\"title\":\"c.c动漫-動畫-動漫花園資源網\",\"link\":\"http://share.dmhy.org/\",\"author\":\"\",\"description\":\"動漫花園資訊網是一個動漫愛好者交流的平台,提供最及時,最全面的動畫,漫畫,動漫音樂,動漫下載,BT,ED,動漫遊戲,資訊,分享,交流,讨论.\",\"image\":\"\"},\"items\":[{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][11][BIG5][1080P][MP4]\",\"pubDate\":\"2021-03-25 07:11:12\",\"link\":\"http://share.dmhy.org/topics/view/563676_c_c_1_11_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/563676_c_c_1_11_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n

\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n

\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:LVYN5MDZTBFRNNSPYYXKOKJA5PNGB4FD&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][10][BIG5][1080P][MP4]\",\"pubDate\":\"2021-03-15 05:12:42\",\"link\":\"http://share.dmhy.org/topics/view/562725_c_c_1_10_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/562725_c_c_1_10_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:QWEVVDWHSWISWGLOQJWD2PRHP3OYJBD3&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][09][BIG5][1080P][MP4]\",\"pubDate\":\"2021-03-14 12:56:28\",\"link\":\"http://share.dmhy.org/topics/view/562653_c_c_1_09_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/562653_c_c_1_09_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:Z6M3M7Y5YTIKY4GGCG7PGEP3WWGORS7T&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][08][BIG5][1080P][MP4]\",\"pubDate\":\"2021-03-14 12:56:00\",\"link\":\"http://share.dmhy.org/topics/view/562652_c_c_1_08_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/562652_c_c_1_08_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:BMXA6AZF7BCYQ2CIZOS5I6XPTXUZ2W3E&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][07][BIG5][1080P][MP4]\",\"pubDate\":\"2021-02-23 09:41:47\",\"link\":\"http://share.dmhy.org/topics/view/560768_c_c_1_07_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/560768_c_c_1_07_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:DDIM47E2UJAXRV54JJQFFPJ7SLYZZYQJ&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][06][BIG5][1080P][MP4]\",\"pubDate\":\"2021-02-14 16:51:36\",\"link\":\"http://share.dmhy.org/topics/view/559914_c_c_1_06_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/559914_c_c_1_06_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:MFQR2G2AEZLHXONGKII47FXP2DPE4C3G&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][05][BIG5][1080P][MP4]\",\"pubDate\":\"2021-02-07 16:33:23\",\"link\":\"http://share.dmhy.org/topics/view/559282_c_c_1_05_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/559282_c_c_1_05_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:TUDQWT6OAHYS2LFTCURHRLNZS6PVZXX5&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][04][BIG5][1080P][MP4]\",\"pubDate\":\"2021-01-31 16:36:34\",\"link\":\"http://share.dmhy.org/topics/view/558624_c_c_1_04_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/558624_c_c_1_04_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:MVJ3F3DGW5Y4Z7LONWEWN6GBSQAC3TKQ&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][03][BIG5][1080P][MP4]\",\"pubDate\":\"2021-01-25 05:27:50\",\"link\":\"http://share.dmhy.org/topics/view/558007_c_c_1_03_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/558007_c_c_1_03_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][03][BIG5][1080P][MP4]

\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][03][BIG5][1080P][MP4]

\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:OR6WDFDYDAPOGFR3FY3LLCF25P3PHUTG&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]},{\"title\":\"\u200B[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][02][BIG5][1080P][MP4]\",\"pubDate\":\"2021-01-17 16:35:55\",\"link\":\"http://share.dmhy.org/topics/view/557306_c_c_1_02_BIG5_1080P_MP4.html\",\"guid\":\"http://share.dmhy.org/topics/view/557306_c_c_1_02_BIG5_1080P_MP4.html\",\"author\":\"lleeopen\",\"thumbnail\":\"https://img.vim-cn.com/43/a8c19df5571ea68c64ed4945cc0187bd82e2f1.jpg\",\"description\":\"\\n

[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][02][BIG5][1080P][MP4]

\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"content\":\"\\n

[c.c動漫][1月新番][無職轉生~到了異世界就拿出真本事~][02][BIG5][1080P][MP4]

\\n

P.s.請使用正規的BT軟件下載(utorrent、qbittorrent、bitcomet),下載完成之後不要立即關閉下載軟件,盡量保持上傳一段時間~~

\\n


\\n\",\"enclosure\":{\"link\":\"magnet:?xt=urn:btih:TGON2SU75VGPYQBOHMCXF7M6MNSYS7J3&dn=&tr=http://104.238.198.186:8000/announce&tr=udp://104.238.198.186:8000/announce&tr=http://tracker.openbittorrent.com:80/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=http://tracker4.itzmx.com:2710/announce&tr=http://tracker.publicbt.com:80/announce&tr=http://tracker.prq.to/announce&tr=http://open.acgtracker.com:1096/announce&tr=https://t-115.rhcloud.com/only_for_ylbud&tr=http://tracker1.itzmx.com:8080/announce&tr=http://tracker2.itzmx.com:6961/announce&tr=udp://tracker1.itzmx.com:8080/announce&tr=udp://tracker2.itzmx.com:6961/announce&tr=udp://tracker3.itzmx.com:6961/announce&tr=udp://tracker4.itzmx.com:2710/announce&tr=http://tr.bangumi.moe:6969/announce&tr=http://t.nyaatracker.com/announce&tr=http://open.nyaatorrents.info:6544/announce&tr=http://t2.popgo.org:7456/annonce&tr=http://share.camoe.cn:8080/announce&tr=http://opentracker.acgnx.se/announce&tr=http://tracker.acgnx.se/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=http://t.acg.rip:6699/announce&tr=http://opentracker.acgnx.com:6869/announce\",\"type\":\"application/x-bittorrent\",\"length\":1},\"categories\":[\"動畫\"]}]}"; @@ -23,7 +24,7 @@ public class BTDownloadManager implements ApplicationContextAware { @Resource IBangumiService bangumiService; private static BTDownloadManager manager; - private static final String DownloadHomePath="/media/yutou/disk_lvm/public/"; + private static final String DownloadHomePath="/media/yutou/disk_lvm/public/download/"; public static BTDownloadManager getInstance() { if (manager == null) { @@ -134,7 +135,7 @@ public class BTDownloadManager implements ApplicationContextAware { Process process=Runtime.getRuntime().exec(new String[]{"sh" , "-c" , exec}); - process.exitValue(); + process.waitFor(120, TimeUnit.SECONDS); return true; } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/yutou/nas/utils/ConfigTools.java b/src/main/java/com/yutou/nas/utils/ConfigTools.java index abbca2f..d2ca2ff 100644 --- a/src/main/java/com/yutou/nas/utils/ConfigTools.java +++ b/src/main/java/com/yutou/nas/utils/ConfigTools.java @@ -54,6 +54,27 @@ public class ConfigTools { return def; } + public static String loadIni(File file, String key) { + try { + BufferedReader reader = new BufferedReader(new FileReader(file)); + String tmp, str = null; + while ((tmp = reader.readLine()) != null) { + if(tmp.startsWith(key+"=")){ + str=tmp.split("=")[1]; + if(StringUtils.isEmpty(str)){ + str=null; + } + break; + } + } + return str; + + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + public static boolean save(String type, String key, Object data) { File file = new File(type); String src = readFile(file); diff --git a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java index 0502a4a..299b433 100644 --- a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java +++ b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java @@ -9,13 +9,20 @@ import lombok.Data; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.OffsetDateTime; import java.util.*; public class JellyfinAPIManager { - public static LibsItem getLibs(String key) { + private List mediaItem=new ArrayList<>(); + + public JellyfinAPIManager() { + mediaItem=getAllItem(); + } + + public LibsItem getLibs(String key) { HashMap header = getHeader(); String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items", header); JSONObject json = JSONObject.parseObject(httpText); @@ -32,21 +39,39 @@ public class JellyfinAPIManager { return null; } - public static List getLibsItems(String id) { + public ItemInfo getInfo(String id) { + String http = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items/"+id, getHeader()); + return JSONObject.parseObject(http,ItemInfo.class); + } + + public List getAllItem() { + String http = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items?SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Series&Recursive=true&Fields=PrimaryImageAspectRatio%2CBasicSyncInfo&ImageTypeLimit=1&EnableImageTypes=Primary%2CBackdrop%2CBanner%2CThumb&ParentId=28e774baf8f2fd279e7d58da9890a7d2", getHeader()); + JSONObject json = JSONObject.parseObject(http); + + JSONArray items = json.getJSONArray("Items"); + List list = JSONArray.parseArray(items.toJSONString(), LibsItem.class); + for (LibsItem item : list) { + item.setInfo(getInfo(item.getId())); + } + return list; + } + + public List getLibsItems(String id) { String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items?ParentId=" + id, getHeader()); JSONObject json = JSONObject.parseObject(httpText); JSONArray items = json.getJSONArray("Items"); return JSONArray.parseArray(items.toJSONString(), LibsItem.class); } - public static JSONObject getItemShows(String id) { - String data=HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Seasons?userId=e8a13675bb64466dbd81f1e5985ef8c7", + public JSONObject getItemShows(String id) { + String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Seasons?userId=e8a13675bb64466dbd81f1e5985ef8c7", id - ),getHeader()); + ), getHeader()); return JSONObject.parseObject(data); } - public static void uploadImage(File image, String id, String model) { + + public void uploadImage(File image, String id, String model) { try { HashMap header = getHeader(); header.put("Content-Type", "image/jpg"); @@ -66,7 +91,8 @@ public class JellyfinAPIManager { e.printStackTrace(); } } - public static void saveJellyfinMetaData(JSONObject info, JellyfinAPIManager.LibsItem item) { + + public void saveJellyfinMetaData(JSONObject info, JellyfinAPIManager.LibsItem item) { JSONArray airDate = new JSONArray(); airDate.add(info.getString("air_date")); JSONObject providerIds = new JSONObject(); @@ -113,7 +139,7 @@ public class JellyfinAPIManager { metadata.put("PreferredMetadataCountryCode", ""); metadata.put("RunTimeTicks", 0); metadata.put("Taglines", new JSONArray()); - HashMap headers = JellyfinAPIManager.getHeader(); + HashMap headers = getHeader(); headers.put("Content-Type", "application/json"); System.out.println(metadata.toString().replace("\"null\"", "null")); String ret = HttpTools.http_post("http://192.168.31.88:8096/Items/" + item.getId() @@ -123,16 +149,16 @@ public class JellyfinAPIManager { System.out.println(ret); HttpTools.download( info.getJSONObject("images").getString("large").replace("http:", "https:"), - "poster.jpg", + item.getName() + "_poster.jpg", new DownloadInterface() { @Override public void onDownload(File file) { super.onDownload(file); - JellyfinAPIManager.uploadImage(file, item.getId(), "Primary"); - JSONObject items = JellyfinAPIManager.getItemShows(item.getId()); + uploadImage(file, item.getId(), "Primary"); + JSONObject items = getItemShows(item.getId()); for (Object o : items.getJSONArray("Items")) { JSONObject json = (JSONObject) o; - JellyfinAPIManager.uploadImage(file, json.getString("Id"), "Primary"); + uploadImage(file, json.getString("Id"), "Primary"); } } @@ -140,7 +166,7 @@ public class JellyfinAPIManager { ); } - public static HashMap getHeader() { + public HashMap getHeader() { HashMap header = new HashMap<>(); header.put("X-Emby-Authorization", "MediaBrowser Client=\"Jellyfin CLI\", Device=\"Jellyfin-CLI\", DeviceId=\"None\", Version=\"10.7.6\", Token=\"81be0169523e463a8c36a7b752d60ab2\""); return header; @@ -160,9 +186,59 @@ public class JellyfinAPIManager { private List backdropImageTags; private Object imageBlurHashes; private String locationType; + private ItemInfo info; } + @Data + public static class ItemInfo { + private String name; + private String serverID; + private String id; + private String etag; + private OffsetDateTime dateCreated; + private OffsetDateTime dateLastMediaAdded; + private boolean canDelete; + private boolean canDownload; + private String sortName; + private Object[] externalUrls; + private String path; + private boolean enableMediaSourceDisplay; + private Object channelID; + private Object[] taglines; + private Object[] genres; + private String playAccess; + private Object[] remoteTrailers; + private boolean isFolder; + private String parentID; + private String type; + private Object[] people; + private Object[] studios; + private Object[] genreItems; + private long localTrailerCount; + private UserData userData; + private long recursiveItemCount; + private long childCount; + private long specialFeatureCount; + private String displayPreferencesID; + private Object[] airDays; + private Object[] tags; + private double primaryImageAspectRatio; + private ImageTags imageTags; + private String[] backdropImageTags; + private Object[] screenshotImageTags; + private String locationType; + private Object[] lockedFields; + private boolean lockData; + + public String getPath() { + if(AppTools.isRuntimeSystemOfWindow()){ + path=path.replace("/media/yutou/disk_lvm/public/download/anim/","Z:\\download\\anim\\"); + } + return path; + } + } + @Data public static class UserData { private long playbackPositionTicks; @@ -177,19 +253,99 @@ public class JellyfinAPIManager { private String primary; } - public static void main(String[] args) { - JellyfinAPIManager.LibsItem item = JellyfinAPIManager.getLibs("番剧"); + public void testItem(String id) { + JellyfinAPIManager manager = new JellyfinAPIManager(); + JellyfinAPIManager.LibsItem item = manager.getLibs("番剧"); if (item != null) { List list; - list = JellyfinAPIManager.getLibsItems(item.getId()); + list = manager.getLibsItems(item.getId()); for (JellyfinAPIManager.LibsItem libsItem : list) { - if ("寒蝉鸣泣之时_卒".equals(libsItem.getName())) { - saveJellyfinMetaData( - BangumiTools.getBangumiInfo(331033), + if ("轻音少女".equals(libsItem.getName())) { + /* saveJellyfinMetaData( + BangumiTools.getBangumiInfo(1424), libsItem - ); + );*/ + System.out.println("libsItem = " + libsItem); + System.out.println(manager.getItemShows(libsItem.getId())); + JSONObject json = manager.getItemShows(libsItem.getId()); + JSONArray array = json.getJSONArray("Items"); + for (Object o : array) { + JSONObject _json = (JSONObject) o; + System.out.println(_json.getString("Name")); + + if (_json.getString("Name").equals("第一季")) { + JellyfinAPIManager.LibsItem _item = JSONObject.parseObject(_json.toJSONString(), JellyfinAPIManager.LibsItem.class); + manager.saveJellyfinMetaData( + BangumiTools.getBangumiInfo(1424), + _item + ); + } else if (_json.getString("Name").equals("第二季")) { + JellyfinAPIManager.LibsItem _item = JSONObject.parseObject(_json.toJSONString(), JellyfinAPIManager.LibsItem.class); + manager.saveJellyfinMetaData( + BangumiTools.getBangumiInfo(3774), + _item + ); + } else if (_json.getString("Name").contains("[剧场版]")) { + JellyfinAPIManager.LibsItem _item = JSONObject.parseObject(_json.toJSONString(), JellyfinAPIManager.LibsItem.class); + manager.saveJellyfinMetaData( + BangumiTools.getBangumiInfo(12426), + _item + ); + } + + + } + /* System.out.println("libsItem = " + libsItem); + testItem(libsItem.getId());*/ } } } } + + public void search(String name, File path) { + for (LibsItem item : mediaItem) { + System.out.println(item.getName()+" > "+item.getInfo().getPath()); + } + } + + public void init(File path) { + if (path.isDirectory()) { + File file = new File(path.getAbsolutePath() + File.separator + "info.ini"); + if (!file.exists()) { + try { + file.createNewFile(); + System.out.println("创建:" + file.getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + String id = ConfigTools.loadIni(file, "id"); + if (id != null) { + for (LibsItem item : mediaItem) { + + if(item.getInfo().getPath().contains(path.getPath())){ + System.out.println(item.getName()+" "+id); + // new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)),item); + break; + } + } + } + } + } + for (File file : path.listFiles()) { + if (file.isDirectory()) { + // System.out.println("搜索目录:"+file.getAbsolutePath()); + init(file); + } + } + + } + + public static String mainPath = "Z:\\download\\anim\\"; + + public static void main(String[] args) { + File file = new File("Z:\\download\\anim\\"); + //new JellyfinAPIManager().search(file.getName(), file); + new JellyfinAPIManager().init(file); + } } diff --git a/src/main/java/com/yutou/nas/utils/QQBotManager.java b/src/main/java/com/yutou/nas/utils/QQBotManager.java index a1256ef..dab9fc8 100644 --- a/src/main/java/com/yutou/nas/utils/QQBotManager.java +++ b/src/main/java/com/yutou/nas/utils/QQBotManager.java @@ -73,7 +73,7 @@ public class QQBotManager { public void run() { long qq = 2476945931L; String password = "zhang34864394"; - if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) { + if ("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) { qq = 3620756944L; password = "UAs6YBYMyxJU"; } @@ -82,7 +82,7 @@ public class QQBotManager { { setProtocol(MiraiProtocol.ANDROID_PAD); fileBasedDeviceInfo("qq_bot_devices_info.json"); - if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) { + if ("nas".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) { noBotLog(); noNetworkLog(); } @@ -99,7 +99,7 @@ public class QQBotManager { } catch (InterruptedException e) { e.printStackTrace(); } - String str = sendMessage("姬妻酱上线拉~☆Daze~"); + String str = sendMessage("姬妻酱上线拉~☆Daze~ 当前版本:"+NasApplication.version); com.yutou.nas.utils.Log.i(str); } diff --git a/src/main/java/com/yutou/nas/utils/Tools.java b/src/main/java/com/yutou/nas/utils/Tools.java index 81e4fff..0236efb 100644 --- a/src/main/java/com/yutou/nas/utils/Tools.java +++ b/src/main/java/com/yutou/nas/utils/Tools.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.yutou.nas.Controllers.UpdateIp; import com.yutou.nas.interfaces.DownloadInterface; import com.yutou.nas.interfaces.ObjectInterface; +import org.apache.commons.codec.digest.DigestUtils; import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -338,6 +339,10 @@ public class Tools { return digest.digest(); } + public static String getMD5(String str){ + return DigestUtils.md5Hex(str); + } + private static String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder(""); if (src == null || src.length <= 0) {