diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index f306ad3..9bdcb3c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,7 @@ - - + + 4.0.0 crawler-video top.yuchat @@ -30,7 +31,7 @@ org.springframework.boot - spring-boot-starter + spring-boot-starter-web @@ -71,6 +72,13 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + true + + diff --git a/src/main/java/top/yuchat/crawler/video/models/service/MadouVideoService.java b/src/main/java/top/yuchat/crawler/video/models/service/MadouVideoService.java index 8acd6f3..c8f4bb1 100644 --- a/src/main/java/top/yuchat/crawler/video/models/service/MadouVideoService.java +++ b/src/main/java/top/yuchat/crawler/video/models/service/MadouVideoService.java @@ -1,11 +1,15 @@ package top.yuchat.crawler.video.models.service; import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; + +import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -60,7 +64,6 @@ public class MadouVideoService extends ServiceImpl list = classifyInfoService.list(); int count = 0; @@ -68,7 +71,8 @@ public class MadouVideoService extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("m3u8", false); @@ -148,7 +150,9 @@ public class MadouVideoService extends ServiceImpl { try { log.info("下载封面图片,名称:{},地址:{}", videoInfo.getTitle(), videoInfo.getCoverUrl()); - httpRequestComponent.download(videoInfo.getCoverUrl(), Paths.get(imgPath.toString(), videoInfo.getId().toString() + videoInfo.getCoverUrl().substring(videoInfo.getCoverUrl().lastIndexOf(".")))); + httpRequestComponent.download(videoInfo.getCoverUrl(), + Paths.get(imgPath.toString(), videoInfo.getId().toString() + + videoInfo.getCoverUrl().substring(videoInfo.getCoverUrl().lastIndexOf(".")))); log.info("开始下载:{},m3u8地址:{}", videoInfo.getTitle(), videoInfo.getM3u8Url()); String result = httpRequestComponent.get(videoInfo.getM3u8Url()); @@ -176,7 +180,7 @@ public class MadouVideoService extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.isNull("size"); @@ -189,7 +193,8 @@ public class MadouVideoService extends ServiceImpl pageList(Integer page, Integer size, String classify, String title) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (StringUtils.isNotBlank(classify)) { + queryWrapper.eq(MadouVideoInfo::getClassify, classify); + } + + if (StringUtils.isNotBlank(title)) { + queryWrapper.like(MadouVideoInfo::getTitle, title); + } + + return this.page(new Page<>(page, size), queryWrapper); + } } diff --git a/src/main/java/top/yuchat/crawler/video/utils/HttpRequestComponent.java b/src/main/java/top/yuchat/crawler/video/utils/HttpRequestComponent.java index 7e3da8b..487dc14 100644 --- a/src/main/java/top/yuchat/crawler/video/utils/HttpRequestComponent.java +++ b/src/main/java/top/yuchat/crawler/video/utils/HttpRequestComponent.java @@ -2,7 +2,6 @@ package top.yuchat.crawler.video.utils; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; import org.apache.http.HttpStatus; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -31,7 +30,7 @@ import java.security.NoSuchAlgorithmException; @Slf4j @Component public class HttpRequestComponent { - private static final HttpHost PROXY = new HttpHost("172.20.0.1", 1080); + // private static final HttpHost PROXY = new HttpHost("172.20.0.1", 1080); private CloseableHttpClient closeableHttpClient; private RequestConfig requestConfig; @@ -48,7 +47,7 @@ public class HttpRequestComponent { public void createHttpClients() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial(null, (_, _) -> true); + builder.loadTrustMaterial(null, (_2, _1) -> true); SSLConnectionSocketFactory sslref = new SSLConnectionSocketFactory(builder.build(), NoopHostnameVerifier.INSTANCE); Registry registry = RegistryBuilder.create().register("http", new PlainConnectionSocketFactory()).register("https", sslref).build(); PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);