package com.yeshi.buwan.videos.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 com.yeshi.buwan.videos.funtv.vo.base.FunTVBaseAlbum;
|
import com.yeshi.buwan.videos.funtv.vo.base.FunTVBaseVideo;
|
import org.hibernate.HibernateException;
|
import org.hibernate.Session;
|
import org.springframework.orm.hibernate4.HibernateCallback;
|
import org.springframework.stereotype.Component;
|
|
import com.yeshi.buwan.dao.CategoryVideoDao;
|
import com.yeshi.buwan.domain.CategoryVideo;
|
import com.yeshi.buwan.domain.VideoDetailInfo;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVCartoonAlbum;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVCartoonVideo;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVMovieVideo;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVShortVideo;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVShowAlbum;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVShowVideo;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVTVAlbum;
|
import com.yeshi.buwan.videos.funtv.vo.FunTVTVVideo;
|
import com.yeshi.buwan.videos.funtv.entity.FunTVVideo;
|
import com.yeshi.buwan.service.imp.juhe.FunTVService;
|
import com.yeshi.buwan.util.JuheVideoUtil;
|
import com.yeshi.buwan.util.NumberUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
import com.yeshi.buwan.util.TimeUtil;
|
|
@Component
|
public class FunTVUtil {
|
|
@Resource
|
private FunTVService funTVService;
|
|
@Resource
|
private CategoryVideoDao categoryVideoDao;
|
|
|
|
public final static int RESOURCE_ID = 19;
|
public final static String RESOURCE_NAME = "风行";
|
|
public static VideoDetailInfo convertFunTVVideoToVideoDetail(FunTVVideo pv, FunTVAlbum p) {
|
VideoDetailInfo vinfo = new VideoDetailInfo();
|
vinfo.setExtraId(pv.getVid() + "");
|
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");
|
vinfo.setId(Long.parseLong(pv.getVid()));
|
return vinfo;
|
}
|
|
/**
|
* @param p
|
* @return
|
*/
|
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.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);
|
if (p.getCate() != null && (p.getCate().contains("电影") || p.getCate().contains("电视剧") || p.getCate().contains("综艺") || p.getCate().contains("动漫")))
|
vi.setContentType(1);//正片
|
else
|
vi.setContentType(2);
|
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);// 存入数据库
|
//todo 拉取数据的时候不处理
|
// 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());
|
//todo 拉取数据的时候不处理
|
// 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;
|
}
|
|
|
/**
|
* 处理专辑
|
*
|
* @param m
|
*/
|
private void processAlbum(FunTVBaseAlbum m) {
|
if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByAid(m.getAid());
|
} else if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVAlbum album = null;
|
if (m instanceof FunTVTVAlbum) {
|
album = FunTVAlbumFactory.create((FunTVTVAlbum) m);
|
} else if (m instanceof FunTVCartoonAlbum) {
|
album = FunTVAlbumFactory.create((FunTVCartoonAlbum) m);
|
} else if (m instanceof FunTVShowAlbum) {
|
album = FunTVAlbumFactory.create((FunTVShowAlbum) m);
|
}
|
saveFunTVAlbum(album);
|
}
|
}
|
|
|
/**
|
* 处理视频
|
*
|
* @param m
|
*/
|
private void processVideo(FunTVBaseVideo m) {
|
if (m.getOp().equalsIgnoreCase("add")) {
|
FunTVVideo video = null;
|
if (m instanceof FunTVMovieVideo) {
|
video = FunTVVideoFactory.create((FunTVMovieVideo) m);
|
} else if (m instanceof FunTVTVVideo) {
|
video = FunTVVideoFactory.create((FunTVTVVideo) m);
|
} else if (m instanceof FunTVCartoonVideo) {
|
video = FunTVVideoFactory.create((FunTVCartoonVideo) m);
|
} else if (m instanceof FunTVShowVideo) {
|
video = FunTVVideoFactory.create((FunTVShowVideo) m);
|
} else if (m instanceof FunTVShortVideo) {
|
video = FunTVVideoFactory.create((FunTVShortVideo) m);
|
}
|
addFunTVVideo(video);
|
} else if (m.getOp().equalsIgnoreCase("del")) {
|
funTVService.deleteVideoByVid(m.getVid());
|
}
|
}
|
|
|
/**
|
* 更新
|
*/
|
public void startUpdate() {
|
List<String> list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_TV);
|
for (String url : list) {
|
List<FunTVTVAlbum> videoList = FunTVApi.parseTV(url);
|
for (FunTVTVAlbum m : videoList) {
|
processAlbum(m);
|
}
|
}
|
// //
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_CARTON);
|
for (String url : list) {
|
List<FunTVCartoonAlbum> videoList = FunTVApi.parseCartoon(url);
|
for (FunTVCartoonAlbum m : videoList) {
|
processAlbum(m);
|
}
|
}
|
//
|
// 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) {
|
processVideo(m);
|
}
|
}
|
//
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_UPDATE_SHORTVIDEO);
|
for (String url : list) {
|
List<FunTVShortVideo> videoList = FunTVApi.parseShortVideo(url);
|
for (FunTVShortVideo m : videoList) {
|
processVideo(m);
|
}
|
}
|
|
}
|
|
|
public void syncAllVideos() {
|
List<String> list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_MOVIE);
|
for (String url : list) {
|
List<FunTVMovieVideo> videoList = FunTVApi.parseMovie(url);
|
for (FunTVMovieVideo m : videoList) {
|
processVideo(m);
|
}
|
}
|
}
|
|
/**
|
* 拉取全部
|
*/
|
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) {
|
processVideo(m);
|
}
|
}
|
// //
|
list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_CARTON);
|
for (String url : list) {
|
List<FunTVCartoonAlbum> videoList = FunTVApi.parseCartoon(url);
|
for (FunTVCartoonAlbum m : videoList) {
|
processAlbum(m);
|
}
|
}
|
//
|
// 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) {
|
processAlbum(m);
|
}
|
}
|
}
|
|
public void startParseShortVideo(){
|
List<String> list
|
= FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_SHORTVIDEO);
|
for (String url : list) {
|
List<FunTVShortVideo> videoList = FunTVApi.parseShortVideo(url);
|
for (FunTVShortVideo m : videoList) {
|
processVideo(m);
|
}
|
}
|
}
|
}
|