mirror of
https://github.com/wushuo894/ani-rss.git
synced 2026-03-13 09:20:23 +00:00
refactor: 拆分模块
This commit is contained in:
2
.github/workflows/maven-test.yml
vendored
2
.github/workflows/maven-test.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: ./target/ani-rss-jar-with-dependencies.jar
|
||||
path: ./ani-rss-application/target/ani-rss-jar-with-dependencies.jar
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
||||
12
.github/workflows/maven.yml
vendored
12
.github/workflows/maven.yml
vendored
@@ -35,12 +35,12 @@ jobs:
|
||||
append_body: false
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: |
|
||||
./target/ani-rss-jar-with-dependencies.jar
|
||||
./target/ani-rss-jar-with-dependencies.jar.md5
|
||||
./target/ani-rss-launcher.exe
|
||||
./target/ani-rss-launcher.exe.md5
|
||||
./target/ani-rss.win.x86_64.zip
|
||||
./target/ani-rss.win.x86_64.zip.md5
|
||||
./ani-rss-application/target/ani-rss-jar-with-dependencies.jar
|
||||
./ani-rss-application/target/ani-rss-jar-with-dependencies.jar.md5
|
||||
./ani-rss-application/target/ani-rss-launcher.exe
|
||||
./ani-rss-application/target/ani-rss-launcher.exe.md5
|
||||
./ani-rss-application/target/ani-rss.win.x86_64.zip
|
||||
./ani-rss-application/target/ani-rss.win.x86_64.zip.md5
|
||||
./info.json
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
27
ani-rss-api/pom.xml
Normal file
27
ani-rss-api/pom.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss</artifactId>
|
||||
<version>2.4.8</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ani-rss-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss-commons</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
19
ani-rss-api/src/main/java/ani/rss/ApiMain.java
Normal file
19
ani-rss-api/src/main/java/ani/rss/ApiMain.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package ani.rss;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
public class ApiMain {
|
||||
public static void main(String[] args) {
|
||||
Set<Class<?>> classSet = ClassUtil.scanPackage("ani.rss");
|
||||
for (Class<?> clazz : classSet) {
|
||||
if (clazz.isMemberClass()) {
|
||||
continue;
|
||||
}
|
||||
log.info(clazz.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
package ani.rss.entity;
|
||||
|
||||
import ani.rss.entity.tmdb.Tmdb;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -270,58 +266,5 @@ public class Ani implements Serializable {
|
||||
*/
|
||||
private List<String> customTags;
|
||||
|
||||
public static Ani createAni() {
|
||||
Ani newAni = new Ani();
|
||||
Config config = ConfigUtil.CONFIG;
|
||||
return newAni
|
||||
.setId(UUID.fastUUID().toString())
|
||||
.setMikanTitle("")
|
||||
.setStandbyRssList(new ArrayList<>())
|
||||
.setOffset(0)
|
||||
.setYear(1970)
|
||||
.setMonth(1)
|
||||
.setDate(1)
|
||||
.setEnable(true)
|
||||
.setOva(false)
|
||||
.setScore(0.0)
|
||||
.setLastDownloadTime(0L)
|
||||
.setImage("")
|
||||
.setThemoviedbName("")
|
||||
.setCustomDownloadPath(false)
|
||||
.setDownloadPath("")
|
||||
.setGlobalExclude(false)
|
||||
.setCurrentEpisodeNumber(0)
|
||||
.setTotalEpisodeNumber(0)
|
||||
.setMatch(List.of())
|
||||
.setExclude(List.of("720[Pp]", "\\d-\\d", "合集", "特别篇"))
|
||||
.setBgmUrl("")
|
||||
.setSubgroup("")
|
||||
.setCustomEpisode(config.getCustomEpisode())
|
||||
.setCustomEpisodeStr(config.getCustomEpisodeStr())
|
||||
.setCustomEpisodeGroupIndex(config.getCustomEpisodeGroupIndex())
|
||||
.setOmit(true)
|
||||
.setDownloadNew(false)
|
||||
.setNotDownload(new ArrayList<>())
|
||||
.setTmdb(
|
||||
new Tmdb()
|
||||
.setId("")
|
||||
.setName("")
|
||||
.setDate(new Date())
|
||||
)
|
||||
.setUpload(config.getUpload())
|
||||
.setProcrastinating(true)
|
||||
.setCustomRenameTemplate(config.getRenameTemplate())
|
||||
.setCustomRenameTemplateEnable(false)
|
||||
.setCustomPriorityKeywordsEnable(false)
|
||||
.setCustomPriorityKeywords(new ArrayList<>())
|
||||
.setMessage(true)
|
||||
.setAlistPath("")
|
||||
.setCustomAlistPath(false)
|
||||
.setCompleted(true)
|
||||
.setCustomCompleted(false)
|
||||
.setCustomCompletedPathTemplate("")
|
||||
.setCustomTags(new ArrayList<>())
|
||||
.setCustomTagsEnable(false);
|
||||
}
|
||||
|
||||
}
|
||||
46
ani-rss-api/src/main/java/ani/rss/entity/EmbyWebHook.java
Normal file
46
ani-rss-api/src/main/java/ani/rss/entity/EmbyWebHook.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package ani.rss.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* EmbyWebHook
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class EmbyWebHook implements Serializable {
|
||||
|
||||
@SerializedName(value = "item", alternate = "Item")
|
||||
private Item item;
|
||||
|
||||
@SerializedName(value = "event", alternate = "Event")
|
||||
private String event;
|
||||
|
||||
@SerializedName(value = "playbackInfo", alternate = "PlaybackInfo")
|
||||
private PlaybackInfo playbackInfo;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Item implements Serializable {
|
||||
@SerializedName(value = "path", alternate = "Path")
|
||||
private String path;
|
||||
@SerializedName(value = "seriesName", alternate = "SeriesName")
|
||||
private String seriesName;
|
||||
@SerializedName(value = "fileName", alternate = "FileName")
|
||||
private String fileName;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class PlaybackInfo implements Serializable {
|
||||
/**
|
||||
* 是否播放完成
|
||||
*/
|
||||
@SerializedName(value = "playedToCompletion", alternate = "PlayedToCompletion")
|
||||
private Boolean playedToCompletion;
|
||||
}
|
||||
|
||||
}
|
||||
17
ani-rss-api/src/main/java/ani/rss/entity/Global.java
Normal file
17
ani-rss-api/src/main/java/ani/rss/entity/Global.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package ani.rss.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class Global implements Serializable {
|
||||
public static List<String> ARGS = new ArrayList<>();
|
||||
|
||||
public static String HOST = "";
|
||||
public static String HTTP_PORT = "7789";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package ani.rss.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum NotificationTypeEnum {
|
||||
EMBY_REFRESH,
|
||||
MAIL,
|
||||
SERVER_CHAN,
|
||||
SYSTEM,
|
||||
TELEGRAM,
|
||||
WEB_HOOK,
|
||||
SHELL
|
||||
}
|
||||
116
ani-rss-application/pom.xml
Normal file
116
ani-rss-application/pom.xml
Normal file
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss</artifactId>
|
||||
<version>2.4.8</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ani-rss-application</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>ani-rss</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>ani.rss.ApplicationMain</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||
<artifactId>launch4j-maven-plugin</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>l4j</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>launch4j</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>target/ani-rss-launcher.exe</outfile>
|
||||
<jar>target/ani-rss-jar-with-dependencies.jar</jar>
|
||||
<errTitle>Java environment is required!</errTitle>
|
||||
<cmdLine>--gui</cmdLine>
|
||||
<chdir>.</chdir>
|
||||
<priority>normal</priority>
|
||||
<downloadUrl>https://adoptium.net/zh-CN/</downloadUrl>
|
||||
<supportUrl>https://whichjdk.com/</supportUrl>
|
||||
<stayAlive>false</stayAlive>
|
||||
<restartOnCrash>false</restartOnCrash>
|
||||
<icon>${project.parent.basedir}/ui/public/favicon.ico</icon>
|
||||
<jre>
|
||||
<path>jre/bin;%JAVA_HOME%/bin;%PATH%</path>
|
||||
<minVersion>17</minVersion>
|
||||
<opts>
|
||||
<opt>-Xms60m -Xmx1g -Xss256k</opt>
|
||||
<opt>--enable-native-access=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens=java.base/java.net=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED</opt>
|
||||
</opts>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileDescription>https://docs.wushuo.top/</fileDescription>
|
||||
<copyright>Copyright (C) 2024-2025</copyright>
|
||||
<productName>${project.artifactId}</productName>
|
||||
<internalName>${project.artifactId}</internalName>
|
||||
<originalFilename>ani-rss-launcher.exe</originalFilename>
|
||||
<language>SIMPLIFIED_CHINESE</language>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,9 +1,13 @@
|
||||
package ani.rss;
|
||||
|
||||
import ani.rss.commons.ExceptionUtil;
|
||||
import ani.rss.commons.MavenUtil;
|
||||
import ani.rss.other.Cron;
|
||||
import ani.rss.service.TaskService;
|
||||
import ani.rss.util.basic.ExceptionUtil;
|
||||
import ani.rss.util.other.*;
|
||||
import ani.rss.util.ServerUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import ani.rss.util.other.MenuUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -11,13 +15,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class Main {
|
||||
public class ApplicationMain {
|
||||
|
||||
public static List<String> ARGS = new ArrayList<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
|
||||
Main.ARGS = List.of(ObjectUtil.defaultIfNull(args, new String[]{}));
|
||||
ApplicationMain.ARGS = List.of(ObjectUtil.defaultIfNull(args, new String[]{}));
|
||||
try {
|
||||
ConfigUtil.load();
|
||||
ConfigUtil.backup();
|
||||
@@ -3,6 +3,8 @@ package ani.rss.action;
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.auth.enums.AuthType;
|
||||
import ani.rss.commons.ExceptionUtil;
|
||||
import ani.rss.commons.FileUtil;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.entity.Item;
|
||||
@@ -11,16 +13,17 @@ import ani.rss.enums.SortTypeEnum;
|
||||
import ani.rss.service.ClearService;
|
||||
import ani.rss.service.DownloadService;
|
||||
import ani.rss.task.RssTask;
|
||||
import ani.rss.util.basic.ExceptionUtil;
|
||||
import ani.rss.util.basic.MyFileUtil;
|
||||
import ani.rss.util.other.*;
|
||||
import ani.rss.util.ServerUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import ani.rss.util.other.ItemsUtil;
|
||||
import ani.rss.util.other.TorrentUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.comparator.PinyinComparator;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -219,7 +222,7 @@ public class AniAction implements BaseAction {
|
||||
}
|
||||
try {
|
||||
FileUtil.mkdir(newDownloadPath);
|
||||
File[] files = MyFileUtil.listFiles(downloadPath);
|
||||
File[] files = FileUtil.listFiles(downloadPath);
|
||||
for (File oldFile : files) {
|
||||
log.info("移动文件 {} ==> {}", oldFile, newDownloadPath);
|
||||
FileUtil.move(oldFile, new File(newDownloadPath), true);
|
||||
@@ -5,6 +5,7 @@ import ani.rss.annotation.Path;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.entity.BgmInfo;
|
||||
import ani.rss.entity.tmdb.Tmdb;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.BgmUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
@@ -33,7 +34,7 @@ public class BgmAction implements BaseAction {
|
||||
case "getAniBySubjectId" -> {
|
||||
String id = request.getParam("id");
|
||||
BgmInfo bgmInfo = BgmUtil.getBgmInfo(id, true);
|
||||
Ani ani = BgmUtil.toAni(bgmInfo, Ani.createAni());
|
||||
Ani ani = BgmUtil.toAni(bgmInfo, AniUtil.createAni());
|
||||
ani
|
||||
.setCustomDownloadPath(true);
|
||||
resultSuccess(ani);
|
||||
@@ -2,8 +2,8 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.GsonStatic;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.util.basic.GsonStatic;
|
||||
import ani.rss.util.basic.HttpReq;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
@@ -2,12 +2,11 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.FileUtil;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.service.ClearService;
|
||||
import ani.rss.util.basic.MyFileUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
import cn.hutool.http.server.HttpServerResponse;
|
||||
@@ -29,12 +28,12 @@ public class ClearCacheAction implements BaseAction {
|
||||
@Override
|
||||
public synchronized void doAction(HttpServerRequest request, HttpServerResponse response) throws IOException {
|
||||
File configDir = ConfigUtil.getConfigDir();
|
||||
String configDirStr = MyFileUtil.getAbsolutePath(configDir);
|
||||
String configDirStr = FileUtil.getAbsolutePath(configDir);
|
||||
|
||||
Set<String> covers = AniUtil.ANI_LIST
|
||||
.stream()
|
||||
.map(Ani::getCover)
|
||||
.map(s -> MyFileUtil.getAbsolutePath(new File(configDirStr + "/files/" + s)))
|
||||
.map(s -> FileUtil.getAbsolutePath(new File(configDirStr + "/files/" + s)))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
FileUtil.mkdir(configDirStr + "/files");
|
||||
@@ -43,7 +42,7 @@ public class ClearCacheAction implements BaseAction {
|
||||
Set<File> files = FileUtil.loopFiles(configDirStr + "/files")
|
||||
.stream()
|
||||
.filter(file -> {
|
||||
String fileName = MyFileUtil.getAbsolutePath(file);
|
||||
String fileName = FileUtil.getAbsolutePath(file);
|
||||
return !covers.contains(fileName);
|
||||
}).collect(Collectors.toSet());
|
||||
long filesSize = files.stream()
|
||||
@@ -2,12 +2,12 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.MavenUtil;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.entity.Login;
|
||||
import ani.rss.service.TaskService;
|
||||
import ani.rss.util.other.AfdianUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import ani.rss.util.other.MavenUtil;
|
||||
import ani.rss.util.other.TorrentUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
@@ -3,10 +3,10 @@ package ani.rss.action;
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.auth.enums.AuthType;
|
||||
import ani.rss.util.basic.ExceptionUtil;
|
||||
import ani.rss.commons.ExceptionUtil;
|
||||
import ani.rss.util.ServerUtil;
|
||||
import ani.rss.util.basic.HttpReq;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import ani.rss.util.other.ServerUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
@@ -2,15 +2,12 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.auth.util.AuthUtil;
|
||||
import ani.rss.commons.CacheUtil;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.entity.Login;
|
||||
import ani.rss.entity.Result;
|
||||
import ani.rss.exception.ResultException;
|
||||
import ani.rss.util.basic.MyCacheUtil;
|
||||
import ani.rss.util.AuthUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
@@ -18,8 +15,8 @@ import cn.hutool.http.server.HttpServerResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static ani.rss.util.AuthUtil.limitLoginAttempts;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
@@ -74,51 +71,10 @@ public class LoginAction implements BaseAction {
|
||||
public static void clearLimitLoginAttempts() {
|
||||
String ip = AuthUtil.getIp();
|
||||
String key = "LimitLoginAttempts#" + ip;
|
||||
if (MyCacheUtil.containsKey(key)) {
|
||||
MyCacheUtil.remove(key);
|
||||
if (CacheUtil.containsKey(key)) {
|
||||
CacheUtil.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 限制尝试次数
|
||||
*
|
||||
* @param isAdd 累加计数
|
||||
*/
|
||||
public static void limitLoginAttempts(Boolean isAdd) {
|
||||
Config config = ConfigUtil.CONFIG;
|
||||
boolean limitLoginAttempts = config.getLimitLoginAttempts();
|
||||
if (!limitLoginAttempts) {
|
||||
return;
|
||||
}
|
||||
String ip = AuthUtil.getIp();
|
||||
String key = "LimitLoginAttempts#" + ip;
|
||||
|
||||
// 1 天内将不再允许尝试
|
||||
long timeout = TimeUnit.DAYS.toMillis(1);
|
||||
|
||||
if (!MyCacheUtil.containsKey(key)) {
|
||||
if (isAdd) {
|
||||
MyCacheUtil.put(key, new AtomicInteger(1), timeout);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AtomicInteger countAtomicInteger = MyCacheUtil.get(key);
|
||||
int count = countAtomicInteger.getAndAdd(isAdd ? 1 : 0);
|
||||
|
||||
// 失败时 时间将重新计时
|
||||
MyCacheUtil.put(key, countAtomicInteger, timeout);
|
||||
|
||||
// 失败 10 次
|
||||
if (count < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("失败次数过多, 已限制登录 {}", ip);
|
||||
Result<Void> result = new Result<Void>()
|
||||
.setMessage(StrFormatter.format("失败次数过多, 已限制登录 {}", ip))
|
||||
.setCode(300);
|
||||
throw new ResultException(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.GsonStatic;
|
||||
import ani.rss.entity.Mikan;
|
||||
import ani.rss.entity.TorrentsInfo;
|
||||
import ani.rss.util.basic.GsonStatic;
|
||||
import ani.rss.util.other.MikanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
@@ -11,6 +11,7 @@ import ani.rss.enums.NotificationTypeEnum;
|
||||
import ani.rss.notification.BaseNotification;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.BgmUtil;
|
||||
import ani.rss.util.other.NotificationUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
import cn.hutool.http.server.HttpServerResponse;
|
||||
@@ -46,8 +47,9 @@ public class NotificationAction implements BaseAction {
|
||||
private void test() {
|
||||
NotificationConfig notificationConfig = getBody(NotificationConfig.class);
|
||||
NotificationTypeEnum notificationType = notificationConfig.getNotificationType();
|
||||
BaseNotification baseNotification = ReflectUtil.newInstance(notificationType.getAClass());
|
||||
Ani ani = Ani.createAni();
|
||||
Class<? extends BaseNotification> aClass = NotificationUtil.NOTIFICATION_MAP.get(notificationType);
|
||||
BaseNotification baseNotification = ReflectUtil.newInstance(aClass);
|
||||
Ani ani = AniUtil.createAni();
|
||||
ani.setBgmUrl("https://bgm.tv/subject/424883");
|
||||
BgmInfo bgmInfo = BgmUtil.getBgmInfo(ani);
|
||||
String image = bgmInfo.getImage();
|
||||
@@ -3,16 +3,15 @@ package ani.rss.action;
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.auth.enums.AuthType;
|
||||
import ani.rss.commons.FileUtil;
|
||||
import ani.rss.download.BaseDownload;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.entity.PlayItem;
|
||||
import ani.rss.enums.StringEnum;
|
||||
import ani.rss.service.DownloadService;
|
||||
import ani.rss.util.basic.MyFileUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -60,7 +59,7 @@ public class PlaylistAction implements BaseAction {
|
||||
public List<PlayItem> getPlayItem(File file) {
|
||||
List<PlayItem> playItems = new ArrayList<>();
|
||||
if (file.isDirectory()) {
|
||||
File[] files = MyFileUtil.listFiles(file);
|
||||
File[] files = FileUtil.listFiles(file);
|
||||
for (File itFile : files) {
|
||||
playItems.addAll(getPlayItem(itFile));
|
||||
}
|
||||
@@ -76,7 +75,7 @@ public class PlaylistAction implements BaseAction {
|
||||
if (!ReUtil.contains(StringEnum.SEASON_REG, file.getName())) {
|
||||
return playItems;
|
||||
}
|
||||
File[] files = MyFileUtil.listFiles(file.getParentFile());
|
||||
File[] files = FileUtil.listFiles(file.getParentFile());
|
||||
List<PlayItem.Subtitles> subtitles = Arrays.stream(files)
|
||||
.filter(f -> List.of("ass", "srt").contains(ObjectUtil.defaultIfNull(FileUtil.extName(f), "")))
|
||||
.filter(f -> f.getName().startsWith(FileUtil.mainName(file.getName())))
|
||||
@@ -85,13 +84,13 @@ public class PlaylistAction implements BaseAction {
|
||||
return new PlayItem.Subtitles()
|
||||
.setName(name)
|
||||
.setHtml(name.toUpperCase())
|
||||
.setUrl(Base64.encode(MyFileUtil.getAbsolutePath(f)))
|
||||
.setUrl(Base64.encode(FileUtil.getAbsolutePath(f)))
|
||||
.setType(FileUtil.extName(f));
|
||||
}).toList();
|
||||
subtitles = CollUtil.distinct(subtitles, PlayItem.Subtitles::getName, true);
|
||||
PlayItem playItem = new PlayItem();
|
||||
playItem.setSubtitles(subtitles);
|
||||
playItem.setFilename(Base64.encode(MyFileUtil.getAbsolutePath(file)))
|
||||
playItem.setFilename(Base64.encode(FileUtil.getAbsolutePath(file)))
|
||||
.setName(file.getName())
|
||||
.setLastModify(file.lastModified())
|
||||
.setTitle(ReUtil.get(StringEnum.SEASON_REG, file.getName(), 0));
|
||||
@@ -2,8 +2,8 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.ExceptionUtil;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.util.basic.ExceptionUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
@@ -2,8 +2,8 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.util.other.ServerUtil;
|
||||
import ani.rss.util.other.UpdateUtil;
|
||||
import ani.rss.commons.MavenUtil;
|
||||
import ani.rss.util.ServerUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
@@ -32,7 +32,7 @@ public class StopAction implements BaseAction {
|
||||
resultSuccessMsg("正在{}", s);
|
||||
ThreadUtil.execute(() -> {
|
||||
ThreadUtil.sleep(3000);
|
||||
File jar = UpdateUtil.getJar();
|
||||
File jar = MavenUtil.getJar();
|
||||
String extName = FileUtil.extName(jar);
|
||||
ServerUtil.stop();
|
||||
if ("exe".equals(extName) && status == 0) {
|
||||
@@ -2,12 +2,11 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.FileUtil;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.util.basic.MyFileUtil;
|
||||
import ani.rss.util.ServerUtil;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.ServerUtil;
|
||||
import ani.rss.util.other.TorrentUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.Method;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
@@ -53,7 +52,7 @@ public class TorrentAction implements BaseAction {
|
||||
|
||||
Ani ani = first.get();
|
||||
File torrentDir = TorrentUtil.getTorrentDir(ani);
|
||||
File[] files = MyFileUtil.listFiles(torrentDir);
|
||||
File[] files = FileUtil.listFiles(torrentDir);
|
||||
for (File file : files) {
|
||||
String s = FileUtil.mainName(file);
|
||||
if (infoHashList.contains(s)) {
|
||||
@@ -2,8 +2,8 @@ package ani.rss.action;
|
||||
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.commons.ExceptionUtil;
|
||||
import ani.rss.entity.About;
|
||||
import ani.rss.util.basic.ExceptionUtil;
|
||||
import ani.rss.util.other.UpdateUtil;
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
import cn.hutool.http.server.HttpServerResponse;
|
||||
@@ -3,15 +3,14 @@ package ani.rss.action;
|
||||
import ani.rss.annotation.Auth;
|
||||
import ani.rss.annotation.Path;
|
||||
import ani.rss.auth.enums.AuthType;
|
||||
import ani.rss.commons.GsonStatic;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.entity.EmbyWebHook;
|
||||
import ani.rss.entity.tmdb.Tmdb;
|
||||
import ani.rss.enums.StringEnum;
|
||||
import ani.rss.util.basic.GsonStatic;
|
||||
import ani.rss.util.other.AniUtil;
|
||||
import ani.rss.util.other.BgmUtil;
|
||||
import ani.rss.util.other.ConfigUtil;
|
||||
import ani.rss.util.other.ItemsUtil;
|
||||
import ani.rss.service.DownloadService;
|
||||
import ani.rss.util.other.*;
|
||||
import cn.hutool.core.thread.ExecutorBuilder;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -20,8 +19,10 @@ import cn.hutool.http.server.HttpServerResponse;
|
||||
import lombok.Synchronized;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@@ -94,7 +95,7 @@ public class WebHookAction implements BaseAction {
|
||||
|
||||
// 优先匹配路径相同的
|
||||
String subjectId = anis.stream()
|
||||
.filter(embyWebHook::equalsAni)
|
||||
.filter(ani -> embyEqualsAni(embyWebHook, ani))
|
||||
.map(BgmUtil::getSubjectId)
|
||||
.findFirst()
|
||||
.orElseGet(() -> BgmUtil.getSubjectId(seriesName, season));
|
||||
@@ -112,6 +113,69 @@ public class WebHookAction implements BaseAction {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否匹配到订阅
|
||||
*
|
||||
* @param ani
|
||||
* @return
|
||||
*/
|
||||
public Boolean embyEqualsAni(EmbyWebHook embyWebHook, Ani ani) {
|
||||
EmbyWebHook.Item item = embyWebHook.getItem();
|
||||
String fileName = item.getFileName();
|
||||
if (!ReUtil.contains(StringEnum.SEASON_REG, fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 季
|
||||
int season = Integer.parseInt(ReUtil.get(StringEnum.SEASON_REG, fileName, 1));
|
||||
|
||||
if (season != ani.getSeason()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String bgmUrl = ani.getBgmUrl();
|
||||
if (StrUtil.isBlank(bgmUrl)) {
|
||||
// bgmUrl为空
|
||||
return false;
|
||||
}
|
||||
|
||||
String path = item.getPath();
|
||||
String parent = new File(path).getParent();
|
||||
String downloadPath = DownloadService.getDownloadPath(ani);
|
||||
if (downloadPath.equals(parent)) {
|
||||
// 路径相同
|
||||
return true;
|
||||
}
|
||||
|
||||
String title = ani.getTitle();
|
||||
title = RenameUtil.renameDel(title, false);
|
||||
String seriesName = item.getSeriesName();
|
||||
if (title.equals(seriesName)) {
|
||||
// 名称与季相同
|
||||
return true;
|
||||
}
|
||||
|
||||
Tmdb tmdb = ani.getTmdb();
|
||||
if (Objects.isNull(tmdb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 对比tmdb名称
|
||||
String name = tmdb.getName();
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
if (name.equals(seriesName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 对比tmdb原名
|
||||
String originalName = tmdb.getOriginalName();
|
||||
if (StrUtil.isNotBlank(originalName)) {
|
||||
return originalName.equals(seriesName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取播放状态
|
||||
*
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
39
ani-rss-commons/pom.xml
Normal file
39
ani-rss-commons/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss</artifactId>
|
||||
<version>2.4.8</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ani-rss-commons</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
19
ani-rss-commons/src/main/java/ani/rss/CommonsMain.java
Normal file
19
ani-rss-commons/src/main/java/ani/rss/CommonsMain.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package ani.rss;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
public class CommonsMain {
|
||||
public static void main(String[] args) {
|
||||
Set<Class<?>> classSet = ClassUtil.scanPackage("ani.rss.commons");
|
||||
for (Class<?> clazz : classSet) {
|
||||
if (clazz.isMemberClass()) {
|
||||
continue;
|
||||
}
|
||||
log.info(clazz.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.cache.impl.FIFOCache;
|
||||
import lombok.Synchronized;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class MyCacheUtil {
|
||||
static final FIFOCache<Object, Object> CACHE = CacheUtil.newFIFOCache(1024 * 8);
|
||||
public class CacheUtil {
|
||||
static final FIFOCache<Object, Object> CACHE = cn.hutool.cache.CacheUtil.newFIFOCache(1024 * 8);
|
||||
|
||||
@Synchronized("CACHE")
|
||||
public static <V> V get(Object key) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MyFileUtil {
|
||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
|
||||
/**
|
||||
* 获取绝对路径 并把 windows 狗日的 \ 转换为 /
|
||||
@@ -55,7 +55,7 @@ public class MyFileUtil {
|
||||
|
||||
public static String normalize(String path) {
|
||||
path = path.trim();
|
||||
String s = FileUtil.normalize(path);
|
||||
String s = cn.hutool.core.io.FileUtil.normalize(path);
|
||||
while (s.endsWith("/")) {
|
||||
s = s.substring(0, s.length() - 1);
|
||||
}
|
||||
@@ -63,23 +63,14 @@ public class MyFileUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表 不会存在空指针问题
|
||||
* 获得文件的扩展名(后缀名),扩展名不带“.”
|
||||
*
|
||||
* @param path 文件夹位置
|
||||
* @return 文件列表
|
||||
* @param fileName 文件名
|
||||
* @return 扩展名
|
||||
* @see FileNameUtil#extName(String)
|
||||
*/
|
||||
public static List<File> listFileList(String path) {
|
||||
return List.of(listFiles(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表 不会存在空指针问题
|
||||
*
|
||||
* @param file 文件夹位置
|
||||
* @return 文件列表
|
||||
*/
|
||||
public static List<File> listFileList(File file) {
|
||||
return List.of(listFiles(file));
|
||||
public static String extName(String fileName) {
|
||||
return FileNameUtil.extName(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,4 +102,7 @@ public class MyFileUtil {
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
public static List<File> listFileList(String path) {
|
||||
return List.of(listFiles(path));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import ani.rss.other.TimeZoneSerializer;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -1,9 +1,11 @@
|
||||
package ani.rss.util.other;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.OsInfo;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import lombok.Cleanup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -21,7 +23,7 @@ public class MavenUtil {
|
||||
public static JarFile JAR_FILE = null;
|
||||
|
||||
static {
|
||||
File jar = UpdateUtil.getJar();
|
||||
File jar = getJar();
|
||||
try {
|
||||
if (isJar()) {
|
||||
JAR_FILE = new JarFile(jar);
|
||||
@@ -31,8 +33,16 @@ public class MavenUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static File getJar() {
|
||||
OsInfo osInfo = SystemUtil.getOsInfo();
|
||||
String splitStr = osInfo.isWindows() ? ";" : ":";
|
||||
String s = System.getProperty("java.class.path")
|
||||
.split(splitStr)[0];
|
||||
return new File(s);
|
||||
}
|
||||
|
||||
public static Boolean isJar() {
|
||||
File jar = UpdateUtil.getJar();
|
||||
File jar = getJar();
|
||||
|
||||
if (jar.isDirectory()) {
|
||||
return false;
|
||||
@@ -52,7 +62,8 @@ public class MavenUtil {
|
||||
}
|
||||
try {
|
||||
if (Objects.nonNull(JAR_FILE)) {
|
||||
JarEntry jarEntry = JAR_FILE.getJarEntry("META-INF/maven/ani.rss/ani-rss/pom.xml");
|
||||
String pomPath = "META-INF/maven/ani.rss/ani-rss-application/pom.xml";
|
||||
JarEntry jarEntry = JAR_FILE.getJarEntry(pomPath);
|
||||
@Cleanup
|
||||
InputStream inputStream = JAR_FILE.getInputStream(jarEntry);
|
||||
String s = IoUtil.readUtf8(inputStream);
|
||||
@@ -1,4 +1,4 @@
|
||||
package ani.rss.util.other;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ani.rss.other;
|
||||
package ani.rss.commons;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -15,4 +15,4 @@ public class TimeZoneSerializer implements JsonSerializer<TimeZone> {
|
||||
jsonObject.addProperty("id", src.getID());
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package ani.rss.util.basic;
|
||||
package ani.rss.commons;
|
||||
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class MyURLUtil {
|
||||
public class URLUtil extends cn.hutool.core.util.URLUtil {
|
||||
/**
|
||||
* 自动添加http协议
|
||||
*
|
||||
61
ani-rss-core/pom.xml
Normal file
61
ani-rss-core/pom.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss</artifactId>
|
||||
<version>2.4.8</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ani-rss-core</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ani.rss</groupId>
|
||||
<artifactId>ani-rss-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse</groupId>
|
||||
<artifactId>bittorrent</artifactId>
|
||||
<version>0.3.0-v20070627-1030</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.50.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.5.19</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.biezhi</groupId>
|
||||
<artifactId>TinyPinyin</artifactId>
|
||||
<version>2.0.3.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.21.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
12
ani-rss-core/src/main/java/ani/rss/CoreMain.java
Normal file
12
ani-rss-core/src/main/java/ani/rss/CoreMain.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package ani.rss;
|
||||
|
||||
import ani.rss.commons.MavenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class CoreMain {
|
||||
public static void main(String[] args) {
|
||||
String version = MavenUtil.getVersion();
|
||||
log.info("version: {}", version);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
package ani.rss.download;
|
||||
|
||||
import ani.rss.commons.FileUtil;
|
||||
import ani.rss.commons.GsonStatic;
|
||||
import ani.rss.entity.Ani;
|
||||
import ani.rss.entity.Config;
|
||||
import ani.rss.entity.Item;
|
||||
import ani.rss.entity.TorrentsInfo;
|
||||
import ani.rss.util.basic.GsonStatic;
|
||||
import ani.rss.util.basic.HttpReq;
|
||||
import ani.rss.util.basic.MyFileUtil;
|
||||
import ani.rss.util.basic.RenameCacheUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
@@ -113,7 +112,7 @@ public class Aria2 implements BaseDownload {
|
||||
.setName(name)
|
||||
.setHash(infoHash)
|
||||
.setState(state)
|
||||
.setDownloadDir(MyFileUtil.getAbsolutePath(dir))
|
||||
.setDownloadDir(FileUtil.getAbsolutePath(dir))
|
||||
.setFiles(() -> files);
|
||||
torrentsInfos.add(torrentsInfo);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user