feat(media): 支持后台转码配置与缩略图轴
This commit is contained in:
1 parent
70da939a58
commit
316baf28d6
39 files changed
+1523
-38
No files matched your search
+16
-5
@@ -20,6 +20,7 @@ import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import com.fruitshorts.media.service.PlaybackSigner;
|
||||
import com.fruitshorts.media.service.ThumbnailUrlResolver;
|
||||
import com.fruitshorts.content.vo.DramaCategoryRespVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -50,6 +51,7 @@ public class AppCatalogService {
|
||||
private final DramaCategoryService dramaCategoryService;
|
||||
private final PlaybackSigner playbackSigner;
|
||||
private final CommentService commentService;
|
||||
private final ThumbnailUrlResolver thumbnailUrlResolver;
|
||||
|
||||
public AppFeedVO homeFeed() {
|
||||
Map<Long, String> categoryNames = categoryNameMap();
|
||||
@@ -110,6 +112,8 @@ public class AppCatalogService {
|
||||
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
||||
Map<Long, Long> episodeCommentCounts = commentService.countByEpisodes(
|
||||
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||
Map<Long, String> thumbnailUrls = thumbnailUrlResolver.resolveAll(
|
||||
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
||||
|
||||
AppDramaDetailVO detail = new AppDramaDetailVO();
|
||||
@@ -128,7 +132,7 @@ public class AppCatalogService {
|
||||
detail.setFavoriteCount(drama.getFavoriteCount());
|
||||
detail.setCommentCount(commentService.countByDrama(dramaId));
|
||||
detail.setEpisodes(episodes.stream()
|
||||
.map(episode -> toEpisode(episode, episodeCommentCounts))
|
||||
.map(episode -> toEpisode(episode, episodeCommentCounts, thumbnailUrls))
|
||||
.toList());
|
||||
return detail;
|
||||
}
|
||||
@@ -176,14 +180,18 @@ public class AppCatalogService {
|
||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(ids);
|
||||
Map<Long, Long> commentCounts = commentService.countByEpisodes(
|
||||
previews.values().stream().map(DramaEpisode::getId).sorted().toList());
|
||||
Map<Long, String> thumbnailUrls = thumbnailUrlResolver.resolveAll(
|
||||
previews.values().stream().map(DramaEpisode::getId).sorted().toList());
|
||||
return dramas.stream()
|
||||
.map(drama -> toCard(
|
||||
drama, categoryNames, previews.get(drama.getId()), commentCounts))
|
||||
drama, categoryNames, previews.get(drama.getId()), commentCounts,
|
||||
thumbnailUrls))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private AppDramaCardVO toCard(Drama drama, Map<Long, String> categoryNames,
|
||||
DramaEpisode preview, Map<Long, Long> commentCounts) {
|
||||
DramaEpisode preview, Map<Long, Long> commentCounts,
|
||||
Map<Long, String> thumbnailUrls) {
|
||||
AppDramaCardVO card = new AppDramaCardVO();
|
||||
card.setId(drama.getId());
|
||||
card.setTitle(drama.getTitle());
|
||||
@@ -201,11 +209,13 @@ public class AppCatalogService {
|
||||
? 0L : commentCounts.getOrDefault(preview.getId(), 0L));
|
||||
card.setLanguage(drama.getLanguage());
|
||||
card.setDramaType(drama.getDramaType());
|
||||
card.setPreview(preview == null ? null : toEpisode(preview, commentCounts));
|
||||
card.setPreview(preview == null
|
||||
? null : toEpisode(preview, commentCounts, thumbnailUrls));
|
||||
return card;
|
||||
}
|
||||
|
||||
private AppEpisodeVO toEpisode(DramaEpisode episode, Map<Long, Long> commentCounts) {
|
||||
private AppEpisodeVO toEpisode(DramaEpisode episode, Map<Long, Long> commentCounts,
|
||||
Map<Long, String> thumbnailUrls) {
|
||||
AppEpisodeVO vo = new AppEpisodeVO();
|
||||
vo.setId(episode.getId());
|
||||
vo.setNumber(episode.getEpNo());
|
||||
@@ -219,6 +229,7 @@ public class AppCatalogService {
|
||||
vo.setUnlockCoin(episode.getUnlockCoin());
|
||||
vo.setLikeCount(episode.getLikeCount() == null ? 0L : episode.getLikeCount());
|
||||
vo.setCommentCount(commentCounts.getOrDefault(episode.getId(), 0L));
|
||||
vo.setThumbnailsUrl(thumbnailUrls.get(episode.getId()));
|
||||
if (free) {
|
||||
// 播放地址统一在这里签名:客户端拿不到可长期复用的裸地址
|
||||
vo.setPlayUrl(playbackSigner.sign(playableSource(episode)));
|
||||
|
||||
@@ -24,4 +24,6 @@ public class AppEpisodeVO {
|
||||
* 详情页拿到就能直接播,不必按集再请求一次播放票据。
|
||||
*/
|
||||
private String playUrl;
|
||||
/** 雪碧图 WebVTT 时间轴地址;没有产物时为 null */
|
||||
private String thumbnailsUrl;
|
||||
}
|
||||
Reference in new issue
Block a user