data
This commit is contained in:
parent
71778b0bd3
commit
c5cb9fca5b
4
pom.xml
4
pom.xml
|
@ -10,8 +10,8 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
void main(String[] args) {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplication.run(Main.class, args);
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -3,17 +3,13 @@ package com.dengqn.app.lingyinapi.apis;
|
|||
import com.dengqn.app.lingyinapi.beans.SeedListItem;
|
||||
import com.dengqn.app.lingyinapi.beans.api.Page;
|
||||
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.http.HttpTool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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 java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -41,17 +36,36 @@ public class Seed {
|
|||
this.okHttpClient = okHttpClient;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<Resp<Page<SeedListItem>>> getSeedPage(
|
||||
@GetMapping("/book/list")
|
||||
public ResponseEntity<Resp<Page<SeedListItem>>> getBookSeedPage(
|
||||
@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
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
// log.info("html:{}", html);
|
||||
Document doc = Jsoup.parse(html);
|
||||
|
@ -62,10 +76,8 @@ public class Seed {
|
|||
.size(Integer.valueOf(size))
|
||||
.total(HtmlTool.getPageTotal(doc))
|
||||
.list(listItem)
|
||||
.build()));
|
||||
.build()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class HtmlTool {
|
|||
public static List<SeedListItem> getSeedListItem(Document doc) {
|
||||
Element torrents;
|
||||
try {
|
||||
torrents = doc.getElementsByClass("torrents").getFirst();
|
||||
torrents = doc.getElementsByClass("torrents").get(0);
|
||||
} catch (Exception e) {
|
||||
log.info("搜不到东西:{}", e.getMessage());
|
||||
return new ArrayList<>();
|
||||
|
@ -66,7 +66,7 @@ public class HtmlTool {
|
|||
|
||||
public static Integer getPageTotal(Document document) {
|
||||
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");
|
||||
if (pages == null || pages.size() == 0) return 0;
|
||||
|
|
Loading…
Reference in New Issue