| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import java.io.Serializable; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.VideoType; |
| | | import com.yeshi.buwan.pptv.entity.PPTVProgram; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.util.AESUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Iterator; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.yeshi.buwan.dao.juhe.pptv.PPTVMovieVideoDao; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.pptv.entity.PPTVCartoonDetail; |
| | | import com.yeshi.buwan.pptv.entity.PPTVCartoonVideo; |
| | | import com.yeshi.buwan.pptv.entity.PPTVMovieVideo; |
| | | import com.yeshi.buwan.pptv.entity.PPTVShortVideo; |
| | | import com.yeshi.buwan.pptv.entity.PPTVShowDetail; |
| | | import com.yeshi.buwan.pptv.entity.PPTVShowVideo; |
| | | import com.yeshi.buwan.pptv.entity.PPTVTVDetail; |
| | | import com.yeshi.buwan.pptv.entity.PPTVTVVideo; |
| | | import com.yeshi.buwan.service.imp.juhe.PPTVService; |
| | | import com.yeshi.buwan.util.HttpUtil; |
| | | import com.yeshi.buwan.util.NumberUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | |
| | | @Component |
| | | public class PPTVUtil { |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | @Resource |
| | | private PPTVMovieVideoDao pptvMovieVideoDao; |
| | | |
| | | // 解析电影 |
| | | public void startParseMovie() { |
| | | List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_MOVIE); |
| | | for (String url : urlList) { |
| | | List<PPTVMovieVideo> list = PPTVDataParseUtil.parseMovieListVideo(HttpUtil.get(url)); |
| | | for (PPTVMovieVideo pv : list) { |
| | | if (pv.getOp().equalsIgnoreCase("del")) {// 删除 |
| | | pptvService.deletePPTVMovie(pv); |
| | | } else {// 增加或者更新 |
| | | Serializable id = pptvService.saveOrUpdatePPTVMovie(pv); |
| | | if (id != null) |
| | | pptvService.addPPTVMovieToVideoInfo(pv, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | public final static int RESOURCE_ID = 25; |
| | | |
| | | // 解析电视剧 |
| | | public void startParseTV() { |
| | | List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_TV); |
| | | for (int p = 0; p < urlList.size(); p++) { |
| | | String url = urlList.get(p); |
| | | List<PPTVTVVideo> list = PPTVDataParseUtil.parseTVListVideo(HttpUtil.get(url)); |
| | | System.out.println(list.size()); |
| | | for (int n = 0; n < list.size(); n++) { |
| | | PPTVTVVideo pv = list.get(n); |
| | | if (pv.getOp().equalsIgnoreCase("del")) {// 删除 |
| | | pptvService.deletePPTVTV(pv); |
| | | } else {// 增加或者更新 |
| | | String videoid = pptvService.saveOrUpdatePPTVTV(pv) + ""; |
| | | boolean isUpdate = pptvService.hasTVUpdate(pv.getDetailList()); |
| | | for (PPTVTVDetail pd : pv.getDetailList()) { |
| | | public final static int PLAY_NONE = 0;// 不能播放 |
| | | public final static int PLAY_HTML = 1;// 跳转移动端网页播放 |
| | | public final static int PLAY_SDK = 2;// 内嵌SDK播放 |
| | | |
| | | pd.setVideoId(pv.getAid()); |
| | | if (pd.getOp().equalsIgnoreCase("del")) { |
| | | pptvService.deletePPTVTVDetail(pd); |
| | | } else { |
| | | pptvService.saveOrUpdatePPTVTVDetail(pd); |
| | | } |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(videoid)) |
| | | pptvService.addPPTVTVToVideoInfo(pv, isUpdate); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 解析综艺 |
| | | public void startParseShow() { |
| | | List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_SHOW); |
| | | for (String url : urlList) { |
| | | List<PPTVShowVideo> list = PPTVDataParseUtil.parseShowListVideo(HttpUtil.get(url)); |
| | | for (PPTVShowVideo pv : list) { |
| | | if (pv.getOp().equalsIgnoreCase("del")) {// 删除 |
| | | pptvService.deletePPTVShow(pv); |
| | | } else {// 增加或者更新 |
| | | String videoid = pptvService.saveOrUpdatePPTVShow(pv) + ""; |
| | | boolean isUpdate = pptvService.hasShowUpdate(pv.getDetailList()); |
| | | for (PPTVShowDetail pd : pv.getDetailList()) { |
| | | pd.setVideoId(pv.getAid()); |
| | | if (pd.getOp().equalsIgnoreCase("del")) { |
| | | pptvService.deletePPTVShowDetail(pd); |
| | | } else { |
| | | pptvService.saveOrUpdatePPTVShowDetail(pd); |
| | | } |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(videoid)) |
| | | pptvService.addPPTVShowToVideoInfo(pv, isUpdate); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | private static Long getVideoType(PPTVSeries series) { |
| | | String type = series.getProgramType(); |
| | | if (type.contains("VIP")) { |
| | | type = series.getProgramType2(); |
| | | } |
| | | |
| | | // 解析卡通 |
| | | public void startParseCartoon() { |
| | | List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_CARTON); |
| | | for (String url : urlList) { |
| | | List<PPTVCartoonVideo> list = PPTVDataParseUtil.parseCartoonListVideo(HttpUtil.get(url)); |
| | | for (PPTVCartoonVideo pv : list) { |
| | | if (pv.getOp().equalsIgnoreCase("del")) {// 删除 |
| | | pptvService.deletePPTVCartoon(pv); |
| | | } else {// 增加或者更新 |
| | | String videoid = pptvService.saveOrUpdatePPTVCartoon(pv) + ""; |
| | | boolean isUpdate = pptvService.hasCartoonUpdate(pv.getDetailList()); |
| | | for (PPTVCartoonDetail pd : pv.getDetailList()) { |
| | | pd.setVideoId(pv.getAid()); |
| | | if (pd.getOp().equalsIgnoreCase("del")) { |
| | | pptvService.deletePPTVCartoonDetail(pd); |
| | | } else { |
| | | pptvService.saveOrUpdatePPTVCartoonDetail(pd); |
| | | } |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(videoid)) |
| | | pptvService.addPPTVCartoonToVideoInfo(pv, isUpdate); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | int videoType = 0; |
| | | switch (type) { |
| | | case "电影": |
| | | videoType = VideoConstant.VIDEO_CATEGORY_DIANYING; |
| | | break; |
| | | case "电视剧": |
| | | videoType = VideoConstant.VIDEO_CATEGORY_DIANSHIJU; |
| | | break; |
| | | case "综艺": |
| | | videoType = VideoConstant.VIDEO_CATEGORY_ZONGYI; |
| | | break; |
| | | case "动漫": |
| | | videoType = VideoConstant.VIDEO_CATEGORY_DONGMAN; |
| | | break; |
| | | case "少儿": |
| | | videoType = 312; |
| | | break; |
| | | default: |
| | | return null; |
| | | } |
| | | |
| | | // 解析小视频 |
| | | public void startParseShortVideo() { |
| | | List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_SHORTVIDEO); |
| | | for (String url : urlList) { |
| | | List<PPTVShortVideo> list = PPTVDataParseUtil.parseShortListVideo(HttpUtil.get(url)); |
| | | for (PPTVShortVideo pv : list) { |
| | | if (pv.getOp().equalsIgnoreCase("del")) {// 删除 |
| | | pptvService.deletePPTVShort(pv); |
| | | } else {// 增加或者更新 |
| | | Serializable id = pptvService.saveOrUpdatePPTVShort(pv); |
| | | if (id != null) |
| | | pptvService.addPPTVShortToVideoInfo(pv, false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return (long) videoType; |
| | | } |
| | | |
| | | // 获取分类 |
| | | public static List<Integer> getTypeList(String rc, String sc) { |
| | | List<Integer> list = new ArrayList<Integer>(); |
| | | if (rc.equalsIgnoreCase("电影")) { |
| | | if ("预告".equalsIgnoreCase(sc)) { |
| | | list.add(281); |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | list.add(281); |
| | | } else { |
| | | list.add(151); |
| | | } |
| | | |
| | | } else if (rc.equalsIgnoreCase("电视剧")) { |
| | | if ("预告".equalsIgnoreCase(sc)) { |
| | | list.add(282); |
| | | } else if ("剧八卦".equalsIgnoreCase(sc)) { |
| | | list.add(282); |
| | | } else |
| | | list.add(150); |
| | | /** |
| | | * 视频转换 |
| | | * |
| | | * @param series |
| | | * @return |
| | | */ |
| | | public static List<VideoConvertResult> convertToVideoInfo(PPTVSeries series) { |
| | | Long videoTypeId = getVideoType(series); |
| | | |
| | | } else if (rc.equalsIgnoreCase("卡通")) {// 现场 预告 MV 原创 音乐 自制 用户上传 |
| | | if ("现场".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("预告".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("MV".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("原创".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("音乐".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("自制".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | list.add(283); |
| | | } else |
| | | list.add(153); |
| | | if (videoTypeId == null) |
| | | return null; |
| | | |
| | | } else if (rc.equalsIgnoreCase("综艺")) { |
| | | list.add(152); |
| | | } else if (rc.equalsIgnoreCase("生活")) {// 美味食刻 萌宠萌宝 新辣生活 健康休闲 生活窍门 用户上传 |
| | | // 猎奇趣闻 |
| | | if ("美味食刻".equalsIgnoreCase(sc)) { |
| | | list.add(228); |
| | | } else if ("萌宠萌宝".equalsIgnoreCase(sc)) { |
| | | } else if ("新辣生活".equalsIgnoreCase(sc)) { |
| | | list.add(230); |
| | | } else if ("健康休闲".equalsIgnoreCase(sc)) { |
| | | list.add(230); |
| | | } else if ("生活窍门".equalsIgnoreCase(sc)) { |
| | | list.add(230); |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | } else if ("猎奇趣闻".equalsIgnoreCase(sc)) { |
| | | } |
| | | List<VideoConvertResult> list = new ArrayList<>(); |
| | | |
| | | } else if (rc.equalsIgnoreCase("时尚")) {// 秀场传真 媒体专区 美丽课堂 视觉大赏 用户上传 风尚快报 |
| | | // 潮流关键词 时尚人物 品牌风向标 |
| | | if ("秀场传真".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("媒体专区".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("美丽课堂".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("视觉大赏".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | } else if ("风尚快报".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("潮流关键词".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("时尚人物".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } else if ("品牌风向标".equalsIgnoreCase(sc)) { |
| | | list.add(232); |
| | | } |
| | | if (videoTypeId.longValue() == VideoConstant.VIDEO_CATEGORY_DIANYING) { |
| | | //PPTV电影一个百科ID下面可能有多个视频(国语版/粤语版) |
| | | for (PPTVProgram program : series.getSeries()) { |
| | | list.add(new VideoConvertResult(convertToVideoInfo(series, program), program.getProgramCode())); |
| | | } |
| | | } else { |
| | | list.add(new VideoConvertResult(convertToVideoInfo(series, null), null)); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } else if (rc.equalsIgnoreCase("音乐")) {// 舞蹈 不要 音乐节 用户上传 颁奖礼 翻唱猎奇 自制音乐 |
| | | // 乐人无数 戏曲 新歌首发 音乐资讯 内地 港台 台湾音乐 |
| | | // 日本 韩国 欧美 现场 合作比赛 影视原声 其他 |
| | | if ("舞蹈".equalsIgnoreCase(sc)) { |
| | | list.add(303); |
| | | } else if ("不要".equalsIgnoreCase(sc)) { |
| | | } else if ("音乐节".equalsIgnoreCase(sc)) { |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | } else if ("颁奖礼".equalsIgnoreCase(sc)) { |
| | | } else if ("翻唱猎奇".equalsIgnoreCase(sc)) { |
| | | list.add(304); |
| | | } else if ("自制音乐".equalsIgnoreCase(sc)) { |
| | | } else if ("乐人无数".equalsIgnoreCase(sc)) { |
| | | } else if ("戏曲".equalsIgnoreCase(sc)) { |
| | | } else if ("新歌首发".equalsIgnoreCase(sc)) { |
| | | } else if ("音乐资讯".equalsIgnoreCase(sc)) { |
| | | list.add(280); |
| | | } else if ("内地".equalsIgnoreCase(sc)) { |
| | | } else if ("港台".equalsIgnoreCase(sc)) { |
| | | } else if ("台湾音乐".equalsIgnoreCase(sc)) { |
| | | } else if ("日本".equalsIgnoreCase(sc)) { |
| | | } else if ("韩国".equalsIgnoreCase(sc)) { |
| | | } else if ("欧美".equalsIgnoreCase(sc)) { |
| | | } else if ("现场".equalsIgnoreCase(sc)) { |
| | | list.add(303); |
| | | } else if ("合作比赛".equalsIgnoreCase(sc)) { |
| | | } else if ("影视原声".equalsIgnoreCase(sc)) { |
| | | list.add(279); |
| | | } else if ("其他".equalsIgnoreCase(sc)) { |
| | | list.add(280); |
| | | } |
| | | private static VideoInfo convertToVideoInfo(PPTVSeries series, PPTVProgram program) { |
| | | int year = Integer.parseInt(series.getReleaseYear()); |
| | | int month = 1; |
| | | int day = 1; |
| | | String director = series.getDirector(); |
| | | String mainActor = series.getActor(); |
| | | |
| | | } else if (rc.equalsIgnoreCase("旅游")) {// 酒店之选 极致旅游 旷世美景 舌尖美食 用户上传 走遍中国 |
| | | // 香艳之旅 环球畅游 出境游(港澳台) 热点推荐 户外猎奇 |
| | | // 沿途春色 人文风物 旅游焦点 网友攻略 |
| | | list.add(229); |
| | | if ("酒店之选".equalsIgnoreCase(sc)) { |
| | | } else if ("极致旅游".equalsIgnoreCase(sc)) { |
| | | } else if ("旷世美景".equalsIgnoreCase(sc)) { |
| | | } else if ("舌尖美食".equalsIgnoreCase(sc)) { |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | } else if ("走遍中国".equalsIgnoreCase(sc)) { |
| | | } else if ("香艳之旅".equalsIgnoreCase(sc)) { |
| | | } else if ("环球畅游".equalsIgnoreCase(sc)) { |
| | | } else if ("出境游(港澳台)".equalsIgnoreCase(sc)) { |
| | | } else if ("热点推荐".equalsIgnoreCase(sc)) { |
| | | } else if ("户外猎奇".equalsIgnoreCase(sc)) { |
| | | } else if ("沿途春色".equalsIgnoreCase(sc)) { |
| | | } else if ("人文风物".equalsIgnoreCase(sc)) { |
| | | } else if ("旅游焦点".equalsIgnoreCase(sc)) { |
| | | } else if ("网友攻略".equalsIgnoreCase(sc)) { |
| | | } |
| | | String score = series.getScore(); |
| | | |
| | | } else if (rc.equalsIgnoreCase("搞笑")) {// 郭德纲专场 爆笑秀场 周立波专场 囧人囧片 用户上传 |
| | | // 恶搞整蛊 搞笑自拍 相声小品 超萌系列 动物奇趣 开心广告 |
| | | if ("郭德纲专场".equalsIgnoreCase(sc)) { |
| | | list.add(217); |
| | | } else if ("爆笑秀场".equalsIgnoreCase(sc)) { |
| | | list.add(216); |
| | | } else if ("周立波专场".equalsIgnoreCase(sc)) { |
| | | list.add(217); |
| | | } else if ("囧人囧片".equalsIgnoreCase(sc)) { |
| | | list.add(216); |
| | | } else if ("用户上传".equalsIgnoreCase(sc)) { |
| | | } else if ("恶搞整蛊".equalsIgnoreCase(sc)) { |
| | | list.add(216); |
| | | } else if ("搞笑自拍".equalsIgnoreCase(sc)) { |
| | | list.add(216); |
| | | } else if ("相声小品".equalsIgnoreCase(sc)) { |
| | | list.add(217); |
| | | } else if ("超萌系列".equalsIgnoreCase(sc)) { |
| | | list.add(220); |
| | | } else if ("动物奇趣".equalsIgnoreCase(sc)) { |
| | | list.add(220); |
| | | } else if ("开心广告".equalsIgnoreCase(sc)) { |
| | | list.add(216); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | String tag = ""; |
| | | Long videoTypeId = getVideoType(series); |
| | | if (videoTypeId == null) |
| | | return null; |
| | | VideoType videoType = new VideoType(videoTypeId); |
| | | |
| | | private static String getScore(String vid) { |
| | | String result = HttpUtil |
| | | .get("http://epg.api.pptv.com/detail.api?auth=d410fafad87e7bbf6c6dd62434345818&canal=17&userLevel=0&ppi=AgACAAAABwAABOUAAAAHAAAAAFf5GACAuIIVSMh5Qi0t_zR3NmUpIHR91aabBP6RHKxiYkX3RBkET2s_BTUB5ewNFjXCLeUkiUqMCreGl70MnKLhRpth&appid=com.pplive.androidphone&appver=6.1.5&appplt=aph&vid=" |
| | | + vid |
| | | + "&series=1&virtual=1&ver=4&platform=android3&contentType=Preview&vr=3d%2Cvr360%2Cvr180"); |
| | | String score = PPTVDataParseUtil.parseScore(result); |
| | | return score; |
| | | } |
| | | |
| | | public static VideoInfo convertMovieToVideoInfo(PPTVMovieVideo pptv) { |
| | | String score = getScore(pptv.getVid()); |
| | | String showTime = pptv.getShowTime(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd")); |
| | | String year = calendar.get(Calendar.YEAR) + ""; |
| | | String month = calendar.get(Calendar.MONTH) + ""; |
| | | String day = calendar.get(Calendar.DAY_OF_MONTH) + ""; |
| | | //电影 |
| | | if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANYING) { |
| | | tag = "评分:" + score; |
| | | } else if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoType.getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN) { |
| | | //电视剧,动漫 |
| | | if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) { |
| | | tag = series.getSeriesCount() + "集全"; |
| | | } else { |
| | | tag = "更新至" + series.getCurrentNum() + "集"; |
| | | } |
| | | } else if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_ZONGYI) { |
| | | //综艺 |
| | | if (!StringUtil.isNullOrEmpty(series.getCurrentNum())) { |
| | | tag = series.getCurrentNum().replace("期", ""); |
| | | } else { |
| | | tag = series.getPublishTime().split(" ")[0]; |
| | | } |
| | | } else { |
| | | if ("1".equalsIgnoreCase(series.getSeriesCount())) { |
| | | tag = "评分:" + score; |
| | | } else { |
| | | if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) { |
| | | tag = series.getSeriesCount() + "集全"; |
| | | } else { |
| | | if (series.getCurrentNum() != null) |
| | | tag = "更新至" + series.getCurrentNum() + "集"; |
| | | else { |
| | | tag = "更新至" + series.getSeriesCount() + "集"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | String area = ""; |
| | | for (String st : pptv.getRegion().split("\\$\\$")) |
| | | area += st + " "; |
| | | video.setArea(area); |
| | | video.setBaseurl(""); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setContentType(1); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day); |
| | | String director = ""; |
| | | for (String st : pptv.getDirector().split("\\$\\$")) |
| | | director += st + " "; |
| | | |
| | | video.setDirector(director); |
| | | video.setHpicture(pptv.getHorizontalPoster()); |
| | | video.setIntroduction(pptv.getIntroduction()); |
| | | video.setLatestHpicture(pptv.getHorizontalPoster()); |
| | | video.setLatestVpicture(pptv.getNewPoster()); |
| | | video.setLatestWatchCount(0); |
| | | String mainActor = ""; |
| | | for (String st : pptv.getStarring().split("\\$\\$")) |
| | | mainActor += st + " "; |
| | | video.setMainActor(mainActor); |
| | | video.setMonth(month); |
| | | video.setName(pptv.getWorkName()); |
| | | video.setNowNumber(0 + ""); |
| | | video.setOrderby(0 + ""); |
| | | video.setPicture(pptv.getNewPoster()); |
| | | video.setPlayPicture(pptv.getHorizontalPoster()); |
| | | video.setScore(score); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | video.setTag("评分:" + score); |
| | | video.setThirdType("0"); |
| | | video.setTotalNumber("0"); |
| | | video.setUpdatetime(calendar.getTimeInMillis() + ""); |
| | | video.setVideocount(1); |
| | | video.setVpicture(pptv.getNewPoster()); |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year); |
| | | return video; |
| | | } |
| | | String latestHpicture = program != null ? program.getSubHorCover() : series.getSeries().get(series.getSeries().size() - 1).getSubHorCover(); |
| | | |
| | | public static VideoInfo convertTVToVideoInfo(PPTVTVVideo pptv) { |
| | | Comparator<PPTVTVDetail> cm = new Comparator<PPTVTVDetail>() { |
| | | public int compare(PPTVTVDetail o1, PPTVTVDetail o2) { |
| | | return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq())); |
| | | } |
| | | }; |
| | | long updateTime = System.currentTimeMillis(); |
| | | |
| | | Collections.sort(pptv.getDetailList(), cm); |
| | | VideoInfo vi = new VideoInfo(); |
| | | vi.setVideoType(videoType); |
| | | vi.setArea(series.getCountry()); |
| | | vi.setBaseurl(""); |
| | | vi.setCanSave(false); |
| | | vi.setCommentCount(0); |
| | | vi.setContentType(1); |
| | | vi.setCreatetime(System.currentTimeMillis()); |
| | | vi.setDay(day + ""); |
| | | vi.setDirector(director); |
| | | vi.setFocus(""); |
| | | vi.setHpicture(series.getHorCover()); |
| | | vi.setIntroduction(series.getDescription()); |
| | | vi.setLatestHpicture(latestHpicture); |
| | | vi.setLatestVpicture(""); |
| | | vi.setMainActor(mainActor); |
| | | vi.setMonth(month + ""); |
| | | vi.setName(program != null ? program.getProgramSetTiltle() : series.getName()); |
| | | vi.setNowNumber(0 + ""); |
| | | vi.setOrderby("0"); |
| | | vi.setPicture(series.getCover()); |
| | | vi.setScore(score); |
| | | vi.setShare("0"); |
| | | vi.setShow(1 + ""); |
| | | vi.setTag(tag); |
| | | vi.setVpicture(series.getCover()); |
| | | vi.setWatchCount(0 + ""); |
| | | vi.setYear(year + ""); |
| | | vi.setUpdatetime(updateTime + ""); |
| | | vi.setVideocount(program != null ? 1 : series.getSeries().size()); |
| | | return vi; |
| | | } |
| | | |
| | | String score = getScore(pptv.getDetailList().get(0).getVid()); |
| | | String showTime = pptv.getDetailList().get(pptv.getDetailList().size() - 1).getResourceTime(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd HH:mm:ss")); |
| | | String year = calendar.get(Calendar.YEAR) + ""; |
| | | String month = calendar.get(Calendar.MONTH) + ""; |
| | | String day = calendar.get(Calendar.DAY_OF_MONTH) + ""; |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | String area = ""; |
| | | for (String st : pptv.getRegion().split("\\$\\$")) |
| | | area += st + " "; |
| | | video.setArea(area); |
| | | video.setBaseurl(""); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setContentType(1); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day); |
| | | String director = ""; |
| | | for (String st : pptv.getDirector().split("\\$\\$")) |
| | | director += st + " "; |
| | | public static int getPlayType(AcceptData acceptData, PPTVProgram pptvProgram) { |
| | | if (!pptvProgram.getStatus().equalsIgnoreCase("del")) { |
| | | return PLAY_SDK; |
| | | } else { |
| | | return PLAY_NONE; |
| | | } |
| | | } |
| | | |
| | | video.setDirector(director); |
| | | video.setHpicture(pptv.getHorizontalPoster()); |
| | | video.setIntroduction(pptv.getIntroduction()); |
| | | video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails()); |
| | | video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster()); |
| | | video.setLatestWatchCount(0); |
| | | String mainActor = ""; |
| | | for (String st : pptv.getStarring().split("\\$\\$")) |
| | | mainActor += st + " "; |
| | | video.setMainActor(mainActor); |
| | | video.setMonth(month); |
| | | video.setName(pptv.getWorkName()); |
| | | video.setNowNumber(0 + ""); |
| | | video.setOrderby(0 + ""); |
| | | video.setPicture(pptv.getNewPoster()); |
| | | video.setPlayPicture(pptv.getHorizontalPoster()); |
| | | video.setScore(score); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | if (Integer.parseInt(pptv.getNewUpdate()) == pptv.getTotalnumber()) |
| | | video.setTag(pptv.getNewUpdate() + "集全"); |
| | | else |
| | | video.setTag("更新至" + pptv.getNewUpdate() + "集"); |
| | | video.setThirdType("0"); |
| | | video.setTotalNumber(pptv.getTotalnumber() + ""); |
| | | video.setUpdatetime(calendar.getTimeInMillis() + ""); |
| | | video.setVideocount(pptv.getDetailList().size()); |
| | | video.setVpicture(pptv.getNewPoster()); |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year); |
| | | return video; |
| | | } |
| | | /** |
| | | * 获取pptv的用户ID |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public static String getPPTVUid(String uid) { |
| | | return "buwan_" + uid; |
| | | } |
| | | |
| | | public static VideoInfo convertShowToVideoInfo(PPTVShowVideo pptv) { |
| | | Comparator<PPTVShowDetail> cm = new Comparator<PPTVShowDetail>() { |
| | | public int compare(PPTVShowDetail o1, PPTVShowDetail o2) { |
| | | return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq())); |
| | | } |
| | | }; |
| | | /** |
| | | * 获取pptvcode |
| | | * |
| | | * @param pptvUid |
| | | * @return |
| | | */ |
| | | public static String getPPTVCode(String pptvUid) { |
| | | if (StringUtil.isNullOrEmpty(pptvUid)) |
| | | return null; |
| | | return AESUtil.encrypt(pptvUid + "#" + System.currentTimeMillis()).replace("/", "_").replace("=", "-"); |
| | | } |
| | | |
| | | Collections.sort(pptv.getDetailList(), cm); |
| | | public static String getUidFromPPTVUid(String pptvUid) { |
| | | return pptvUid.split("_")[1]; |
| | | } |
| | | |
| | | String score = getScore(pptv.getDetailList().get(0).getVid()); |
| | | String showTime = pptv.getShowTime(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | long time = TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd"); |
| | | if (time < 0) |
| | | time = TimeUtil.convertGernalTime(pptv.getDetailList().get(0).getDate(), "yyyyMMdd"); |
| | | |
| | | calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd")); |
| | | String year = calendar.get(Calendar.YEAR) + ""; |
| | | String month = calendar.get(Calendar.MONTH) + ""; |
| | | String day = calendar.get(Calendar.DAY_OF_MONTH) + ""; |
| | | /** |
| | | * 解密PPTVCode |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static PPTVCodeInfo decryptPPTVCode(String code) { |
| | | code = code.replace("_", "/").replace("-", "="); |
| | | String info = AESUtil.decrypt(code); |
| | | if (StringUtil.isNullOrEmpty(info)) { |
| | | return null; |
| | | } else { |
| | | String[] sts = info.split("#"); |
| | | if (sts.length != 2) |
| | | return null; |
| | | PPTVCodeInfo codeInfo = new PPTVCodeInfo(); |
| | | codeInfo.pptvUid = sts[0]; |
| | | codeInfo.time = Long.parseLong(sts[1]); |
| | | return codeInfo; |
| | | } |
| | | } |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | String area = ""; |
| | | for (String st : pptv.getRegion().split("\\$\\$")) |
| | | area += st + " "; |
| | | video.setArea(area); |
| | | video.setBaseurl(""); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setContentType(1); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day); |
| | | String director = ""; |
| | | for (String st : pptv.getHost().split("\\$\\$")) |
| | | director += st + " "; |
| | | |
| | | video.setDirector(director); |
| | | video.setHpicture(pptv.getHorizontalPoster()); |
| | | video.setIntroduction(pptv.getIntroduction()); |
| | | video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails()); |
| | | video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster()); |
| | | video.setLatestWatchCount(0); |
| | | String mainActor = ""; |
| | | /** |
| | | * 获取播放链接 |
| | | * |
| | | * @param series |
| | | * @param program |
| | | * @return |
| | | */ |
| | | public static String getPlayUrl(PPTVSeries series, PPTVProgram program) { |
| | | return getPlayUrl(series, program.getProgramCode()); |
| | | } |
| | | |
| | | video.setMainActor(mainActor); |
| | | video.setMonth(month); |
| | | video.setName(pptv.getWorkName()); |
| | | video.setNowNumber(0 + ""); |
| | | video.setOrderby(0 + ""); |
| | | video.setPicture(pptv.getNewPoster()); |
| | | video.setPlayPicture(pptv.getHorizontalPoster()); |
| | | video.setScore(score); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | video.setTag("更新至" |
| | | + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(pptv.getNewUpdate(), "yyyyMMdd"), "yyyy-MM-dd")); |
| | | video.setThirdType("0"); |
| | | video.setTotalNumber(pptv.getTotalNumber() + ""); |
| | | video.setUpdatetime(TimeUtil.convertGernalTime(pptv.getNewUpdate(), "yyyyMMdd") + ""); |
| | | video.setVideocount(pptv.getDetailList().size()); |
| | | video.setVpicture(pptv.getNewPoster()); |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year); |
| | | return video; |
| | | } |
| | | |
| | | public static VideoInfo convertCartoonToVideoInfo(PPTVCartoonVideo pptv) { |
| | | Comparator<PPTVCartoonDetail> cm = new Comparator<PPTVCartoonDetail>() { |
| | | public int compare(PPTVCartoonDetail o1, PPTVCartoonDetail o2) { |
| | | return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq())); |
| | | } |
| | | }; |
| | | public static String getPlayUrl(PPTVSeries series, String programCode) { |
| | | boolean isMovie = (series.getProgramType() != null && series.getProgramType().contains("电影")) || (series.getProgramType2() != null && series.getProgramType2().contains("电影")); |
| | | //programtype 电影-3 其他-2 |
| | | return String.format("https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=%s&vid=%s&programtype=%s", isMovie ? programCode : series.getSeriesCode(), programCode, isMovie ? 3 : 2); |
| | | } |
| | | |
| | | Collections.sort(pptv.getDetailList(), cm); |
| | | |
| | | String score = getScore(pptv.getDetailList().get(0).getVid()); |
| | | String showTime = pptv.getShowTime(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy")); |
| | | String year = calendar.get(Calendar.YEAR) + ""; |
| | | String month = calendar.get(Calendar.MONTH) + ""; |
| | | String day = calendar.get(Calendar.DAY_OF_MONTH) + ""; |
| | | public static class PPTVCodeInfo { |
| | | public String pptvUid; |
| | | public long time; |
| | | } |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | String area = ""; |
| | | for (String st : pptv.getRegion().split("\\$\\$")) |
| | | area += st + " "; |
| | | video.setArea(area); |
| | | video.setBaseurl(""); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setContentType(1); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day); |
| | | String director = ""; |
| | | public static Set<String> getAvaiableStates() { |
| | | Set<String> stateSets = new HashSet<>(); |
| | | stateSets.add("add"); |
| | | stateSets.add("update"); |
| | | return stateSets; |
| | | } |
| | | |
| | | video.setDirector(director); |
| | | video.setHpicture(pptv.getHorizontalPoster()); |
| | | video.setIntroduction(pptv.getIntroduction()); |
| | | video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails()); |
| | | video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster()); |
| | | video.setLatestWatchCount(0); |
| | | String mainActor = ""; |
| | | public static boolean isVIPVideo(String free) { |
| | | return "1".equalsIgnoreCase((free + "").trim()); |
| | | } |
| | | |
| | | video.setMainActor(mainActor); |
| | | video.setMonth(month); |
| | | video.setName(pptv.getWorkName()); |
| | | video.setNowNumber(0 + ""); |
| | | video.setOrderby(0 + ""); |
| | | video.setPicture(pptv.getNewPoster()); |
| | | video.setPlayPicture(pptv.getHorizontalPoster()); |
| | | video.setScore(score); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | if (Integer.parseInt(pptv.getNewUpdate()) == pptv.getTotalNumber()) |
| | | video.setTag(pptv.getNewUpdate() + "集全"); |
| | | else |
| | | video.setTag("更新至" + pptv.getNewUpdate() + "集"); |
| | | video.setThirdType("0"); |
| | | video.setTotalNumber(pptv.getTotalNumber() + ""); |
| | | video.setUpdatetime(calendar.getTimeInMillis() + ""); |
| | | video.setVideocount(pptv.getDetailList().size()); |
| | | video.setVpicture(pptv.getNewPoster()); |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year); |
| | | return video; |
| | | } |
| | | |
| | | public static VideoInfo convertShortToVideoInfo(PPTVShortVideo pptv) { |
| | | String showTime = pptv.getPublish(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd HH:mm:ss")); |
| | | String year = calendar.get(Calendar.YEAR) + ""; |
| | | String month = calendar.get(Calendar.MONTH) + ""; |
| | | String day = calendar.get(Calendar.DAY_OF_MONTH) + ""; |
| | | /** |
| | | * 获取商品购买成功的缓存Key |
| | | * |
| | | * @param uid |
| | | * @param goodsNo |
| | | * @return |
| | | */ |
| | | public static String getBuyGoodsCacheKey(String uid, String goodsNo) { |
| | | return String.format("pptvbuygoods-%s-%s", uid, goodsNo); |
| | | } |
| | | |
| | | String[] sts = pptv.getDuration().split(":"); |
| | | int t = 0; |
| | | if (sts.length == 3) |
| | | t = Integer.parseInt(sts[0]) * 3600 + Integer.parseInt(sts[1]) * 60 + Integer.parseInt(sts[2]); |
| | | else if (sts.length == 2) |
| | | t = Integer.parseInt(sts[0]) * 60 + Integer.parseInt(sts[1]); |
| | | else if (sts.length == 1) |
| | | t = Integer.parseInt(sts[0]); |
| | | |
| | | String tag = NumberUtil.convertSecondToString(t); |
| | | VideoInfo video = new VideoInfo(); |
| | | String area = ""; |
| | | /** |
| | | * 获取虚拟的视频ID |
| | | * |
| | | * @param cid |
| | | * @return |
| | | */ |
| | | public static String getVisualVideoId(String cid, String vid) { |
| | | return "pptv-" + cid + "-" + vid; |
| | | } |
| | | |
| | | video.setArea(area); |
| | | video.setBaseurl(""); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setContentType(1); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day); |
| | | String director = ""; |
| | | video.setDirector(t + ""); |
| | | video.setHpicture(pptv.getHorizontalPoster()); |
| | | video.setIntroduction(pptv.getIntroduction()); |
| | | video.setLatestHpicture(""); |
| | | video.setLatestVpicture(""); |
| | | video.setLatestWatchCount(0); |
| | | String mainActor = ""; |
| | | /** |
| | | * 解析infoId |
| | | * |
| | | * @param videoId |
| | | * @return |
| | | */ |
| | | public static String[] parseCidAndVidFromVisualVideoId(String videoId) { |
| | | if (videoId == null) |
| | | return null; |
| | | if (!videoId.contains("pptv-")) |
| | | return null; |
| | | return videoId.replace("pptv-", "").trim().split("-"); |
| | | } |
| | | |
| | | video.setMainActor(mainActor); |
| | | video.setMonth(month); |
| | | video.setName(pptv.getSingleTitle()); |
| | | video.setNowNumber(0 + ""); |
| | | video.setOrderby(0 + ""); |
| | | video.setPicture(pptv.getHorizontalPoster()); |
| | | video.setPlayPicture(pptv.getHorizontalPoster()); |
| | | video.setScore("9.0"); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | video.setTag(tag); |
| | | video.setThirdType("0"); |
| | | video.setTotalNumber("1"); |
| | | video.setUpdatetime(calendar.getTimeInMillis() + ""); |
| | | video.setVideocount(1); |
| | | video.setVpicture(""); |
| | | video.setWatchCount(0 + ""); |
| | | video.setYear(year); |
| | | return video; |
| | | } |
| | | public static class VideoConvertResult { |
| | | public VideoInfo videoInfo; |
| | | public String programCode; |
| | | |
| | | public static List<Integer> getVideoTypeList(String ft, String typeStr) { |
| | | List<Integer> typeList = new ArrayList<Integer>(); |
| | | String[] types = (typeStr + "").split("\\$\\$"); |
| | | Set<Integer> set = new TreeSet<Integer>(); |
| | | for (String tp : types) { |
| | | List<Integer> typeL = PPTVUtil.getTypeList(ft, tp); |
| | | for (Integer i : typeL) |
| | | set.add(i); |
| | | } |
| | | Iterator<Integer> its = set.iterator(); |
| | | while (its.hasNext()) { |
| | | typeList.add(its.next()); |
| | | } |
| | | if (typeList.size() == 0) |
| | | typeList.add(299); |
| | | public VideoConvertResult(VideoInfo videoInfo, String programCode) { |
| | | this.videoInfo = videoInfo; |
| | | this.programCode = programCode; |
| | | } |
| | | } |
| | | |
| | | return typeList; |
| | | } |
| | | |
| | | } |