fix:修复动漫花园订阅地址非https的问题

update:手动rss下载,同时跳过下一次自动订阅下载
This commit is contained in:
Yutousama 2022-07-18 12:48:29 +08:00
parent 15e32c9b00
commit 584779cc13
5 changed files with 58 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package com.yutou.nas.Controllers;
import com.yutou.nas.Services.IBangumiService;
import com.yutou.nas.utils.AnimRssManager;
import com.yutou.nas.utils.BTDownloadManager;
import com.yutou.nas.utils.DmhyRssDownloadManager;
@ -8,8 +9,12 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
public class BTDownloadController {
@Resource
IBangumiService bangumiService;
@ResponseBody
@RequestMapping("/bt/down.do")
@ -25,4 +30,11 @@ public class BTDownloadController {
BTDownloadManager.done(id,name);
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);
return "1";
}
}

View File

@ -6,4 +6,6 @@ import java.util.List;
public interface IBangumiService {
List<BangumiItem> getAllBangumi();
void download(int id,boolean isDownloadNext, String url);
}

View File

@ -4,6 +4,9 @@ import com.yutou.nas.Services.IBangumiService;
import com.yutou.nas.mybatis.dao.BangumiItemDao;
import com.yutou.nas.mybatis.model.BangumiItem;
import com.yutou.nas.mybatis.model.BangumiItemExample;
import com.yutou.nas.utils.BTDownloadManager;
import com.yutou.nas.utils.Log;
import com.yutou.nas.utils.RedisTools;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -19,4 +22,16 @@ public class BangumiServiceImpl implements IBangumiService {
example.createCriteria().andEnableEqualTo(1);
return itemDao.selectByExample(example);
}
@Override
public void download(int id,boolean isDownloadNext, String url) {
BangumiItem item = itemDao.selectByPrimaryKey(id);
if(item!=null){
BTDownloadManager.download(item.getTitle(),url);
if(!isDownloadNext){
Log.i("跳过下载","确定跳过:"+item.getTitle()+"的下载id = "+item.getId());
RedisTools.set(item.getId()+"","next");
}
}
}
}

View File

@ -11,6 +11,22 @@ import java.util.concurrent.TimeUnit;
public class BTDownloadManager {
protected static final String DownloadHomePath = "/media/yutou/disk_lvm/public/download/";
public synchronized static boolean skipDownload(String title, JSONObject json){
if ("ok".equals(json.getString("status"))) {
JSONArray items = json.getJSONArray("items");
for (Object _item : items) {
JSONObject item = (JSONObject) _item;
if (!isDownload(title, item.getString("title"))) {
JSONArray array = getDownload(title);
array.add(item.getString("title"));
RedisTools.set(title, array.toJSONString());
Log.i("跳过下载",title);
return true;
}
}
}
return false;
}
public synchronized static void download(String title, JSONObject json) {
if ("ok".equals(json.getString("status"))) {
JSONArray items = json.getJSONArray("items");
@ -52,7 +68,7 @@ public class BTDownloadManager {
//RedisTools.set(item.getString("title"),url);
}
private static boolean download(String title, String url) {
public static boolean download(String title, String url) {
try {
String exec = String.format("transmission-remote -n yutou:34864394 -w \"%sanim/%s\" -a \"%s\" --torrent-done-script \"/home/yutou/public/servier/btDone.sh\""
, DownloadHomePath
@ -71,7 +87,7 @@ public class BTDownloadManager {
return false;
}
private static JSONArray getDownload(String title) {
private static JSONArray getDownload(String title) {
String _title = RedisTools.get(title);
if (StringUtils.isEmpty(_title)) {
return new JSONArray();
@ -114,7 +130,6 @@ public class BTDownloadManager {
}
private static void grep(String remoteLocation, String remoteName) {
System.out.println("remoteName = " + remoteName.contains("265"));
if(remoteName.contains("265")){
String newName=remoteName.replace("265","贰陸伍");
String exec="mv \"" + remoteLocation + File.separator + remoteName + "\" \"" + remoteLocation + File.separator + newName+"\"";

File diff suppressed because one or more lines are too long