Skip to content

Commit

Permalink
add api for find dmhy rss items by keyword (#148), close issue #147
Browse files Browse the repository at this point in the history
* add api for find dmhy rss items by keyword

* update changelog
  • Loading branch information
chivehao authored Dec 7, 2022
1 parent 9386f47 commit afa0108
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- 添加动漫花园资源查询接口
- 添加特征资源匹配下载的定时任务

## Bugfix
- 添加根据关键词查询动漫花园资源接口,修复问题:如果通过番组计划的中文查不到资源,则无法正常订阅 #147

## Pages
- 完善动漫详情页,并对接服务端
- 对接动漫资源查询接口,完善动漫详情页订阅流程
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public CommonResult<BgmTvUserInfo> bgmTvTokenUserMe() {
}

@GetMapping("/dmhy/rss/items/anime/{id}")
public CommonResult<List<DmhyRssItem>> findDmhyRssItems(
public CommonResult<List<DmhyRssItem>> findDmhyRssItemsByAnimeId(
@PathVariable("id") Long animeId,
@RequestParam(required = false, name = "seq") Long seq) {
AssertUtils.notNull(animeId, "anime id");
Expand All @@ -75,4 +75,13 @@ public CommonResult<List<DmhyRssItem>> 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<List<DmhyRssItem>> 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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ public List<DmhyRssItem> 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;
Expand Down

0 comments on commit afa0108

Please sign in to comment.