From b37275dba6b782bf3bb3817c4504f6cdef1bef7c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 18 三月 2021 18:38:51 +0800 Subject: [PATCH] APP首页顶部标签兼容 --- src/main/java/com/yeshi/buwan/funtv/FunTVUtil.java | 1428 +++++++++++++++++++++++++--------------------------------- 1 files changed, 623 insertions(+), 805 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/funtv/FunTVUtil.java b/src/main/java/com/yeshi/buwan/funtv/FunTVUtil.java index ff13159..1ce8651 100644 --- a/src/main/java/com/yeshi/buwan/funtv/FunTVUtil.java +++ b/src/main/java/com/yeshi/buwan/funtv/FunTVUtil.java @@ -8,6 +8,8 @@ import javax.annotation.Resource; +import com.yeshi.buwan.funtv.vo.base.FunTVBaseAlbum; +import com.yeshi.buwan.funtv.vo.base.FunTVBaseVideo; import org.hibernate.HibernateException; import org.hibernate.Session; import org.springframework.orm.hibernate4.HibernateCallback; @@ -18,14 +20,14 @@ import com.yeshi.buwan.domain.VideoDetailInfo; import com.yeshi.buwan.domain.VideoInfo; import com.yeshi.buwan.funtv.entity.FunTVAlbum; -import com.yeshi.buwan.funtv.entity.FunTVCartoonAlbum; -import com.yeshi.buwan.funtv.entity.FunTVCartoonVideo; -import com.yeshi.buwan.funtv.entity.FunTVMovieVideo; -import com.yeshi.buwan.funtv.entity.FunTVShortVideo; -import com.yeshi.buwan.funtv.entity.FunTVShowAlbum; -import com.yeshi.buwan.funtv.entity.FunTVShowVideo; -import com.yeshi.buwan.funtv.entity.FunTVTVAlbum; -import com.yeshi.buwan.funtv.entity.FunTVTVVideo; +import com.yeshi.buwan.funtv.vo.FunTVCartoonAlbum; +import com.yeshi.buwan.funtv.vo.FunTVCartoonVideo; +import com.yeshi.buwan.funtv.vo.FunTVMovieVideo; +import com.yeshi.buwan.funtv.vo.FunTVShortVideo; +import com.yeshi.buwan.funtv.vo.FunTVShowAlbum; +import com.yeshi.buwan.funtv.vo.FunTVShowVideo; +import com.yeshi.buwan.funtv.vo.FunTVTVAlbum; +import com.yeshi.buwan.funtv.vo.FunTVTVVideo; import com.yeshi.buwan.funtv.entity.FunTVVideo; import com.yeshi.buwan.service.imp.VideoResourceService; import com.yeshi.buwan.service.imp.VideoService; @@ -38,846 +40,662 @@ @Component public class FunTVUtil { - @Resource - private FunTVService funTVService; - @Resource - private VideoService videoService; - @Resource - private VideoResourceService videoResourceService; + @Resource + private FunTVService funTVService; - @Resource - private CategoryVideoDao categoryVideoDao; + @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 final static int RESOURCE_ID = 19; + public final static String RESOURCE_NAME = "椋庤"; - 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()); + 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; + } - List<FunTVVideo> list = new ArrayList<FunTVVideo>(); - for (FunTVTVVideo tv : album.getVideoList()) { - list.add(convertToVideo(tv)); - } - ab.setVideoList(list); + /** + * @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(); - return ab; - } + String score = NumberUtil.get1PointNumber(Double.parseDouble((6 + Math.random() * 3) + "")); - 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()); + 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; + } - List<FunTVVideo> list = new ArrayList<FunTVVideo>(); - for (FunTVShowVideo tv : album.getVideoList()) { - list.add(convertToVideo(tv)); - } - ab.setVideoList(list); - return ab; - } + 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);// 鍊掑簭鎺掑垪 + } + }; - 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); + Collections.sort(p.getVideoList(), cm); + String latestHpicture = p.getVideoList().get(0).getImg(); - if (StringUtil.isNullOrEmpty(ab.getPublishTime())) - ab.setPublishTime(album.getPubDate() + "-01-01"); + long updateTime = TimeUtil.convertGernalTime(p.getVideoList().get(0).getUpdatetime(), "yyyy-MM-dd HH:mm:ss"); - List<FunTVVideo> list = new ArrayList<FunTVVideo>(); - for (FunTVCartoonVideo tv : album.getVideoList()) { - list.add(convertToVideo(tv)); - } - ab.setVideoList(list); + 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; + } - return ab; - } + 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);//姝g墖 + else + vi.setContentType(2); + return vi; + } - // 杞负鍒版暟鎹簱瀛樺偍鐨勪俊鎭� - 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())); + 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; + } - fvideo.setUpdatetime(TimeUtil.getGernalTime(TimeUtil.convertGernalTime(fvideo.getPublishTime(), "yyyy-MM-dd"), - "yyyy-MM-dd HH:mm:ss")); - fvideo.setTitle(video.getTitle()); + 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; - return fvideo; - } + // 鍔犲叆videoInfo + try { + funTVService.saveVideo(funTVVideo);// 瀛樺叆鏁版嵁搴� + //todo 鎷夊彇鏁版嵁鐨勬椂鍊欎笉澶勭悊 +// funTVVideo.setId(funTVService.getFunTVVideoByVid(funTVVideo.getVid()).getId()); +// funTVService.addVideoToVideoInfo(funTVVideo); + } catch (Exception e) { - 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 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; - 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; - } + 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); + } + }; - 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()); + Collections.sort(pm.getVideoList(), cp); + List<FunTVVideo> vlist = new ArrayList<FunTVVideo>(); - return fvideo; - } + 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); + } - 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; - } + @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; + } - 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(); + 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; - String score = NumberUtil.get1PointNumber(Double.parseDouble((6 + Math.random() * 3) + "")); + 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; + } + } - 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; - } + 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); + } - 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);// 鍊掑簭鎺掑垪 - } - }; + } 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("浣撹偛")) { - Collections.sort(p.getVideoList(), cm); - String latestHpicture = p.getVideoList().get(0).getImg(); + 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); + } - long updateTime = TimeUtil.convertGernalTime(p.getVideoList().get(0).getUpdatetime(), "yyyy-MM-dd HH:mm:ss"); + } else if (cate.equalsIgnoreCase("娓告垙")) { + if ("瑙h".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); + } - 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; - } + if (shortVideo.getTitle().contains("鐜嬭�呰崳鑰�")) { + list.clear(); + list.add(214); + } - 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; - } + } 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 ("灏忓搧鐩稿0".equalsIgnoreCase(subCate)) { + list.add(217); + } - 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; - } + } 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 ("椋嶧UN杞﹂椈".equalsIgnoreCase(subCate)) { + list.add(226); + } else if ("椋嶧UN浼欎即".equalsIgnoreCase(subCate)) { + list.add(226); + } else if ("椋嶧UN涓撹".equalsIgnoreCase(subCate)) { + list.add(226); + } else if ("椋嶧UN璇曢┚".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); + } - 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; + } else if (cate.equalsIgnoreCase("鐢靛奖鐗囪姳")) { + } else if (cate.equalsIgnoreCase("鐢佃鐗囪姳")) { + } else if (cate.equalsIgnoreCase("鍔ㄦ极鐗囪姳")) { + } else if (cate.equalsIgnoreCase("缁艰壓鐗囪姳")) { + } else if (cate.equalsIgnoreCase("鍘熷垱")) { + } + return list; + } - // 鍔犲叆videoInfo - try { - funTVService.saveVideo(funTVVideo);// 瀛樺叆鏁版嵁搴� - funTVVideo.setId(funTVService.getFunTVVideoByVid(funTVVideo.getVid()).getId()); - funTVService.addVideoToVideoInfo(funTVVideo); - } catch (Exception e) { - } - } + /** + * 澶勭悊涓撹緫 + * + * @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); + } + } - 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); - } - }; + /** + * 澶勭悊瑙嗛 + * + * @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()); + } + } - 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()); + /** + * 鏇存柊 + */ + 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()); + // } + // } + // } - if (pm.getVideoList() != null && pm.getVideoList().size() > 0) - funTVService.addFunTVAlbumToVideoInfo(pm, isUpdate); - } + 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); + } + } - @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 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 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); - } + /** + * 鎷夊彇鍏ㄩ儴 + */ + 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()); + // } + // } + // } - } 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("浣撹偛")) { + list = FunTVApi.getPageUrl(FunTVApi.FUNTV_ALL_TV); + for (String url : list) { + List<FunTVTVAlbum> videoList = FunTVApi.parseTV(url); + for (FunTVTVAlbum m : videoList) { + processAlbum(m); + } + } + } - 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 ("瑙h".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 ("灏忓搧鐩稿0".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 ("椋嶧UN杞﹂椈".equalsIgnoreCase(subCate)) { - list.add(226); - } else if ("椋嶧UN浼欎即".equalsIgnoreCase(subCate)) { - list.add(226); - } else if ("椋嶧UN涓撹".equalsIgnoreCase(subCate)) { - list.add(226); - } else if ("椋嶧UN璇曢┚".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()); - } - } - } - } + 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); + } + } + } } -- Gitblit v1.8.0