package com.yeshi.buwan.pptv;
|
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.Calendar;
|
import java.util.Collections;
|
import java.util.Comparator;
|
import java.util.Iterator;
|
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 {
|
|
public final static int RESOURCE_ID = 16;
|
public final static String RESOURCE_NAME = "PPTV";
|
|
@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 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()) {
|
|
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);
|
}
|
}
|
}
|
}
|
|
// 解析卡通
|
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);
|
}
|
}
|
}
|
}
|
|
// 解析小视频
|
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);
|
}
|
}
|
}
|
}
|
|
// 获取分类
|
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);
|
|
} 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);
|
|
} 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)) {
|
}
|
|
} 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);
|
}
|
|
} 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);
|
}
|
|
} 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)) {
|
}
|
|
} 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;
|
}
|
|
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) + "";
|
|
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;
|
}
|
|
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()));
|
}
|
};
|
|
Collections.sort(pptv.getDetailList(), cm);
|
|
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 + " ";
|
|
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;
|
}
|
|
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()));
|
}
|
};
|
|
Collections.sort(pptv.getDetailList(), cm);
|
|
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) + "";
|
|
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 = "";
|
|
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()));
|
}
|
};
|
|
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) + "";
|
|
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 = "";
|
|
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 = "";
|
|
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) + "";
|
|
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 = "";
|
|
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 = "";
|
|
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 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);
|
|
return typeList;
|
}
|
|
}
|