| | |
| | | package com.yeshi.buwan.iqiyi.util; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.buwan.dao.VideoInfoDao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiAlbum2Dao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyi2Dao; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.iqiyi.IqiYiAPI; |
| | | import com.yeshi.buwan.domain.AdminInfo; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.VideoType; |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.iqiyi.entity.*; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.iqiyi.vo.IqiyiAlbumListResult; |
| | | import com.yeshi.buwan.log.LogHelper; |
| | | 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 net.sf.json.JSONArray; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.jsoup.select.Elements; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | @Component |
| | | public class IqiyiUtil2 { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger("iqiyiVideoUpdate"); |
| | | |
| | | public final int PLAY_NONE = 0;// 不能播放 |
| | | public final int PLAY_HTML = 1;// 跳转移动端网页播放 |
| | | public final int PLAY_SWF = 2;// 嵌套网页播放 |
| | | public final static int PLAY_NONE = 0;// 不能播放 |
| | | public final static int PLAY_HTML = 1;// 跳转移动端网页播放 |
| | | public final static int PLAY_SWF = 2;// 嵌套网页播放 |
| | | |
| | | private final static long RESOURCE_ID = 22L; |
| | | |
| | | public final static int RESOURCE_ID = 22; |
| | | public final static String RESOURCE_NAME = "爱奇艺."; |
| | | @Resource |
| | | private IqiyiAlbum2Dao iqiyiAlbum2Dao; |
| | | |
| | | @Resource |
| | | private VideoIqiyi2Dao videoIqiyi2Dao; |
| | | |
| | | @Resource |
| | | private VideoInfoDao videoInfoDao; |
| | | |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | @Resource |
| | | private VideoInfoService videoInfoService; |
| | | |
| | | @Resource |
| | | private CategoryVideoService categoryVideoService; |
| | | |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | private Iqiyi2Service iqiyi2Service; |
| | | |
| | | private void saveAlbumAndVideo(List<IqiyiAlbum2> list) { |
| | | if (list == null) |
| | | return; |
| | | for (IqiyiAlbum2 album : list) { |
| | | if (album.getContentType() != 1) |
| | | continue; |
| | | if (!albumIsValid(album)) {//如果是无效的专辑就需要删除 |
| | | iqiyi2Service.deleteByAid(album.getId()); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | logger.info(VideoLogFactory.createAddAlbumLog(album)); |
| | | |
| | | if (album.getTvQipuIds() != null && album.getTvQipuIds().size() > 0) { |
| | | int pageSize = 10; |
| | | int page = album.getTvQipuIds().size() % pageSize == 0 ? album.getTvQipuIds().size() / pageSize : album.getTvQipuIds().size() / pageSize + 1; |
| | | for (int p = 0; p < page; p++) { |
| | | int startIndex = p * pageSize; |
| | | int toIndex = (startIndex + pageSize) > album.getTvQipuIds().size() ? album.getTvQipuIds().size() : (startIndex + pageSize); |
| | | List<IqiyiAlbum2> detailList = IqiYiNewAPI.getAlbumOrVideoDetail(album.getTvQipuIds().subList(startIndex, toIndex)); |
| | | if (detailList != null) |
| | | for (IqiyiAlbum2 video : detailList) |
| | | iqiyiAlbum2Dao.save(video); |
| | | //查询最新的一集是否缓存 |
| | | boolean needSaveVideos = true; |
| | | if (album.getLatestVideo() != null) { |
| | | if (iqiyi2Service.countById(album.getLatestVideo().getId()) > 0L) |
| | | needSaveVideos = false; |
| | | } |
| | | |
| | | |
| | | if (needSaveVideos) { |
| | | int pageSize = 10; |
| | | int page = album.getTvQipuIds().size() % pageSize == 0 ? album.getTvQipuIds().size() / pageSize : album.getTvQipuIds().size() / pageSize + 1; |
| | | for (int p = 0; p < page; p++) { |
| | | int startIndex = p * pageSize; |
| | | int toIndex = (startIndex + pageSize) > album.getTvQipuIds().size() ? album.getTvQipuIds().size() : (startIndex + pageSize); |
| | | List<Long> tvQipuIds = new ArrayList<>(); |
| | | tvQipuIds.addAll(album.getTvQipuIds().subList(startIndex, toIndex)); |
| | | |
| | | //查询是否已经存在了 |
| | | List<IqiyiAlbum2> existList = iqiyi2Service.listByIds(tvQipuIds); |
| | | Set<Long> sets = new HashSet<>(); |
| | | if (existList != null && existList.size() > 0) { |
| | | for (IqiyiAlbum2 a : existList) |
| | | sets.add(a.getId()); |
| | | |
| | | //删除已经存在的 |
| | | for (int i = 0; i < tvQipuIds.size(); i++) { |
| | | if (sets.contains(tvQipuIds.get(i))) { |
| | | tvQipuIds.remove(i--); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (tvQipuIds.size() > 0) { |
| | | List<IqiyiAlbum2> detailList = IqiYiNewAPI.getAlbumOrVideoDetail(tvQipuIds); |
| | | if (detailList != null) |
| | | for (IqiyiAlbum2 video : detailList) |
| | | iqiyi2Service.saveIqiyiAlbum(video); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | iqiyiAlbum2Dao.save(album); |
| | | iqiyi2Service.saveIqiyiAlbum(album); |
| | | CMQManager.getInstance().addIqiyiAlbumUpdateMsg(album.getId()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 同步所有的专辑与视频 |
| | | * 同步所有的专辑与视频 |
| | | * |
| | | * @param categoryId |
| | | * @param isAlbum |
| | |
| | | if (result.getAlbum2List() != null) { |
| | | saveAlbumAndVideo(result.getAlbum2List()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | //拉取所有的电影 |
| | | |
| | | /** |
| | | * 根据专辑ID查询 |
| | | * |
| | | * @param aid |
| | | */ |
| | | public void syncByAid(Long aid) { |
| | | List<Long> aidList = new ArrayList<>(); |
| | | aidList.add(aid); |
| | | List<IqiyiAlbum2> album2List = IqiYiNewAPI.getAlbumOrVideoDetail(aidList); |
| | | saveAlbumAndVideo(album2List); |
| | | } |
| | | |
| | | //拉取所有的电影 |
| | | public void syncAllDianYing() { |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DIANYING, false, 255675400l); |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DIANYING, false, null); |
| | | } |
| | | |
| | | //拉取所有的电视剧 |
| | | //拉取所有的电视剧 |
| | | public void syncAllDianShiJu() { |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DIANSHIJU, true, 206929801L); |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DIANSHIJU, true, null); |
| | | } |
| | | |
| | | //拉取所有的动漫 |
| | | //拉取所有的动漫 |
| | | public void syncAllDongMan() { |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DONGMAN, true, null); |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_DONGMAN, true, 217289601L); |
| | | } |
| | | |
| | | //拉取所有的综艺 |
| | | //拉取所有的综艺 |
| | | public void syncAllZongYi() { |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_ZONGYI, true, null); |
| | | syncAlbumAndVideo(IqiYiNewAPI.TYPE_ZONGYI, true, 246881501L); |
| | | } |
| | | |
| | | //更新专辑 |
| | | public void updateAlbum(int categoryId, Date startTime, Date endTime) { |
| | | IqiyiAlbumListResult result = IqiYiNewAPI.getUpdateAlbumList(categoryId + "", startTime, endTime, null, true, 10); |
| | | //更新专辑 |
| | | public void updateAlbum(int categoryId, boolean isAlbum, Date startTime, Date endTime) { |
| | | IqiyiAlbumListResult result = IqiYiNewAPI.getUpdateAlbumList(categoryId + "", startTime, endTime, null, isAlbum, 10); |
| | | if (result.getAlbum2List() != null) |
| | | saveAlbumAndVideo(result.getAlbum2List()); |
| | | while (result.getMinId() != null) { |
| | | result = IqiYiNewAPI.getUpdateAlbumList(categoryId + "", startTime, endTime, result.getMinId(), true, 10); |
| | | result = IqiYiNewAPI.getUpdateAlbumList(categoryId + "", startTime, endTime, result.getMinId(), isAlbum, 10); |
| | | if (result.getAlbum2List() != null) |
| | | saveAlbumAndVideo(result.getAlbum2List()); |
| | | } |
| | | } |
| | | |
| | | //更新视频 |
| | | //更新视频 |
| | | public void updateVideo(int categoryId, Date startTime, Date endTime) { |
| | | IqiyiAlbumListResult result = IqiYiNewAPI.getUpdateVideoList(categoryId + "", startTime, endTime, null, true, 10); |
| | | if (result.getAlbum2List() != null) |
| | |
| | | } |
| | | } |
| | | |
| | | //将专辑添加到视频 |
| | | @Transactional |
| | | public void addToVideoInfo(IqiyiAlbum2 album) { |
| | | if (album.getFeatureAlbumId() > 0L && album.getChannelId() != IqiYiNewAPI.TYPE_DIANYING) { |
| | | return; |
| | | } |
| | | |
| | | //只缓存有效的 |
| | | if(album.getEffect()==0) |
| | | return; |
| | | |
| | | //只缓存正片 |
| | | if(album.getContentType()!=1) |
| | | return; |
| | | |
| | | VideoInfo newVideoInfo = convertAlbumToVideoInfo(album); |
| | | VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(album.getId()); |
| | | if (videoIqiyi2 != null) {//渠道视频已经存在 |
| | | VideoInfo videoInfo = videoInfoDao.find(VideoInfo.class, videoIqiyi2.getVideoId()); |
| | | if (videoInfo == null) |
| | | return; |
| | | |
| | | if (newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag())) |
| | | return; |
| | | newVideoInfo.setId(videoInfo.getId()); |
| | | newVideoInfo.setCreatetime(videoInfo.getCreatetime()); |
| | | //更新信息tag信息 |
| | | videoInfo.setLatestHpicture(newVideoInfo.getLatestHpicture()); |
| | | videoInfo.setLatestVpicture(newVideoInfo.getLatestVpicture()); |
| | | videoInfo.setVideocount(newVideoInfo.getVideocount()); |
| | | videoInfo.setTag(newVideoInfo.getTag()); |
| | | videoInfo.setPicture(newVideoInfo.getPicture()); |
| | | videoInfo.setHpicture(newVideoInfo.getHpicture()); |
| | | videoInfo.setVpicture(newVideoInfo.getVpicture()); |
| | | videoInfo.setShow(newVideoInfo.getShow()); |
| | | videoInfoDao.update(videoInfo); |
| | | } else {//视频不存在 |
| | | //判断2个视频实体是否为同一视频 |
| | | VideoInfo oldVideo = videoInfoService.getExistSameVideo(newVideoInfo); |
| | | if (oldVideo == null) { |
| | | //添加视频 |
| | | Serializable id = videoInfoDao.save(newVideoInfo); |
| | | newVideoInfo.setId(id + ""); |
| | | } else {//为同一视频 |
| | | //更新tag |
| | | newVideoInfo.setId(oldVideo.getId()); |
| | | oldVideo.setLatestHpicture(newVideoInfo.getLatestHpicture()); |
| | | oldVideo.setLatestVpicture(newVideoInfo.getLatestVpicture()); |
| | | oldVideo.setVideocount(newVideoInfo.getVideocount()); |
| | | oldVideo.setTag(newVideoInfo.getTag()); |
| | | oldVideo.setPicture(newVideoInfo.getPicture()); |
| | | oldVideo.setHpicture(newVideoInfo.getHpicture()); |
| | | oldVideo.setVpicture(newVideoInfo.getVpicture()); |
| | | oldVideo.setShow(newVideoInfo.getShow()); |
| | | videoInfoDao.update(oldVideo); |
| | | } |
| | | |
| | | //加入映射 |
| | | VideoIqiyi2 vi = new VideoIqiyi2(); |
| | | vi.setIqiyiId(album.getId()); |
| | | vi.setVideoId(Long.parseLong(newVideoInfo.getId())); |
| | | videoIqiyi2Dao.save(vi); |
| | | |
| | | |
| | | //添加视频来源映射 |
| | | resourceVideoService.addVideoResource(newVideoInfo.getId(), RESOURCE_ID + ""); |
| | | //添加视频分类映射 |
| | | categoryVideoService.addCategoryVideo(newVideoInfo.getId(), newVideoInfo.getVideoType().getId()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | //更新最近一天的的专辑与视频 |
| | | public void updateTodayAlbumAndVideo() { |
| | | //更新最近一天的的专辑与视频 |
| | | public void updateTodayAlbumAndVideo(int channelId) { |
| | | long now = System.currentTimeMillis(); |
| | | for (int i = 0; i < 8; i++) { |
| | | Date endTime = new Date(now - i * 1000 * 60 * 60L * 3); |
| | | Date endTime = new Date(now - 1000 * 60 * 60L * 3 * i); |
| | | Date startTime = new Date(endTime.getTime() - 1000 * 60 * 60L * 3); |
| | | |
| | | //更新电影 |
| | | updateVideo(IqiYiNewAPI.TYPE_DIANYING, startTime, endTime); |
| | | //更新电视剧 |
| | | updateAlbum(IqiYiNewAPI.TYPE_DIANSHIJU, startTime, endTime); |
| | | updateVideo(IqiYiNewAPI.TYPE_DIANSHIJU, startTime, endTime); |
| | | |
| | | //更新动漫 |
| | | updateAlbum(IqiYiNewAPI.TYPE_DONGMAN, startTime, endTime); |
| | | updateVideo(IqiYiNewAPI.TYPE_DONGMAN, startTime, endTime); |
| | | |
| | | //更新综艺 |
| | | updateAlbum(IqiYiNewAPI.TYPE_ZONGYI, startTime, endTime); |
| | | updateVideo(IqiYiNewAPI.TYPE_ZONGYI, startTime, endTime); |
| | | } |
| | | } |
| | | |
| | | |
| | | public VideoInfo convertAlbumToVideoInfo(IqiyiAlbum2 album) { |
| | | Calendar ca = Calendar.getInstance(); |
| | | ca.setTimeInMillis(TimeUtil.convertGernalTime(album.getPeriod(), "yyyyMMdd")); |
| | | int day = ca.get(Calendar.DAY_OF_MONTH); |
| | | int month = ca.get(Calendar.MONTH) + 1; |
| | | int year = ca.get(Calendar.YEAR); |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | video.setVideoType(new VideoType(IqiyiUtil.getType(album.getContentType()))); |
| | | video.setArea(album.getAreas()); |
| | | video.setBaseurl(album.getH5Url()); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day + ""); |
| | | video.setDirector(album.getDirectors()); |
| | | video.setDuration(album.getDuration() + ""); |
| | | video.setFinish("1"); |
| | | video.setIntroduction(album.getDesc()); |
| | | video.setMainActor(album.getMainCharacters()); |
| | | video.setMonth(month + ""); |
| | | video.setName(album.getName()); |
| | | if (album.getLatestVideo() != null) |
| | | video.setNowNumber(album.getLatestVideo().getOrder() + ""); |
| | | else |
| | | video.setNowNumber("1"); |
| | | video.setOrderby("0" + ""); |
| | | video.setPicture(album.getImageUrl()); |
| | | |
| | | video.setVpicture(IqiyiUtil.getVPicture(video.getPicture())); |
| | | video.setHpicture(IqiyiUtil.getHPicture(video.getPicture())); |
| | | |
| | | if (album.getStatistics() != null) |
| | | video.setScore(album.getStatistics().getScore() + ""); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | |
| | | video.setThirdType("1"); |
| | | video.setTotalNumber("0"); |
| | | |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year + ""); |
| | | video.setAdmin(new AdminInfo("1")); |
| | | video.setContentType(album.getContentType()); |
| | | video.setCommentCount(0); |
| | | |
| | | String tag = getAlbumTag(album); |
| | | video.setTag(tag); |
| | | |
| | | if (album.getLatestVideo() != null) { |
| | | //查询最近的图片 |
| | | IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(album.getLatestVideo().getId()); |
| | | if (album2 != null) { |
| | | video.setLatestHpicture(IqiyiUtil.getHPicture(album2.getImageUrl())); |
| | | video.setLatestVpicture(IqiyiUtil.getVPicture(album2.getImageUrl())); |
| | | switch (channelId) { |
| | | case IqiYiNewAPI.TYPE_DIANYING: |
| | | updateAlbum(channelId, true, startTime, endTime); |
| | | break; |
| | | case IqiYiNewAPI.TYPE_DIANSHIJU: |
| | | case IqiYiNewAPI.TYPE_DONGMAN: |
| | | case IqiYiNewAPI.TYPE_ZONGYI: |
| | | updateAlbum(channelId, true, startTime, endTime); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (album.getTvQipuIds() != null && album.getTvQipuIds().size() > 0) |
| | | video.setVideocount(album.getTvQipuIds().size()); |
| | | else |
| | | video.setVideocount(1); |
| | | |
| | | video.setVideoType(getVideoType(album)); |
| | | return video; |
| | | } |
| | | |
| | | private static VideoType getVideoType(IqiyiAlbum2 album) { |
| | | |
| | | public static VideoType getVideoType(IqiyiAlbum2 album) { |
| | | if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANYING) { |
| | | return new VideoType(VideoConstant.VIDEO_CATEGORY_DIANYING); |
| | | } else if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANSHIJU) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private static String getAlbumTag(IqiyiAlbum2 album) { |
| | | //电影为评分 |
| | | //电视剧和动漫为更新到多少集 |
| | | //综艺为更新到多少期 |
| | | public static String getAlbumTag(IqiyiAlbum2 album) { |
| | | //电影为评分 |
| | | //电视剧和动漫为更新到多少集 |
| | | //综艺为更新到多少期 |
| | | |
| | | String tag = ""; |
| | | if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANYING) |
| | | if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANYING) { |
| | | if (album.getStatistics() != null) |
| | | tag = "评分:" + album.getStatistics().getScore(); |
| | | else if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANSHIJU || album.getChannelId() == IqiYiNewAPI.TYPE_DONGMAN) { |
| | | if (album.getLatestVideo() != null) { |
| | | tag = "评分:" + album.getStatistics().getScore(); |
| | | } else if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANSHIJU || album.getChannelId() == IqiYiNewAPI.TYPE_DONGMAN) { |
| | | if (album.getLatestVideo() != null) { |
| | | if (album.isSourceAlbum()) {//专辑 |
| | | tag = "更新至" + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getLatestVideo().getPeriod(), "yyyyMMdd"), "yyyy-MM-dd") + "期"; |
| | | } else { |
| | | if (album.getLatestVideo().getOrder() == album.getVideoCount()) |
| | | tag = album.getVideoCount() + "集全"; |
| | | tag = album.getVideoCount() + "集全"; |
| | | else |
| | | tag = "更新至" + album.getLatestVideo().getOrder() + "集"; |
| | | tag = "更新至" + album.getLatestVideo().getOrder() + "集"; |
| | | } |
| | | tag = album.getLatestVideo().getOrder() + ""; |
| | | } else if (album.getChannelId() == IqiYiNewAPI.TYPE_ZONGYI) |
| | | if (album.getLatestVideo() != null) { |
| | | tag = "更新至" + album.getLatestVideo().getPeriod() + "期"; |
| | | } |
| | | } |
| | | } else if (album.getChannelId() == IqiYiNewAPI.TYPE_ZONGYI) |
| | | if (album.getLatestVideo() != null) { |
| | | tag = "更新至" + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getLatestVideo().getPeriod(), "yyyyMMdd"), "yyyy-MM-dd") + "期"; |
| | | } |
| | | return tag; |
| | | } |
| | | |
| | |
| | | vi.setAdmin(new AdminInfo("1")); |
| | | vi.setId(album.getId()); |
| | | vi.setIntroduction(album.getDesc()); |
| | | vi.setExtraId(album.getId() + ""); |
| | | vi.setName(album.getName()); |
| | | if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANYING) |
| | | vi.setTag(album.getName()); |
| | | else if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANSHIJU || album.getChannelId() == IqiYiNewAPI.TYPE_DONGMAN) |
| | | vi.setTag(album.getOrder() + ""); |
| | | else if (album.getChannelId() == IqiYiNewAPI.TYPE_ZONGYI) |
| | | vi.setTag(album.getPeriod()); |
| | | else if (album.getChannelId() == IqiYiNewAPI.TYPE_DIANSHIJU || album.getChannelId() == IqiYiNewAPI.TYPE_DONGMAN) { |
| | | if (album.isSourceAlbum()) |
| | | vi.setTag(album.getPeriod() + "\n" + album.getSubTitle()); |
| | | else |
| | | vi.setTag(album.getOrder() + ""); |
| | | } else if (album.getChannelId() == IqiYiNewAPI.TYPE_ZONGYI) |
| | | vi.setTag(album.getPeriod() + "\n" + album.getSubTitle()); |
| | | vi.setType("album"); |
| | | return vi; |
| | | } |
| | | |
| | | |
| | | 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 1; |
| | | else |
| | | return 2; |
| | | } |
| | | |
| | | |
| | | 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 = getPlayType(album); |
| | | PlayUrl pu = new PlayUrl(); |
| | | pu.setParams(""); |
| | | pu.setPlayType(t); |
| | | pu.setResource(vr); |
| | | |
| | | if (t == PLAY_NONE) { |
| | | pu.setUrl(""); |
| | | } else if (t == PLAY_HTML) { |
| | | pu.setUrl(album.getH5Url()); |
| | | } |
| | | return pu; |
| | | } |
| | | |
| | | public int getPlayType(IqiyiAlbum2 album) { |
| | | public static int getPlayType(IqiyiAlbum2 album) { |
| | | int type = PLAY_NONE; |
| | | |
| | | if (album.getEffect() == 0) |
| | | type = PLAY_NONE; |
| | | |
| | | for (IqiyiAlbum2.PlayControlsBean pc : album.getPlayControls()) { |
| | | if (pc.getPlatformId() == 15)// 移动端 |
| | | if (pc.getPlatformId() == 15)// 移动端 |
| | | { |
| | | type = PLAY_HTML; |
| | | } |
| | |
| | | return type; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过列表链接获取爱奇艺中的视频 |
| | | * |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public static List<String> getAlbumUrlsFromUrl(String url) { |
| | | List<String> list = new ArrayList<>(); |
| | | try { |
| | | Document doc = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36").timeout(60000).get(); |
| | | Element root = doc.getElementsByAttributeValue("class", "qy-mod-ul").get(0); |
| | | Elements items = root.getElementsByAttributeValue("class", "qy-mod-li"); |
| | | for (int i = 0; i < items.size(); i++) { |
| | | String href = items.get(i).getElementsByTag("a").get(0).attr("href"); |
| | | if (href.startsWith("//")) |
| | | href = "http:" + href; |
| | | list.add(href); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 专辑是否有效 |
| | | * |
| | | * @param album2 |
| | | * @return |
| | | */ |
| | | public static boolean albumIsValid(IqiyiAlbum2 album2) { |
| | | if (album2.getEffect() != 1) |
| | | return false; |
| | | |
| | | if (album2.isSupportDrm()) |
| | | return false; |
| | | |
| | | List<IqiyiAlbum2.PlayControlsBean> playControls = album2.getPlayControls(); |
| | | if (playControls == null) |
| | | return false; |
| | | for (IqiyiAlbum2.PlayControlsBean bean : playControls) { |
| | | if (bean.getPlatformId() == 15 && bean.getAvailableStatus() == 1) |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |