Skip to content

Commit

Permalink
1.1.158
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuo894 committed Oct 26, 2024
1 parent f17270f commit 042b672
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 11 deletions.
6 changes: 5 additions & 1 deletion UPDATE.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
优化通知集数
修复通知进度不正确

修改默认的Tracker更新地址

增加延迟下载配置
2 changes: 1 addition & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ qbittorrent:
季: ${season}
集: ${episode}
进度: ${currentEpisodeNumber}/${totalEpisodeNumber}
日期: ${year}年${month}月${date}日
首播: ${year}年${month}月${date}日
事件: ${text}

webhook
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ani.rss</groupId>
<artifactId>ani-rss</artifactId>
<version>1.1.157</version>
<version>1.1.158</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/ani/rss/entity/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class Config implements Serializable {
*/
private Boolean watchErrorTorrent;

/**
* 延迟下载
*/
private Integer delayedDownload;

/**
* 显示评分
*/
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/ani/rss/entity/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* 下载项
Expand Down Expand Up @@ -55,4 +56,9 @@ public class Item implements Serializable {
* 字幕组
*/
private String subgroup;

/**
* 发布时间
*/
private LocalDateTime pubDate;
}
3 changes: 2 additions & 1 deletion src/main/java/ani/rss/util/ConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ConfigUtil {
.setRenameMinSize(100)
.setRss(true)
.setWatchErrorTorrent(true)
.setDelayedDownload(0)
.setFileExist(false)
.setAwaitStalledUP(true)
.setDelete(false)
Expand Down Expand Up @@ -120,7 +121,7 @@ public class ConfigUtil {
.setServerChan3ApiUrl("")
.setSystemMsg(false)
.setAutoTrackersUpdate(false)
.setTrackersUpdateUrls("https://cf.trackerslist.com/all.txt\nhttps://cdn.jsdelivr.net/gh/DeSireFire/animeTrackerList/AT_all.txt")
.setTrackersUpdateUrls("https://cf.trackerslist.com/best.txt\nhttps://cdn.jsdelivr.net/gh/ngosang/trackerslist@master/trackers_all.txt")
.setMessageTemplate("${text}");
}

Expand Down
30 changes: 25 additions & 5 deletions src/main/java/ani/rss/util/ItemsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.*;
import cn.hutool.http.HttpResponse;
import lombok.extern.slf4j.Slf4j;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -105,6 +106,8 @@ public static List<Item> getItems(Ani ani, String xml, Item newItem) {

String size = "0MB";

LocalDateTime pubDate = null;

NodeList itemChildNodes = item.getChildNodes();
for (int j = 0; j < itemChildNodes.getLength(); j++) {
Node itemChild = itemChildNodes.item(j);
Expand Down Expand Up @@ -134,13 +137,29 @@ public static List<Item> getItems(Ani ani, String xml, Item newItem) {
size = itemChild.getTextContent();
}

if (itemChildNodeName.equals("pubDate")) {
try {
DateTime parse = DateUtil.parse(itemChild.getTextContent());
pubDate = parse.toLocalDateTime();
} catch (Exception ignored) {
}
}

if (itemChildNodeName.equals("torrent")) {
try {
pubDate = LocalDateTimeUtil.parse(XmlUtil.getElement((Element) itemChild, "pubDate").getTextContent());
} catch (Exception ignored) {
}
}

if (itemChildNodeName.equals("link")) {
String link = itemChild.getTextContent();
if (!link.endsWith(".torrent")) {
continue;
}
torrent = link;
}

}

if (StrUtil.isBlank(torrent)) {
Expand Down Expand Up @@ -168,7 +187,8 @@ public static List<Item> getItems(Ani ani, String xml, Item newItem) {
.setReName(itemTitle)
.setTorrent(torrent)
.setInfoHash(infoHash)
.setSize(size);
.setSize(size)
.setPubDate(pubDate);

// 进行过滤
if (exclude.stream().anyMatch(s -> ReUtil.contains(s, addNewItem.getTitle()))) {
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/ani/rss/util/TorrentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ani.rss.entity.TorrentsInfo;
import ani.rss.enums.MessageEnum;
import ani.rss.enums.StringEnum;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.thread.ThreadUtil;
Expand All @@ -19,6 +20,8 @@
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -44,6 +47,7 @@ public static synchronized void downloadAni(Ani ani) {
Config config = ConfigUtil.CONFIG;
Boolean autoDisabled = config.getAutoDisabled();
Integer downloadCount = config.getDownloadCount();
Integer delayedDownload = config.getDelayedDownload();

String title = ani.getTitle();
Integer season = ani.getSeason();
Expand Down Expand Up @@ -99,6 +103,16 @@ public static synchronized void downloadAni(Ani ani) {
String hash = FileUtil.mainName(torrent)
.trim().toLowerCase();

LocalDateTime pubDate = item.getPubDate();
if (Objects.nonNull(pubDate) && delayedDownload > 0) {
LocalDateTime now = LocalDateTime.now();
now = LocalDateTimeUtil.offset(now, -delayedDownload, ChronoUnit.MINUTES);
if (LocalDateTimeUtil.toEpochMilli(now) > LocalDateTimeUtil.toEpochMilli(pubDate)) {
log.info("延迟下载 {}", reName);
continue;
}
}

// 已经下载过
if (hashList.contains(hash) || downloadNameList.contains(reName)) {
log.debug("已有下载任务 {}", reName);
Expand Down Expand Up @@ -143,6 +157,13 @@ public static synchronized void downloadAni(Ani ani) {
String savePath = downloadPathList
.get(0)
.toString();

int size = ItemsUtil.currentEpisodeNumber(ani, items);
if (size > 0 && ani.getCurrentEpisodeNumber() < size) {
ani.setCurrentEpisodeNumber(size);
AniUtil.sync();
}

download(ani, item, savePath, saveTorrent);
if (master && !reName.endsWith(".5")) {
currentDownloadCount++;
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/Test7.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import java.util.concurrent.TimeUnit;
import ani.rss.entity.Ani;
import ani.rss.entity.Item;
import ani.rss.util.AniUtil;
import ani.rss.util.ItemsUtil;

public class Test7 {
public static void main(String[] args) {
System.out.println(TimeUnit.HOURS.toMillis(1));
Ani ani = AniUtil.getAni("https://mikan.wushuo.top/RSS/Bangumi?bangumiId=3436&subgroupid=583");
ani.setUrl("https://nyaa.si/?page=rss&q=[GM-Team][国漫][剑来]&c=0_0&f=0");
for (Item item : ItemsUtil.getItems(ani)) {
System.out.println(item.getPubDate());
}
}
}
3 changes: 3 additions & 0 deletions ui/src/config/Download.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
</div>
</div>
</el-form-item>
<el-form-item label="延迟下载(分钟)">
<el-input-number v-model:model-value="props.config.delayedDownload" min="0"/>
</el-form-item>
<el-form-item label="检测是否死种">
<el-switch v-model:model-value="props.config.watchErrorTorrent"/>
</el-form-item>
Expand Down
1 change: 1 addition & 0 deletions ui/src/home/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const config = ref({
'password': '',
'sleep': 5,
'watchErrorTorrent': true,
'delayedDownload': 0,
'downloadPath': '',
'ovaDownloadPath': '',
'fileExist': true,
Expand Down

0 comments on commit 042b672

Please sign in to comment.