add:新增临时rss下载功能

This commit is contained in:
Yutousama 2022-07-16 18:50:36 +08:00
parent e8fe762c53
commit 238efb7a40
7 changed files with 179 additions and 120 deletions

View File

@ -1,6 +1,7 @@
package com.yutou.nas.Controllers;
import com.yutou.nas.utils.BTDownloadManager;
import com.yutou.nas.utils.AnimRssManager;
import com.yutou.nas.utils.DmhyRssDownloadManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -11,7 +12,8 @@ public class BTDownloadController {
@ResponseBody
@RequestMapping("/bt/down.do")
public String bt(){
BTDownloadManager.getInstance().start();
DmhyRssDownloadManager.getInstance().start();
AnimRssManager.scan();
return "ok";
}
}

View File

@ -1,7 +1,7 @@
package com.yutou.nas;
import com.yutou.nas.Datas.AppData;
import com.yutou.nas.utils.BTDownloadManager;
import com.yutou.nas.utils.DmhyRssDownloadManager;
import com.yutou.nas.utils.ConfigTools;
import com.yutou.nas.utils.QQBotManager;
import com.yutou.nas.utils.RedisTools;
@ -9,7 +9,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class)
@Import(DmhyRssDownloadManager.class)
@SpringBootApplication
public class NasApplication {
public static final String version = "1.2.16";

View File

@ -0,0 +1,35 @@
package com.yutou.nas.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Controllers.UpdateIp;
public class AnimRssManager {
public static void scan() {
String tmp=HttpTools.https_get("https://tools.yutou233.cn/anim/rss/list.do?type=-1&token=zIrsh9TUZP2lfRW753PannG49E7VJvor",null);
System.out.println("tmp = " + tmp);
if(tmp==null){
return;
}
JSONObject json= JSON.parseObject(tmp);
if(json.getInteger("code")==0){
JSONArray data=json.getJSONArray("data");
for (Object datum : data) {
String url= ((JSONObject) datum).getString("title");
download(url);
}
}
}
private static void download(String url) {
JSONObject rss=RssXMLtoJson.toJSON(url);
if (rss != null && "ok".equals(rss.getString("status"))) {
BTDownloadManager.download(rss.getJSONObject("feed").getString("title"), rss);
}
}
public static void main(String[] args) {
scan();
}
}

View File

@ -89,7 +89,8 @@ public class ApplicationInit implements ApplicationRunner {
case "21:00":
case "22:00":
case "23:00":
BTDownloadManager.getInstance().start();
DmhyRssDownloadManager.getInstance().start();
AnimRssManager.scan();
}
} catch (Exception e) {
Log.e("AppTimer", e);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
package com.yutou.nas.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class RssXMLtoJson {
public static JSONObject toJSON(String xmlUrl){
String url = "https://api.rss2json.com/v1/api.json?rss_url=%s&api_key=wtfm5pebya13pnl8rtu51wfgfpte0mb9sap1foll&count=500";
try {
String ret = HttpTools.get(String.format(url, URLEncoder.encode(xmlUrl, "UTF-8")));
if(ret!=null){
return JSON.parseObject(ret, JSONObject.class);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
return null;
}
}