| | |
| | | import com.yeshi.buwan.dao.video.AlbumVideoMapDao; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.domain.solr.SolrAlbumVideo; |
| | | import com.yeshi.buwan.domain.system.SystemConfig; |
| | | import com.yeshi.buwan.domain.video.AlbumVideoMap; |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; |
| | | import com.yeshi.buwan.dto.mq.UpdateResourceVideoMQMsg; |
| | | import com.yeshi.buwan.exception.video.IqiyiVideoSolrException; |
| | | import com.yeshi.buwan.query.Iqiyi2AlbumQuery; |
| | | import com.yeshi.buwan.service.imp.CategoryVideoService; |
| | | import com.yeshi.buwan.service.imp.ResourceVideoService; |
| | | import com.yeshi.buwan.service.imp.VideoInfoService; |
| | | import com.yeshi.buwan.service.imp.VideoResourceService; |
| | | import com.yeshi.buwan.service.inter.juhe.AlbumVideoMapService; |
| | | import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.ThreadUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.log.VideoLogFactory; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.util.mq.rabbit.RabbitmqManager; |
| | | import com.yeshi.buwan.videos.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.videos.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.videos.iqiyi.entity.VideoIqiyi2; |
| | | import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil; |
| | | import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil2; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private AlbumVideoMapService albumVideoMapService; |
| | | |
| | | @Resource |
| | | private SolrAlbumVideoDataManager solrAlbumVideoDataManager; |
| | | |
| | | @Resource |
| | | private RabbitmqManager rabbitmqManager; |
| | | |
| | | |
| | | |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoId, int page, int pageSize) { |
| | | //查询专辑 |
| | | VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoId)); |
| | | if (videoIqiyi2 == null) |
| | | return null; |
| | | |
| | | IqiyiAlbum2 album = iqiyiAlbum2Dao.get(videoIqiyi2.getIqiyiId()); |
| | | final IqiyiAlbum2 album = iqiyiAlbum2Dao.get(videoIqiyi2.getIqiyiId()); |
| | | // if (album != null) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | rabbitmqManager.addUpdateResourceVideoMsg(new UpdateResourceVideoMQMsg(videoIqiyi2.getIqiyiId() + "", IqiyiUtil2.RESOURCE_ID, new Date())); |
| | | } |
| | | }); |
| | | // } |
| | | |
| | | List<IqiyiAlbum2> album2List = new ArrayList<>(); |
| | | if (album.getFeatureAlbumId() > 0) {//单视频 |
| | | album2List.add(album); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void offlineIqiyiAlbum(Long id) { |
| | | //删除专辑 |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().orOperator(Criteria.where("id").is(id), Criteria.where("featureAlbumId").is(id))); |
| | | //删除专辑下的视频 |
| | | iqiyiAlbum2Dao.delete(query); |
| | | } |
| | | |
| | | |
| | | public boolean isUnNormalUpdateVideoName(String name) { |
| | | SystemConfig config = systemConfigService.getConfigByKeyCache("iqiyi_update_video_name"); |
| | | if (config != null) { |
| | | String[] sts = config.getValue().split(","); |
| | | List<String> list = new ArrayList<>(); |
| | | for (String st : sts) { |
| | | list.add(st.trim()); |
| | | } |
| | | return list.contains(name.trim()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void addToVideoInfo(IqiyiAlbum2 album) { |
| | | if (album.getFeatureAlbumId() > 0L && album.getChannelId() != IqiYiNewAPI.TYPE_DIANYING) { |
| | | return; |
| | |
| | | } |
| | | |
| | | |
| | | if (album.getChannelId() != 1 && !VideoConstant.iqiyiSpecialNames.contains(album.getName())) { |
| | | if (album.getChannelId() != 1 && !isUnNormalUpdateVideoName(album.getName())) { |
| | | //标题中只能包含中英文与数字 |
| | | String regx = "^[(\\u4e00-\\u9fa5)(:)( )a-zA-Z0-9]+$"; |
| | | if (!Pattern.matches(regx, album.getName())) { |
| | |
| | | } |
| | | |
| | | //过滤某些短片与影评 |
| | | if (album.getName().contains("《") && !VideoConstant.iqiyiSpecialNames.contains(album.getName())) |
| | | if (album.getName().contains("《") && !isUnNormalUpdateVideoName(album.getName())) |
| | | return; |
| | | |
| | | //空电视剧或者是空动漫则返回 |
| | |
| | | videoInfo.setShow(newVideoInfo.getShow()); |
| | | videoInfo.setVideoType(newVideoInfo.getVideoType()); |
| | | videoInfo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoDao.update(videoInfo); |
| | | videoInfoService.update(videoInfo); |
| | | } |
| | | } else {//视频不存在 |
| | | //判断2个视频实体是否为同一视频 |
| | | VideoInfo oldVideo = videoInfoService.getExistSameVideoWithTime(newVideoInfo); |
| | | if (oldVideo == null) { |
| | | //添加视频 |
| | | Serializable id = videoInfoDao.save(newVideoInfo); |
| | | Serializable id = videoInfoService.save(newVideoInfo); |
| | | newVideoInfo.setId(id + ""); |
| | | } else {//为同一视频 |
| | | //更新tag |
| | |
| | | oldVideo.setShow(newVideoInfo.getShow()); |
| | | oldVideo.setVideoType(newVideoInfo.getVideoType()); |
| | | oldVideo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoDao.update(oldVideo); |
| | | videoInfoService.update(oldVideo); |
| | | } |
| | | |
| | | //加入专辑视频映射 |
| | | AlbumVideoMap map = new AlbumVideoMap(); |
| | | map.setId(newVideoInfo.getId()); |
| | | map.setCreateTime(new Date()); |
| | | map.setVideoId(newVideoInfo.getId()); |
| | | map.setRootVideoType(newVideoInfo.getVideoType().getId()); |
| | |
| | | //添加视频分类映射 |
| | | categoryVideoService.addCategoryVideo(newVideoInfo.getId(), newVideoInfo.getVideoType().getId()); |
| | | |
| | | CMQManager.getInstance().addSolrMsg(newVideoInfo.getId()); |
| | | rabbitmqManager.addSolrMsg(newVideoInfo.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public PlayUrl getPlayUrl(String detailSystemId, int resourceId, String id, String videoId) { |
| | | |
| | | IqiyiAlbum2 album = iqiyiAlbum2Dao.get(Long.parseLong(id)); |
| | | VideoResource vr = videoResourceService.getResource(resourceId + ""); |
| | | int t = IqiyiUtil2.getPlayType(album); |
| | |
| | | } else if (t == IqiyiUtil2.PLAY_HTML) { |
| | | pu.setUrl(album.getH5Url()); |
| | | } |
| | | |
| | | //韩剧 |
| | | if ("48".equalsIgnoreCase(detailSystemId)) { |
| | | pu.setUrl(pu.getUrl().replace("_bwap", "_hjvap")); |
| | | } |
| | | |
| | | return pu; |
| | | } |
| | | |
| | |
| | | } |
| | | VideoIqiyi2 bean = videoIqiyi2Dao.selectByIqiyiId(id); |
| | | if (bean != null) { |
| | | videoIqiyi2Dao.delete(bean.getVideoId()); |
| | | videoIqiyi2Dao.deleteById(bean.getVideoId()); |
| | | //删除资源 |
| | | resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil2.RESOURCE_ID + ""); |
| | | resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil.RESOURCE_ID + ""); |
| | | } |
| | | |
| | | } |
| | |
| | | public List<IqiyiAlbum2> listByIds(List<Long> idsList) { |
| | | return iqiyiAlbum2Dao.listByIds(idsList); |
| | | } |
| | | |
| | | @Override |
| | | public void validAlbumSolrState(Long albumId) throws IqiyiVideoSolrException { |
| | | long count = iqiyiAlbum2Dao.countById(albumId); |
| | | if (count <= 0L) { |
| | | throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_ALBUM_NOT_SAVE, "专辑尚未缓存"); |
| | | } |
| | | VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(albumId); |
| | | if (videoIqiyi2 == null) { |
| | | throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_ALBUM_NOT_ADD_TO_VIDEO, "专辑尚未添加到视频总览"); |
| | | } |
| | | |
| | | |
| | | AlbumVideoMap albumVideoMap = albumVideoMapService.selectByVideoId(videoIqiyi2.getVideoId() + ""); |
| | | if (albumVideoMap == null) { |
| | | throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_VIDEO_NOT_ADD_TO_SOLR_ALBUM, "视频未添加到专辑搜索映射"); |
| | | } |
| | | |
| | | SolrAlbumVideo solrAlbumVideo = solrAlbumVideoDataManager.findOne(videoIqiyi2.getVideoId()); |
| | | if (solrAlbumVideo == null) { |
| | | throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_VIDEO_NOT_SYNC_TO_SOLR, "视频尚未同步到搜索引擎"); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |