| | |
| | | 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.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.Iqiyi2Service; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | 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 org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Service |
| | | public class Iqiyi2ServiceImpl implements Iqiyi2Service { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger("videoUpdate"); |
| | | |
| | | @Resource |
| | | private VideoIqiyi2Dao videoIqiyi2Dao; |
| | | |
| | |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoId) { |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoId, int page, int pageSize) { |
| | | //查询专辑 |
| | | VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoId)); |
| | | if (videoIqiyi2 == null) |
| | |
| | | if (album.getFeatureAlbumId() > 0) {//单视频 |
| | | album2List.add(album); |
| | | } else {//专辑 |
| | | List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(album.getId(), 0, 1000); |
| | | //判断period字段是否为空 |
| | | int sort = album.isSourceAlbum() ? IqiyiAlbum2.SORT_PERIOD : IqiyiAlbum2.SORT_ORDER; |
| | | Iqiyi2AlbumQuery query = new Iqiyi2AlbumQuery(); |
| | | query.setFeatureAlbumId(album.getId()); |
| | | query.setContentType(1); |
| | | List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(query, sort, (page - 1) * pageSize, pageSize); |
| | | if (list != null) |
| | | album2List.addAll(list); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(album.getName())) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | //只缓存有效的 |
| | | if (album.getEffect() == 0) |
| | | return; |
| | |
| | | return; |
| | | } |
| | | |
| | | //标题中只能包含中英文与数字 |
| | | String regx = "^[(\\u4e00-\\u9fa5)( )a-zA-Z0-9]+$"; |
| | | if (!Pattern.matches(regx, album.getName())) { |
| | | return; |
| | | |
| | | if (album.getChannelId() != 1 && !VideoConstant.iqiyiSpecialNames.contains(album.getName())) { |
| | | //标题中只能包含中英文与数字 |
| | | String regx = "^[(\\u4e00-\\u9fa5)(:)( )a-zA-Z0-9]+$"; |
| | | if (!Pattern.matches(regx, album.getName())) { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //过滤某些短片与影评 |
| | | if (album.getName().contains("《") && !VideoConstant.iqiyiSpecialNames.contains(album.getName())) |
| | | return; |
| | | |
| | | //空电视剧或者是空动漫则返回 |
| | | if (album.getChannelId() == 2 || album.getChannelId() == 4) { |
| | |
| | | return; |
| | | } |
| | | |
| | | logger.info(VideoLogFactory.createAddToVideoLog(album)); |
| | | |
| | | VideoInfo newVideoInfo = convertAlbumToVideoInfo(album); |
| | | VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(album.getId()); |
| | |
| | | if (videoInfo == null) |
| | | return; |
| | | newVideoInfo.setId(videoInfo.getId()); |
| | | if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag())) { |
| | | if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag()) || newVideoInfo.getVideocount() != videoInfo.getVideocount()) { |
| | | newVideoInfo.setCreatetime(videoInfo.getCreatetime()); |
| | | //更新信息tag信息 |
| | | videoInfo.setLatestHpicture(newVideoInfo.getLatestHpicture()); |
| | |
| | | videoInfo.setVpicture(newVideoInfo.getVpicture()); |
| | | videoInfo.setShow(newVideoInfo.getShow()); |
| | | videoInfo.setVideoType(newVideoInfo.getVideoType()); |
| | | videoInfo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoDao.update(videoInfo); |
| | | } |
| | | } else {//视频不存在 |
| | |
| | | oldVideo.setVpicture(newVideoInfo.getVpicture()); |
| | | oldVideo.setShow(newVideoInfo.getShow()); |
| | | oldVideo.setVideoType(newVideoInfo.getVideoType()); |
| | | oldVideo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoDao.update(oldVideo); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public int getShowType(String videoid) { |
| | | VideoInfo videoInfo = videoInfoDao.find(VideoInfo.class, videoid); |
| | | if (videoInfo.getVideoType() != null && (videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN)) |
| | | return 2; |
| | | else |
| | | return 1; |
| | | VideoIqiyi2 iqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoid)); |
| | | if (iqiyi2 != null) { |
| | | IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(iqiyi2.getIqiyiId()); |
| | | if (album2 != null) { |
| | | if (album2.getChannelId() == 4 || album2.getChannelId() == 2) { |
| | | if (album2.isSourceAlbum()) { |
| | | return 1; |
| | | } else |
| | | return 2; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | |
| | | video.setLatestVpicture(IqiyiUtil.getVPicture(album2.getImageUrl())); |
| | | } |
| | | } |
| | | long videoCount = iqiyiAlbum2Dao.countVideoByAid(album.getId()); |
| | | if (videoCount == 0L) |
| | | videoCount = 1; |
| | | |
| | | if (album.getTvQipuIds() != null && album.getTvQipuIds().size() > 0) |
| | | video.setVideocount(album.getTvQipuIds().size()); |
| | | else |
| | | video.setVideocount(1); |
| | | video.setVideocount((int) videoCount); |
| | | |
| | | video.setUpdatetime(System.currentTimeMillis() + ""); |
| | | |
| | |
| | | public IqiyiAlbum2 selectAlbumById(Long id) { |
| | | return iqiyiAlbum2Dao.get(id); |
| | | } |
| | | |
| | | @Override |
| | | public long countById(Long id) { |
| | | return iqiyiAlbum2Dao.countById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByAid(long id) { |
| | | long count = iqiyiAlbum2Dao.countById(id); |
| | | if (count > 0) { |
| | | iqiyiAlbum2Dao.delete(id); |
| | | } |
| | | VideoIqiyi2 bean = videoIqiyi2Dao.selectByIqiyiId(id); |
| | | if (bean != null) { |
| | | videoIqiyi2Dao.delete(bean.getVideoId()); |
| | | //删除资源 |
| | | resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil2.RESOURCE_ID + ""); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<IqiyiAlbum2> listByIds(List<Long> idsList) { |
| | | return iqiyiAlbum2Dao.listByIds(idsList); |
| | | } |
| | | } |