This commit is contained in:
dengqn 2025-09-28 09:23:55 +08:00
parent 71778b0bd3
commit c5cb9fca5b
4 changed files with 33 additions and 21 deletions

View File

@ -10,8 +10,8 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<maven.compiler.source>25</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>

View File

@ -13,7 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class Main { public class Main {
void main(String[] args) { public static void main(String[] args) {
try { try {
SpringApplication.run(Main.class, args); SpringApplication.run(Main.class, args);
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -3,17 +3,13 @@ package com.dengqn.app.lingyinapi.apis;
import com.dengqn.app.lingyinapi.beans.SeedListItem; import com.dengqn.app.lingyinapi.beans.SeedListItem;
import com.dengqn.app.lingyinapi.beans.api.Page; import com.dengqn.app.lingyinapi.beans.api.Page;
import com.dengqn.app.lingyinapi.beans.api.Resp; import com.dengqn.app.lingyinapi.beans.api.Resp;
import com.dengqn.app.lingyinapi.config.CookieConfig;
import com.dengqn.app.lingyinapi.html.HtmlTool; import com.dengqn.app.lingyinapi.html.HtmlTool;
import com.dengqn.app.lingyinapi.http.HttpTool; import com.dengqn.app.lingyinapi.http.HttpTool;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import org.jetbrains.annotations.NotNull;
import okhttp3.Response;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -21,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -41,8 +36,8 @@ public class Seed {
this.okHttpClient = okHttpClient; this.okHttpClient = okHttpClient;
} }
@GetMapping("/list") @GetMapping("/book/list")
public ResponseEntity<Resp<Page<SeedListItem>>> getSeedPage( public ResponseEntity<Resp<Page<SeedListItem>>> getBookSeedPage(
@RequestParam(required = false, defaultValue = "0", name = "inclbookmarked") String inclbookmarked, @RequestParam(required = false, defaultValue = "0", name = "inclbookmarked") String inclbookmarked,
@RequestParam(required = false, defaultValue = "1", name = "incldead") String incldead, @RequestParam(required = false, defaultValue = "1", name = "incldead") String incldead,
@RequestParam(required = false, defaultValue = "0", name = "spstate") String spstate, @RequestParam(required = false, defaultValue = "0", name = "spstate") String spstate,
@ -52,6 +47,25 @@ public class Seed {
) throws IOException { ) throws IOException {
String url = "https://pt.soulvoice.club/special.php?inclbookmarked=%s&incldead=%s&spstate=%s&page=%s&search=%s" String url = "https://pt.soulvoice.club/special.php?inclbookmarked=%s&incldead=%s&spstate=%s&page=%s&search=%s"
.formatted(inclbookmarked, incldead, spstate, page, search); .formatted(inclbookmarked, incldead, spstate, page, search);
return getSeedList(page, size, url);
}
@GetMapping("/other/list")
public ResponseEntity<Resp<Page<SeedListItem>>> getOtherSeedPage(
@RequestParam(required = false, defaultValue = "0", name = "inclbookmarked") String inclbookmarked,
@RequestParam(required = false, defaultValue = "1", name = "incldead") String incldead,
@RequestParam(required = false, defaultValue = "0", name = "spstate") String spstate,
@RequestParam(required = false, defaultValue = "0", name = "page") String page,
@RequestParam(required = false, defaultValue = "50", name = "size") String size,
@RequestParam(required = false, defaultValue = "", name = "search") String search
) throws IOException {
String url = "https://pt.soulvoice.club/special.php?inclbookmarked=%s&incldead=%s&spstate=%s&page=%s&search=%s"
.formatted(inclbookmarked, incldead, spstate, page, search);
return getSeedList(page, size, url);
}
@NotNull
private ResponseEntity<Resp<Page<SeedListItem>>> getSeedList(String page, String size, String url) {
String html = HttpTool.getHTML(url, okHttpClient); String html = HttpTool.getHTML(url, okHttpClient);
// log.info("html:{}", html); // log.info("html:{}", html);
Document doc = Jsoup.parse(html); Document doc = Jsoup.parse(html);
@ -66,6 +80,4 @@ public class Seed {
} }
} }

View File

@ -20,7 +20,7 @@ public class HtmlTool {
public static List<SeedListItem> getSeedListItem(Document doc) { public static List<SeedListItem> getSeedListItem(Document doc) {
Element torrents; Element torrents;
try { try {
torrents = doc.getElementsByClass("torrents").getFirst(); torrents = doc.getElementsByClass("torrents").get(0);
} catch (Exception e) { } catch (Exception e) {
log.info("搜不到东西:{}", e.getMessage()); log.info("搜不到东西:{}", e.getMessage());
return new ArrayList<>(); return new ArrayList<>();
@ -66,7 +66,7 @@ public class HtmlTool {
public static Integer getPageTotal(Document document) { public static Integer getPageTotal(Document document) {
Elements paginationEl = document.getElementsByClass("nexus-pagination"); Elements paginationEl = document.getElementsByClass("nexus-pagination");
if (paginationEl == null) return 0; if (paginationEl == null || paginationEl.size() == 0) return 0;
Elements pages = paginationEl.first().getElementsByTag("a"); Elements pages = paginationEl.first().getElementsByTag("a");
if (pages == null || pages.size() == 0) return 0; if (pages == null || pages.size() == 0) return 0;