|
@@ -2,6 +2,9 @@ package cn.reghao.tnb.content.app.vod.service;
|
|
|
|
|
|
|
|
import cn.reghao.file.api.iface.OssService;
|
|
import cn.reghao.file.api.iface.OssService;
|
|
|
import cn.reghao.oss.api.dto.media.VideoInfo;
|
|
import cn.reghao.oss.api.dto.media.VideoInfo;
|
|
|
|
|
+import cn.reghao.tnb.account.api.dto.AccountInfo;
|
|
|
|
|
+import cn.reghao.tnb.account.api.dto.CrawledUser;
|
|
|
|
|
+import cn.reghao.tnb.account.api.iface.AccountQuery;
|
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoFileUpdate;
|
|
import cn.reghao.tnb.content.api.dto.VideoFileUpdate;
|
|
|
import cn.reghao.tnb.content.api.dto.spider.CrawledVideo;
|
|
import cn.reghao.tnb.content.api.dto.spider.CrawledVideo;
|
|
@@ -20,7 +23,9 @@ import org.springframework.stereotype.Service;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class CrawledDataService {
|
|
public class CrawledDataService {
|
|
|
- @DubboReference(check = false)
|
|
|
|
|
|
|
+ @DubboReference(check = false, retries = 0, timeout = 5_000)
|
|
|
|
|
+ private AccountQuery accountQuery;
|
|
|
|
|
+ @DubboReference(check = false, retries = 0, timeout = 5_000)
|
|
|
private OssService ossService;
|
|
private OssService ossService;
|
|
|
|
|
|
|
|
private final VideoPostService videoPostService;
|
|
private final VideoPostService videoPostService;
|
|
@@ -31,19 +36,23 @@ public class CrawledDataService {
|
|
|
this.videoRepository = videoRepository;
|
|
this.videoRepository = videoRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public VideoPost videoExist(String videoId) {
|
|
|
|
|
- VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
|
|
|
- return videoPost;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public synchronized void publishVideo(CrawledVideo crawledVideo) {
|
|
public synchronized void publishVideo(CrawledVideo crawledVideo) {
|
|
|
String videoId = crawledVideo.getVideoId();
|
|
String videoId = crawledVideo.getVideoId();
|
|
|
VideoPost videoPost1 = videoRepository.getVideoPost(videoId);
|
|
VideoPost videoPost1 = videoRepository.getVideoPost(videoId);
|
|
|
if (videoPost1 != null ) {
|
|
if (videoPost1 != null ) {
|
|
|
|
|
+ log.error("VideoPost {} exists", videoPost1.getVideoId());
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- VideoPost videoPost = new VideoPost(crawledVideo);
|
|
|
|
|
|
|
+ CrawledUser crawledUser = crawledVideo.getCrawledUser();
|
|
|
|
|
+ String username = crawledUser.getUsername();
|
|
|
|
|
+ AccountInfo accountInfo = accountQuery.getByUsername(username);
|
|
|
|
|
+ Long publishBy = accountInfo != null ? accountInfo.getUserId() : null;
|
|
|
|
|
+ if (publishBy == null) {
|
|
|
|
|
+ publishBy = accountQuery.createCrawledAccount(crawledUser);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ VideoPost videoPost = new VideoPost(crawledVideo, publishBy);
|
|
|
VideoStatistic videoStatistic = new VideoStatistic(crawledVideo);
|
|
VideoStatistic videoStatistic = new VideoStatistic(crawledVideo);
|
|
|
String tags = crawledVideo.getTags();
|
|
String tags = crawledVideo.getTags();
|
|
|
videoPostService.saveVideo(videoPost, videoStatistic, tags);
|
|
videoPostService.saveVideo(videoPost, videoStatistic, tags);
|