From cad915058c3c53bf328a8ae9ca9bc7de099caba7 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 06 二月 2021 15:27:49 +0800 Subject: [PATCH] 接口bug修改 --- src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil2.java | 476 +++++++++++++++++++++++------------------------------------ 1 files changed, 188 insertions(+), 288 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil2.java b/src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil2.java index 9055086..4548159 100644 --- a/src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil2.java +++ b/src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil2.java @@ -1,89 +1,106 @@ package com.yeshi.buwan.iqiyi.util; -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.dao.video.AlbumVideoMapDao; -import com.yeshi.buwan.domain.*; -import com.yeshi.buwan.domain.entity.PlayUrl; -import com.yeshi.buwan.domain.video.AlbumVideoMap; +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.IqiyiAlbum2; -import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; import com.yeshi.buwan.iqiyi.vo.IqiyiAlbumListResult; -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.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.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; - - @Resource - private AlbumVideoMapDao albumVideoMapDao; + 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 @@ -97,43 +114,55 @@ 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, 217289601L); } - //拉取所有的综艺 + //鎷夊彇鎵�鏈夌殑缁艰壓 public void syncAllZongYi() { 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) @@ -145,188 +174,29 @@ } } - //将专辑添加到视频 - @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; - - //综艺必须要有内容 - if (album.getChannelId() == 6) { - if (album.getTvQipuIds().size() == 0) - 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); - } - - //加入专辑视频映射 - AlbumVideoMap map = new AlbumVideoMap(); - map.setCreateTime(new Date()); - map.setVideoId(newVideoInfo.getId()); - map.setRootVideoType(newVideoInfo.getVideoType().getId()); - map.setVideoCount(newVideoInfo.getVideocount()); - albumVideoMapDao.save(map); - - //加入映射 - 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()); - - CMQManager.getInstance().addSolrMsg(newVideoInfo.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) { @@ -339,27 +209,30 @@ 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; } @@ -369,52 +242,30 @@ 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; } @@ -422,4 +273,53 @@ 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; + } + + } -- Gitblit v1.8.0