package com.newvideo.funtv;
|
|
import java.util.ArrayList;
|
import java.util.Calendar;
|
import java.util.Collections;
|
import java.util.Comparator;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.hibernate.HibernateException;
|
import org.hibernate.Session;
|
import org.springframework.orm.hibernate4.HibernateCallback;
|
import org.springframework.stereotype.Component;
|
|
import com.newvideo.dao.CategoryVideoDao;
|
import com.newvideo.domain.CategoryVideo;
|
import com.newvideo.domain.VideoDetailInfo;
|
import com.newvideo.domain.VideoInfo;
|
import com.newvideo.funtv.entity.FunTVAlbum;
|
import com.newvideo.funtv.entity.FunTVCartoonAlbum;
|
import com.newvideo.funtv.entity.FunTVCartoonVideo;
|
import com.newvideo.funtv.entity.FunTVMovieVideo;
|
import com.newvideo.funtv.entity.FunTVShortVideo;
|
import com.newvideo.funtv.entity.FunTVShowAlbum;
|
import com.newvideo.funtv.entity.FunTVShowVideo;
|
import com.newvideo.funtv.entity.FunTVTVAlbum;
|
import com.newvideo.funtv.entity.FunTVTVVideo;
|
import com.newvideo.funtv.entity.FunTVVideo;
|
import com.newvideo.service.imp.VideoResourceService;
|
import com.newvideo.service.imp.VideoService;
|
import com.newvideo.service.imp.juhe.FunTVService;
|
import com.newvideo.util.JuheVideoUtil;
|
import com.newvideo.util.NumberUtil;
|
import com.newvideo.util.StringUtil;
|
import com.newvideo.util.TimeUtil;
|
|
@Component
|
public class FunTVUtil {
|
|
@Resource
|
private FunTVService funTVService;
|
@Resource
|
private VideoService videoService;
|
@Resource
|
private VideoResourceService videoResourceService;
|
|
@Resource
|
private CategoryVideoDao categoryVideoDao;
|
|
// 转到数据库存储
|
public static FunTVAlbum convertToAlbum(FunTVMovieVideo album) {
|
FunTVAlbum ab = new FunTVAlbum();
|
ab.setActor(album.getAct());
|
ab.setAid(album.getAid());
|
ab.setArea(album.getArea());
|
ab.setDesc(album.getComment());
|
ab.setDir(album.getDir());
|
if (album.getImageHorizon() != null && !album.getImageHorizon().contains("noimage_c.jpg"))
|
ab.setHpicture(album.getImageHorizon());
|
else
|
ab.setHpicture("");
|
ab.setPublishTime(album.getScreen_show_time());
|
ab.setTitle(album.getTitle());
|
ab.setVideoType("电影");
|
ab.setVpicture(album.getImageLink());
|
ab.setLatest(1);
|
ab.setAll(1);
|
if (StringUtil.isNullOrEmpty(ab.getPublishTime()))
|
ab.setPublishTime(album.getScreen_show_time());
|
|
FunTVVideo video = convertToVideo(album);
|
List<FunTVVideo> list = new ArrayList<FunTVVideo>();
|
list.add(video);
|
ab.setVideoList(list);
|
|
return ab;
|
}
|
|
public static FunTVAlbum convertToAlbum(FunTVTVAlbum album) {
|
FunTVAlbum ab = new FunTVAlbum();
|
ab.setActor(album.getAct());
|
ab.setAid(album.getAid());
|
ab.setArea(album.getArea());
|
ab.setDesc(album.getComment());
|
ab.setDir(album.getDir());
|
if (album.getImageHorizon() != null && !album.getImageHorizon().contains("noimage_c.jpg"))
|
ab.setHpicture(album.getImageHorizon());
|
else
|
ab.setHpicture("");
|
ab.setPublishTime(album.getOnline_show_time());
|
ab.setTitle(album.getTitle());
|
ab.setVideoType("电视剧");
|
ab.setVpicture(album.getImageLink());
|
ab.setLatest(album.getLatest());
|
if (album.getOver() == 0)
|
ab.setAll(album.getAll() + 1);
|
else
|
ab.setAll(album.getAll());
|
if (StringUtil.isNullOrEmpty(ab.getPublishTime()))
|
ab.setPublishTime(album.getTv_show_time());
|
|
List<FunTVVideo> list = new ArrayList<FunTVVideo>();
|
for (FunTVTVVideo tv : album.getVideoList()) {
|
list.add(convertToVideo(tv));
|
}
|
ab.setVideoList(list);
|
|
return ab;
|
}
|
|
public static FunTVAlbum convertToAlbum(FunTVShowAlbum album) {
|
FunTVAlbum ab = new FunTVAlbum();
|
ab.setActor("");
|
ab.setAid(album.getAid());
|
ab.setArea(album.getArea());
|
ab.setDesc(album.getDesc());
|
ab.setDir("");
|
if (album.getPost_url_horizon() != null && !album.getPost_url_horizon().contains("noimage_c.jpg"))
|
ab.setHpicture(album.getPost_url_horizon());
|
else
|
ab.setHpicture("");
|
ab.setPublishTime(TimeUtil
|
.getGernalTime(TimeUtil.convertGernalTime(album.getUpdatetime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd"));
|
ab.setTitle(album.getTitle());
|
ab.setVideoType("综艺");
|
ab.setVpicture(album.getPost_url());
|
|
List<FunTVVideo> list = new ArrayList<FunTVVideo>();
|
for (FunTVShowVideo tv : album.getVideoList()) {
|
list.add(convertToVideo(tv));
|
}
|
ab.setVideoList(list);
|
return ab;
|
}
|
|
public static FunTVAlbum convertToAlbum(FunTVCartoonAlbum album) {
|
FunTVAlbum ab = new FunTVAlbum();
|
ab.setActor(album.getActor());
|
ab.setAid(album.getAid());
|
ab.setArea(album.getArea());
|
ab.setDesc(album.getComment());
|
ab.setDir(album.getDir());
|
if (album.getImageHorizon() != null && !album.getImageHorizon().contains("noimage_c.jpg"))
|
ab.setHpicture(album.getImageHorizon());
|
else
|
ab.setHpicture("");
|
ab.setPublishTime(album.getPubDate());
|
ab.setTitle(album.getTitle());
|
ab.setVideoType("动漫");
|
ab.setVpicture(album.getImageLink());
|
ab.setLatest(album.getLatest());
|
if (album.getOver() == 1)
|
ab.setAll(album.getLatest());
|
else
|
ab.setAll(album.getLatest() + 1);
|
|
if (StringUtil.isNullOrEmpty(ab.getPublishTime()))
|
ab.setPublishTime(album.getPubDate() + "-01-01");
|
|
List<FunTVVideo> list = new ArrayList<FunTVVideo>();
|
for (FunTVCartoonVideo tv : album.getVideoList()) {
|
list.add(convertToVideo(tv));
|
}
|
ab.setVideoList(list);
|
|
return ab;
|
}
|
|
// 转为到数据库存储的信息
|
public static FunTVVideo convertToVideo(FunTVMovieVideo video) {
|
FunTVVideo fvideo = new FunTVVideo();
|
fvideo.setDesc(video.getComment());
|
fvideo.setNum(1);
|
fvideo.setOrder(1);
|
fvideo.setPlayMUrl(video.getPlayLinkM());
|
fvideo.setPlayUrl(video.getPlayLink());
|
fvideo.setPublishTime(video.getScreen_show_time());
|
if (!StringUtil.isNullOrEmpty(video.getDuration())) {
|
String[] ts = video.getDuration().split(":");
|
if (ts.length == 3)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 3600 + Integer.parseInt(ts[1]) * 60 + Integer.parseInt(ts[2]));
|
else if (ts.length == 2)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 60 + Integer.parseInt(ts[1]));
|
}
|
fvideo.setVid(video.getVid());
|
if (!video.getImageHorizon().contains("noimage_c.jpg"))
|
fvideo.setImg(video.getImageHorizon());
|
else
|
fvideo.setImg("");
|
fvideo.setType(Integer.parseInt(video.getPreview()));
|
|
fvideo.setUpdatetime(TimeUtil.getGernalTime(TimeUtil.convertGernalTime(fvideo.getPublishTime(), "yyyy-MM-dd"),
|
"yyyy-MM-dd HH:mm:ss"));
|
fvideo.setTitle(video.getTitle());
|
|
return fvideo;
|
}
|
|
public static FunTVVideo convertToVideo(FunTVTVVideo video) {
|
FunTVVideo fvideo = new FunTVVideo();
|
fvideo.setDesc(video.getIntro());
|
fvideo.setNum(Integer.parseInt(video.getNum()));
|
fvideo.setOrder(Integer.parseInt(video.getNum()));
|
fvideo.setPlayMUrl(video.getPlayLinkM());
|
fvideo.setPlayUrl(video.getLink());
|
fvideo.setPublishTime("");
|
if (!StringUtil.isNullOrEmpty(video.getDuration())) {
|
String[] ts = video.getDuration().split(":");
|
if (ts.length == 3)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 3600 + Integer.parseInt(ts[1]) * 60 + Integer.parseInt(ts[2]));
|
else if (ts.length == 2)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 60 + Integer.parseInt(ts[1]));
|
}
|
fvideo.setImg(video.getImage());
|
fvideo.setType(Integer.parseInt(video.getType()));
|
fvideo.setVid(video.getVid());
|
fvideo.setUpdatetime(video.getUpdatetime());
|
return fvideo;
|
}
|
|
public static FunTVVideo convertToVideo(FunTVShowVideo video) {
|
FunTVVideo fvideo = new FunTVVideo();
|
fvideo.setDesc(video.getTopic());
|
fvideo.setNum(Integer.parseInt(video.getIssue().replace("-", "").replace("期", "").trim()));
|
fvideo.setOrder(Integer.parseInt(video.getIssue().replace("-", "").replace("期", "").trim()));
|
fvideo.setPlayMUrl(video.getUrlM());
|
fvideo.setPlayUrl(video.getUrl());
|
fvideo.setPublishTime("");
|
fvideo.setVid(video.getVid());
|
fvideo.setImg(video.getImg());
|
fvideo.setTag(video.getIssue().replace("期", "").trim());
|
fvideo.setType(1);
|
fvideo.setUpdatetime(video.getUpdatetime());
|
return fvideo;
|
}
|
|
public static FunTVVideo convertToVideo(FunTVCartoonVideo video) {
|
FunTVVideo fvideo = new FunTVVideo();
|
fvideo.setDesc(video.getIntro());
|
fvideo.setNum(Integer.parseInt(video.getNum()));
|
fvideo.setOrder(Integer.parseInt(video.getNum()));
|
fvideo.setPlayMUrl(video.getPlayLinkM());
|
fvideo.setPlayUrl(video.getLink());
|
fvideo.setPublishTime("");
|
if (!StringUtil.isNullOrEmpty(video.getDuration())) {
|
String[] ts = video.getDuration().split(":");
|
if (ts.length == 3)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 3600 + Integer.parseInt(ts[1]) * 60 + Integer.parseInt(ts[2]));
|
else if (ts.length == 2)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 60 + Integer.parseInt(ts[1]));
|
}
|
fvideo.setImg(video.getImage());
|
fvideo.setType(Integer.parseInt(video.getType()));
|
fvideo.setVid(video.getVid());
|
fvideo.setUpdatetime(video.getUpdatetime());
|
return fvideo;
|
}
|
|
public static FunTVVideo convertToVideo(FunTVShortVideo video) {
|
FunTVVideo fvideo = new FunTVVideo();
|
fvideo.setDesc(video.getIntroduction());
|
fvideo.setNum(1);
|
fvideo.setOrder(1);
|
fvideo.setPlayMUrl(video.getLinkM());
|
fvideo.setPlayUrl(video.getLink());
|
fvideo.setPublishTime(video.getPublish());
|
if (!StringUtil.isNullOrEmpty(video.getDuration())) {
|
String[] ts = video.getDuration().split(":");
|
if (ts.length == 3)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 3600 + Integer.parseInt(ts[1]) * 60 + Integer.parseInt(ts[2]));
|
else if (ts.length == 2)
|
fvideo.setTime(Integer.parseInt(ts[0]) * 60 + Integer.parseInt(ts[1]));
|
}
|
fvideo.setImg(video.getImage());
|
fvideo.setType(1);
|
fvideo.setVid(video.getVid());
|
fvideo.setTitle(video.getTitle());
|
fvideo.setCate(video.getCategory());
|
fvideo.setSubCate(video.getSubcat());
|
|
return fvideo;
|
}
|
|
public static VideoDetailInfo convertFunTVVideoToVideoDetail(FunTVVideo pv, FunTVAlbum p) {
|
VideoDetailInfo vinfo = new VideoDetailInfo();
|
vinfo.setExtraId(pv.getId() + "");
|
vinfo.setName(pv.getTitle());
|
if ("综艺".equalsIgnoreCase(p.getVideoType()))
|
vinfo.setTag(pv.getTag());
|
else if ("电影".equalsIgnoreCase(p.getVideoType()))
|
vinfo.setTag(p.getTitle());
|
else
|
vinfo.setTag(pv.getNum() + "");
|
vinfo.setType("funtv");
|
return vinfo;
|
}
|
|
public static VideoInfo convertFunTVAlbumToVideoInfo(FunTVAlbum p) {
|
String time = p.getPublishTime();
|
Calendar ca = Calendar.getInstance();
|
ca.setTimeInMillis(TimeUtil.convertDateToTemp(time));
|
int year = ca.get(Calendar.YEAR);
|
int month = ca.get(Calendar.MONTH) + 1;
|
int day = ca.get(Calendar.DAY_OF_MONTH);
|
String director = p.getDir();
|
String mainActor = p.getActor();
|
|
String score = NumberUtil.get1PointNumber(Double.parseDouble((6 + Math.random() * 3) + ""));
|
|
String tag = "";
|
if (p.getVideoType().contains("电影")) {
|
tag = "评分:" + score;
|
} else if (p.getVideoType().contains("电视剧") || p.getVideoType().contains("动漫")) {
|
if (p.getLatest() < p.getAll()) {// 未更新完
|
tag = "更新至" + p.getLatest() + "集";
|
} else {// 更新完
|
tag = p.getAll() + "集全";
|
}
|
} else if (p.getVideoType().contains("综艺")) {
|
Comparator<FunTVVideo> cm = new Comparator<FunTVVideo>() {
|
public int compare(FunTVVideo o1, FunTVVideo o2) {
|
long t2 = Long.parseLong(o2.getTag().replace("-", ""));
|
long t1 = Long.parseLong(o1.getTag().replace("-", ""));
|
return (int) (t2 - t1);// 倒序排列
|
}
|
};
|
Collections.sort(p.getVideoList(), cm);
|
String t = "";
|
long ti = TimeUtil.convertGernalTime(p.getVideoList().get(0).getTag(), "yyyy-MM-dd");
|
if (ti > 0)
|
t = TimeUtil.getGernalTime(ti, "yyyy-MM-dd");
|
else
|
t = p.getVideoList().get(0).getTag();
|
tag = "更新至" + t;
|
}
|
|
Comparator<FunTVVideo> cm = new Comparator<FunTVVideo>() {
|
public int compare(FunTVVideo o1, FunTVVideo o2) {
|
long t2 = o2.getNum();
|
long t1 = o1.getNum();
|
return (int) (t2 - t1);// 倒序排列
|
}
|
};
|
|
Collections.sort(p.getVideoList(), cm);
|
String latestHpicture = p.getVideoList().get(0).getImg();
|
|
long updateTime = TimeUtil.convertGernalTime(p.getVideoList().get(0).getUpdatetime(), "yyyy-MM-dd HH:mm:ss");
|
|
VideoInfo vi = new VideoInfo();
|
vi.setArea(p.getArea());
|
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(p.getHpicture());
|
vi.setIntroduction(p.getDesc());
|
vi.setLatestHpicture(latestHpicture);
|
vi.setLatestVpicture("");
|
vi.setMainActor(mainActor);
|
vi.setMonth(month + "");
|
vi.setName(p.getTitle());
|
vi.setNowNumber(0 + "");
|
vi.setOrderby("0");
|
vi.setPicture(p.getVpicture());
|
vi.setScore(score);
|
vi.setShare("0");
|
vi.setShow(1 + "");
|
vi.setTag(tag);
|
vi.setVpicture(p.getVpicture());
|
vi.setWatchCount(0 + "");
|
vi.setYear(year + "");
|
vi.setUpdatetime(updateTime + "");
|
vi.setVideocount(p.getVideoList() != null ? p.getVideoList().size() : 1);
|
return vi;
|
}
|
|
public static VideoInfo convertVideoToVideoInfo(FunTVVideo p) {
|
String time = p.getPublishTime();
|
Calendar ca = Calendar.getInstance();
|
ca.setTimeInMillis(TimeUtil.convertDateToTemp2(time));
|
int year = ca.get(Calendar.YEAR);
|
int month = ca.get(Calendar.MONTH) + 1;
|
int day = ca.get(Calendar.DAY_OF_MONTH);
|
String score = "9.0";
|
String tag = "";
|
if (p.getTime() > 0) {
|
tag = NumberUtil.convertSecondToString(p.getTime());
|
}
|
long updateTime = ca.getTimeInMillis();
|
VideoInfo vi = new VideoInfo();
|
vi.setArea("");
|
vi.setBaseurl(p.getPlayUrl());
|
vi.setCanSave(false);
|
vi.setCommentCount(0);
|
vi.setContentType(1);
|
vi.setCreatetime(System.currentTimeMillis());
|
vi.setDay(day + "");
|
vi.setDirector("");
|
vi.setFocus("");
|
vi.setHpicture(p.getImg());
|
vi.setIntroduction("");
|
vi.setLatestHpicture("");
|
vi.setLatestVpicture("");
|
vi.setMainActor("");
|
vi.setMonth(month + "");
|
vi.setName(p.getTitle());
|
vi.setNowNumber(0 + "");
|
vi.setOrderby("0");
|
vi.setPicture(p.getImg());
|
vi.setScore(score);
|
vi.setShare("0");
|
vi.setShow(1 + "");
|
vi.setTag(tag);
|
vi.setVpicture("");
|
vi.setWatchCount(0 + "");
|
vi.setYear(year + "");
|
vi.setUpdatetime(updateTime + "");
|
vi.setVideocount(1);
|
return vi;
|
}
|
|
public static int getFunTVAlbumType(FunTVAlbum p) {
|
if (p.getVideoType().equalsIgnoreCase("电影")) {
|
return 151;
|
} else if (p.getVideoType().equalsIgnoreCase("电视剧")) {
|
return 150;
|
} else if (p.getVideoType().equalsIgnoreCase("综艺")) {
|
return 152;
|
} else if (p.getVideoType().equalsIgnoreCase("动漫")) {
|
return 153;
|
}
|
return 0;
|
}
|
|
private void addFunTVVideo(FunTVVideo funTVVideo) {
|
final String name = funTVVideo.getTitle();
|
if (!(Boolean) categoryVideoDao.excute(new HibernateCallback<Boolean>() {
|
public Boolean doInHibernate(Session session) throws HibernateException {
|
return JuheVideoUtil.isNeedAdd(session, name);
|
}
|
}))
|
return;
|
|
// 加入videoInfo
|
try {
|
funTVService.saveVideo(funTVVideo);// 存入数据库
|
funTVVideo.setId(funTVService.getFunTVVideoByVid(funTVVideo.getVid()).getId());
|
funTVService.addVideoToVideoInfo(funTVVideo);
|
} catch (Exception e) {
|
|
}
|
}
|
|
public void saveFunTVAlbum(FunTVAlbum pm) {
|
final String name = pm.getTitle();
|
if (!(Boolean) categoryVideoDao.excute(new HibernateCallback<Boolean>() {
|
public Boolean doInHibernate(Session session) throws HibernateException {
|
return JuheVideoUtil.isNeedAdd(session, name);
|
}
|
}))
|
return;
|
|
FunTVVideo pv = funTVService.getLatestFunTVVideo(pm.getAid() + "");
|
Comparator<FunTVVideo> cp = new Comparator<FunTVVideo>() {
|
public int compare(FunTVVideo o1, FunTVVideo o2) {
|
long t1 = o1.getNum();
|
long t2 = o2.getNum();
|
return (int) (t1 - t2);
|
}
|
};
|
|
Collections.sort(pm.getVideoList(), cp);
|
List<FunTVVideo> vlist = new ArrayList<FunTVVideo>();
|
|
boolean isUpdate = false;
|
if (pm.getVideoList().size() > 0 && pv != null)
|
isUpdate = pm.getVideoList().get(pm.getVideoList().size() - 1).getNum() > pv.getNum();
|
if (pv == null || isUpdate) {
|
if (pv == null)// 首次加入
|
funTVService.saveFunTVAlbum(pm, pm.getVideoList());// 保存数据到本地
|
else {
|
for (int i = 0; i < pm.getVideoList().size(); i++) {
|
if (pm.getVideoList().get(i).getVid().equalsIgnoreCase(pv.getVid())) {
|
if (i < pm.getVideoList().size() - 1)
|
vlist = pm.getVideoList().subList(i + 1, pm.getVideoList().size());
|
break;
|
}
|
}
|
funTVService.saveFunTVAlbum(pm, vlist);
|
}
|
}
|
pm.setId(funTVService.getAlbumByAid(pm.getAid()).getId());
|
|
if (pm.getVideoList() != null && pm.getVideoList().size() > 0)
|
funTVService.addFunTVAlbumToVideoInfo(pm, isUpdate);
|
}
|
|
@SuppressWarnings("unchecked")
|
public static synchronized boolean isSameVideo(List<Integer> typeList, FunTVAlbum p, VideoInfo v, Session session) {
|
try {
|
if (p.getTitle().equalsIgnoreCase(v.getName())) {
|
// 判断是否含有风行来源
|
Object c = session
|
.createQuery("select count(*) from ResourceVideo rv where rv.video.id=? and rv.resource.id=19")
|
.setParameter(0, v.getId()).uniqueResult();
|
if (Integer.parseInt(c + "") > 0) {
|
VideoInfo tempVideo = convertFunTVAlbumToVideoInfo(p);
|
if (v.getPicture().equalsIgnoreCase(tempVideo.getPicture())
|
&& (tempVideo.getYear() + "").equalsIgnoreCase(v.getYear()))// 封面图标相同且是同一年份则判断相同
|
return true;
|
}
|
|
if (p.getVideoType().contains("电影") || p.getVideoType().contains("电视剧")
|
|| p.getVideoType().contains("综艺") || p.getVideoType().contains("动漫")) {
|
String time = p.getPublishTime();
|
Calendar ca = Calendar.getInstance();
|
ca.setTimeInMillis(TimeUtil.convertDateToTemp(time));
|
int year = ca.get(Calendar.YEAR);
|
String wheres = "";
|
for (Integer type : typeList)
|
wheres += String.format(
|
" cv.videoType.id=%s or ( cv.videoType.parent!=null and cv.videoType.parent.id=%s) ",
|
type + "", type + "");
|
if (wheres.endsWith("or"))
|
wheres = wheres.substring(0, wheres.length() - 2);
|
List<CategoryVideo> cvList = session
|
.createQuery("from CategoryVideo cv where cv.video.id=? and (" + wheres + ")")
|
.setParameter(0, v.getId()).list();
|
boolean isSame = false;
|
if (cvList == null || cvList.size() == 0)
|
isSame = false;
|
else
|
isSame = true;
|
|
if (Math.abs(
|
year - Integer.parseInt(StringUtil.isNullOrEmpty(v.getYear()) ? "2017" : v.getYear())) < 3
|
&& isSame)
|
return true;
|
} else {
|
return true;
|
}
|
}
|
return false;
|
} catch (Exception e) {
|
return false;
|
}
|
}
|
|
public static List<Integer> getShortVideoType(FunTVVideo shortVideo, String cate, String subCate) {
|
List<Integer> list = new ArrayList<Integer>();
|
if (cate.equalsIgnoreCase("微电影")) {
|
} else if (cate.equalsIgnoreCase("纪录片")) {
|
} else if (cate.equalsIgnoreCase("热点")) {
|
if ("社会".equalsIgnoreCase(subCate)) {
|
list.add(242);
|
} else if ("民生".equalsIgnoreCase(subCate)) {
|
list.add(242);
|
} else if ("草根".equalsIgnoreCase(subCate)) {
|
list.add(242);
|
} else if ("国际".equalsIgnoreCase(subCate)) {
|
list.add(290);
|
} else if ("政治".equalsIgnoreCase(subCate)) {
|
list.add(290);
|
} else if ("财经".equalsIgnoreCase(subCate)) {
|
list.add(289);
|
}
|
|
} else if (cate.equalsIgnoreCase("娱乐")) {
|
if ("头条".equalsIgnoreCase(subCate)) {
|
list.add(219);
|
} else if ("八卦".equalsIgnoreCase(subCate)) {
|
list.add(219);
|
} else if ("明星资讯".equalsIgnoreCase(subCate)) {
|
list.add(288);
|
} else if ("电影资讯".equalsIgnoreCase(subCate)) {
|
list.add(288);
|
} else if ("电视资讯".equalsIgnoreCase(subCate)) {
|
list.add(288);
|
} else if ("音乐资讯".equalsIgnoreCase(subCate)) {
|
list.add(288);
|
} else if ("风行自制".equalsIgnoreCase(subCate)) {
|
list.add(219);
|
} else if ("MusicVideo".equalsIgnoreCase(subCate)) {
|
list.add(219);
|
}
|
} else if (cate.equalsIgnoreCase("体育")) {
|
|
if ("国际足球".equalsIgnoreCase(subCate)) {
|
list.add(292);
|
} else if ("国内足球".equalsIgnoreCase(subCate)) {
|
list.add(292);
|
} else if ("篮球".equalsIgnoreCase(subCate)) {
|
list.add(292);
|
} else if ("格斗".equalsIgnoreCase(subCate)) {
|
list.add(295);
|
} else if ("综合体育".equalsIgnoreCase(subCate)) {
|
list.add(287);
|
} else if ("风流体坛".equalsIgnoreCase(subCate)) {
|
list.add(287);
|
} else if ("体育节目类".equalsIgnoreCase(subCate)) {
|
list.add(287);
|
}
|
|
} else if (cate.equalsIgnoreCase("游戏")) {
|
if ("解说".equalsIgnoreCase(subCate)) {
|
list.add(272);
|
} else if ("电子竞技".equalsIgnoreCase(subCate)) {
|
list.add(212);
|
} else if ("游戏赛事".equalsIgnoreCase(subCate)) {
|
list.add(212);
|
} else if ("游戏攻略".equalsIgnoreCase(subCate)) {
|
list.add(272);
|
} else if ("网络游戏".equalsIgnoreCase(subCate)) {
|
list.add(212);
|
} else if ("电玩世界".equalsIgnoreCase(subCate)) {
|
list.add(213);
|
} else if ("玩家原创".equalsIgnoreCase(subCate)) {
|
list.add(298);
|
} else if ("主机游戏".equalsIgnoreCase(subCate)) {
|
list.add(213);
|
} else if ("小游戏".equalsIgnoreCase(subCate)) {
|
list.add(213);
|
}
|
|
if (shortVideo.getTitle().contains("王者荣耀")) {
|
list.clear();
|
list.add(214);
|
}
|
|
} else if (cate.equalsIgnoreCase("搞笑")) {
|
if ("疯狂恶搞".equalsIgnoreCase(subCate)) {
|
list.add(216);
|
} else if ("犀利辣评".equalsIgnoreCase(subCate)) {
|
list.add(285);
|
} else if ("萌宠日常".equalsIgnoreCase(subCate)) {
|
list.add(220);
|
} else if ("搞笑联盟".equalsIgnoreCase(subCate)) {
|
list.add(216);
|
} else if ("开心宝贝".equalsIgnoreCase(subCate)) {
|
list.add(216);
|
} else if ("美女恶搞".equalsIgnoreCase(subCate)) {
|
list.add(216);
|
} else if ("小品相声".equalsIgnoreCase(subCate)) {
|
list.add(217);
|
}
|
|
} else if (cate.equalsIgnoreCase("军事")) {
|
list.add(223);
|
} else if (cate.equalsIgnoreCase("广场舞")) {
|
if ("知名舞队".equalsIgnoreCase(subCate)) {
|
list.add(303);
|
} else if ("精彩舞曲".equalsIgnoreCase(subCate)) {
|
list.add(301);
|
} else if ("广场舞教学".equalsIgnoreCase(subCate)) {
|
list.add(303);
|
} else if ("广场舞比赛".equalsIgnoreCase(subCate)) {
|
list.add(303);
|
}
|
} else if (cate.equalsIgnoreCase("汽车")) {
|
if ("风FUN车闻".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
} else if ("风FUN伙伴".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
} else if ("风FUN专访".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
} else if ("风FUN试驾".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
} else if ("香车美女".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
} else if ("用车玩车".equalsIgnoreCase(subCate)) {
|
list.add(226);
|
}
|
} else if (cate.equalsIgnoreCase("旅游")) {
|
if ("编辑推荐".equalsIgnoreCase(subCate)) {
|
list.add(229);
|
} else if ("环球八卦".equalsIgnoreCase(subCate)) {
|
list.add(229);
|
} else if ("寰宇世界".equalsIgnoreCase(subCate)) {
|
list.add(229);
|
} else if ("户外探险".equalsIgnoreCase(subCate)) {
|
list.add(229);
|
} else if ("舌尖刺激".equalsIgnoreCase(subCate)) {
|
list.add(228);
|
}
|
} else if (cate.equalsIgnoreCase("时尚")) {
|
list.add(232);
|
} else if (cate.equalsIgnoreCase("母婴")) {
|
if ("母婴".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("妈妈学堂".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("亲子秀".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("早期教育".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
}
|
} else if (cate.equalsIgnoreCase("健康")) {
|
if ("健康".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("健康贴士".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("瘦身瑜伽".equalsIgnoreCase(subCate)) {
|
list.add(235);
|
} else if ("常识".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("健身".equalsIgnoreCase(subCate)) {
|
list.add(235);
|
} else if ("美容".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("两性".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
}
|
} else if (cate.equalsIgnoreCase("科技")) {
|
list.add(222);
|
} else if (cate.equalsIgnoreCase("生活")) {
|
if ("美食".equalsIgnoreCase(subCate)) {
|
list.add(228);
|
} else if ("星座".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("妙招".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("手工".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("家居".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("奇闻".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("运动".equalsIgnoreCase(subCate)) {
|
list.add(234);
|
} else if ("职场".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("法制".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("情感".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("财经".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("房产".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
} else if ("生活百科".equalsIgnoreCase(subCate)) {
|
list.add(230);
|
}
|
|
} else if (cate.equalsIgnoreCase("电影片花")) {
|
} else if (cate.equalsIgnoreCase("电视片花")) {
|
} else if (cate.equalsIgnoreCase("动漫片花")) {
|
} else if (cate.equalsIgnoreCase("综艺片花")) {
|
} else if (cate.equalsIgnoreCase("原创")) {
|
}
|
return list;
|
}
|
|
// 开始解析
|
public void startParse() {
|
List<String> list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_TV);
|
for (String url : list) {
|
List<FunTVTVAlbum> videoList = FunTVApi.parseTV(url);
|
for (FunTVTVAlbum m : videoList) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVAlbum album = convertToAlbum(m);
|
saveFunTVAlbum(album);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByAid(m.getAid());
|
}
|
}
|
}
|
// //
|
// list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_CARTON);
|
// for (String url : list) {
|
// List<FunTVCartoonAlbum> videoList = FunTVApi.parseCartoon(url);
|
// for (FunTVCartoonAlbum m : videoList) {
|
// if (m.getOp().equalsIgnoreCase("add")) {
|
// FunTVAlbum album = convertToAlbum(m);
|
// saveFunTVAlbum(album);
|
// } else if (m.getOp().equalsIgnoreCase("del")) {
|
// funTVService.deleteVideoByAid(m.getAid());
|
// }
|
// }
|
// }
|
//
|
// list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_SHOW);
|
// for (String url : list) {
|
// List<FunTVShowAlbum> videoList = FunTVApi.parseShow(url);
|
// for (FunTVShowAlbum m : videoList) {
|
// if (m.getOp().equalsIgnoreCase("add")) {
|
// FunTVAlbum album = convertToAlbum(m);
|
// saveFunTVAlbum(album);
|
// } else if (m.getOp().equalsIgnoreCase("delete")) {
|
// funTVService.deleteVideoByAid(m.getAid());
|
// }
|
// }
|
// }
|
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_MOVIE);
|
for (String url : list) {
|
List<FunTVMovieVideo> videoList = FunTVApi.parseMovie(url);
|
for (FunTVMovieVideo m : videoList) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVAlbum album = convertToAlbum(m);
|
// if (album.getTitle().contains("楚乔传"))
|
saveFunTVAlbum(album);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByAid(m.getAid());
|
}
|
}
|
}
|
//
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_SHORTVIDEO);
|
for (String url : list) {
|
List<FunTVShortVideo> videoList = FunTVApi.parseShortVideo(url);
|
for (FunTVShortVideo m : videoList) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVVideo album = convertToVideo(m);
|
addFunTVVideo(album);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByVid(m.getVid());
|
}
|
}
|
}
|
|
}
|
|
public void startParseAll() {
|
List<String> list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_MOVIE);
|
for (String url : list) {
|
List<FunTVMovieVideo> videoList = FunTVApi.parseMovie(url);
|
for (FunTVMovieVideo m : videoList) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVAlbum album = convertToAlbum(m);
|
saveFunTVAlbum(album);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByAid(m.getAid());
|
}
|
}
|
}
|
// //
|
// list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_CARTON);
|
// for (String url : list) {
|
// List<FunTVCartoonAlbum> videoList = FunTVApi.parseCartoon(url);
|
// for (FunTVCartoonAlbum m : videoList) {
|
// if (m.getOp().equalsIgnoreCase("add")) {
|
// FunTVAlbum album = convertToAlbum(m);
|
// saveFunTVAlbum(album);
|
// } else if (m.getOp().equalsIgnoreCase("del")) {
|
// funTVService.deleteVideoByAid(m.getAid());
|
// }
|
// }
|
// }
|
//
|
// list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_SHOW);
|
// for (String url : list) {
|
// List<FunTVShowAlbum> videoList = FunTVApi.parseShow(url);
|
// for (FunTVShowAlbum m : videoList) {
|
// if (m.getOp().equalsIgnoreCase("add")) {
|
// FunTVAlbum album = convertToAlbum(m);
|
// saveFunTVAlbum(album);
|
// } else if (m.getOp().equalsIgnoreCase("delete")) {
|
// funTVService.deleteVideoByAid(m.getAid());
|
// }
|
// }
|
// }
|
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_TV);
|
for (String url : list) {
|
List<FunTVTVAlbum> videoList = FunTVApi.parseTV(url);
|
for (FunTVTVAlbum m : videoList) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVAlbum album = convertToAlbum(m);
|
// if (album.getTitle().contains("楚乔传"))
|
saveFunTVAlbum(album);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByAid(m.getAid());
|
}
|
}
|
}
|
}
|
}
|