From afa0108680df8a363ccd692a0664ba80d6a9af70 Mon Sep 17 00:00:00 2001 From: li-guohao <46225881+li-guohao@users.noreply.github.com> Date: Wed, 7 Dec 2022 23:54:36 +0800 Subject: [PATCH] add api for find dmhy rss items by keyword (#148), close issue #147 * add api for find dmhy rss items by keyword * update changelog --- CHANGELOG.MD | 3 +++ .../server/openapi/TripartiteRestController.java | 11 ++++++++++- .../ikaros/server/tripartite/dmhy/DmhyClientImpl.java | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 93965a77d..9c82155c4 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,9 @@ - 添加动漫花园资源查询接口 - 添加特征资源匹配下载的定时任务 +## Bugfix +- 添加根据关键词查询动漫花园资源接口,修复问题:如果通过番组计划的中文查不到资源,则无法正常订阅 #147 + ## Pages - 完善动漫详情页,并对接服务端 - 对接动漫资源查询接口,完善动漫详情页订阅流程 diff --git a/src/main/java/run/ikaros/server/openapi/TripartiteRestController.java b/src/main/java/run/ikaros/server/openapi/TripartiteRestController.java index 36ba28480..cf02534cc 100644 --- a/src/main/java/run/ikaros/server/openapi/TripartiteRestController.java +++ b/src/main/java/run/ikaros/server/openapi/TripartiteRestController.java @@ -59,7 +59,7 @@ public CommonResult bgmTvTokenUserMe() { } @GetMapping("/dmhy/rss/items/anime/{id}") - public CommonResult> findDmhyRssItems( + public CommonResult> findDmhyRssItemsByAnimeId( @PathVariable("id") Long animeId, @RequestParam(required = false, name = "seq") Long seq) { AssertUtils.notNull(animeId, "anime id"); @@ -75,4 +75,13 @@ public CommonResult> findDmhyRssItems( titleCn + (null == seq ? "" : " " + ((seq > 0 && seq < 10) ? "0" + seq : seq)); return CommonResult.ok(dmhyClient.findRssItems(keywords, DmhyCategory.ANIME)); } + + @GetMapping("/dmhy/rss/items") + public CommonResult> findDmhyRssItemsByKeyword( + @RequestParam("keyword") String keyword, + @RequestParam(required = false, name = "seq") Long seq) { + AssertUtils.notBlank(keyword, "keyword"); + keyword = keyword + (null == seq ? "" : " " + ((seq > 0 && seq < 10) ? "0" + seq : seq)); + return CommonResult.ok(dmhyClient.findRssItems(keyword, DmhyCategory.ANIME)); + } } diff --git a/src/main/java/run/ikaros/server/tripartite/dmhy/DmhyClientImpl.java b/src/main/java/run/ikaros/server/tripartite/dmhy/DmhyClientImpl.java index 8a8309a3e..055008133 100644 --- a/src/main/java/run/ikaros/server/tripartite/dmhy/DmhyClientImpl.java +++ b/src/main/java/run/ikaros/server/tripartite/dmhy/DmhyClientImpl.java @@ -110,6 +110,14 @@ public List findRssItems(@Nonnull String keyword, cacheXmlFile.delete(); } } + + // 动漫花园,分类是动画的话,全集也会被查询出来,所以这里做下过滤 + if (category != null) { + dmhyRssItemList = dmhyRssItemList.stream() + .filter(dmhyRssItem -> category.equals(dmhyRssItem.getCategory())) + .toList(); + } + log.debug("end find rss items with keyword={} and category={}, find size={}", keyword, category, dmhyRssItemList.size()); return dmhyRssItemList;