From 2778cf2a16823f9b1153a0549b47f7b503176a17 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 12 九月 2020 18:04:43 +0800 Subject: [PATCH] 爱奇艺正片,搜索引擎 --- src/test/java/com/hxh/spring/test/VideoTest.java | 198 ++++++++++++++++++++++++++----------------------- 1 files changed, 104 insertions(+), 94 deletions(-) diff --git a/src/test/java/com/hxh/spring/test/VideoTest.java b/src/test/java/com/hxh/spring/test/VideoTest.java index 2b18896..a3600fa 100644 --- a/src/test/java/com/hxh/spring/test/VideoTest.java +++ b/src/test/java/com/hxh/spring/test/VideoTest.java @@ -4,6 +4,7 @@ import com.yeshi.buwan.domain.DetailSystem; import com.yeshi.buwan.domain.VideoInfo; import com.yeshi.buwan.domain.entity.PlayUrl; +import com.yeshi.buwan.iqiyi.IqiYiNewAPI; import com.yeshi.buwan.iqiyi.entity.IqiyiUpdateQueue; import com.yeshi.buwan.iqiyi.util.IqiyiUtil; import com.yeshi.buwan.pptv.PPTVUtil; @@ -15,131 +16,140 @@ import com.yeshi.buwan.util.video.VideoDetailUtil; import org.hibernate.HibernateException; import org.hibernate.Session; +import org.junit.Test; import org.springframework.orm.hibernate4.HibernateCallback; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; public class VideoTest { - public static void main(String[] args) { - // pptv(); - VideoService videoService = BeanUtil.getBean(VideoService.class); - for (int i = 0; i < 50; i++) { - videoService.addNOAddToCategoryVideo(); - } - } + public static void main(String[] args) { + // pptv(); + VideoService videoService = BeanUtil.getBean(VideoService.class); + for (int i = 0; i < 50; i++) { + videoService.addNOAddToCategoryVideo(); + } + } - // @Test - public static void pptv() { - PPTVUtil pptvUtil = BeanUtil.getBean(PPTVUtil.class); - pptvUtil.startParseShow(); - } + // @Test + public static void pptv() { + PPTVUtil pptvUtil = BeanUtil.getBean(PPTVUtil.class); + pptvUtil.startParseShow(); + } - @SuppressWarnings("unchecked") - public static void deleteDuplicateVideo() { - final VideoManager vs = (VideoManager) BeanUtil.getBean("videoManager"); + @SuppressWarnings("unchecked") + public static void deleteDuplicateVideo() { + final VideoManager vs = (VideoManager) BeanUtil.getBean("videoManager"); - final VideoInfoDao infoDao = (VideoInfoDao) BeanUtil.getBean("videoInfoDao"); - List<String> names = (List<String>) infoDao.excute(new HibernateCallback<List<String>>() { - public List<String> doInHibernate(Session session) throws HibernateException { - List list = session - .createSQLQuery( - "SELECT v.`name`,COUNT(*) c FROM wk_video_video v GROUP BY v.`name` HAVING c>2 ORDER BY c DESC;") - .list(); - List<String> nameList = new ArrayList<String>(); - for (int i = 0; i < list.size(); i++) { - Object[] objs = (Object[]) list.get(i); - nameList.add(objs[0] + ""); - } + final VideoInfoDao infoDao = (VideoInfoDao) BeanUtil.getBean("videoInfoDao"); + List<String> names = (List<String>) infoDao.excute(new HibernateCallback<List<String>>() { + public List<String> doInHibernate(Session session) throws HibernateException { + List list = session + .createSQLQuery( + "SELECT v.`name`,COUNT(*) c FROM wk_video_video v GROUP BY v.`name` HAVING c>2 ORDER BY c DESC;") + .list(); + List<String> nameList = new ArrayList<String>(); + for (int i = 0; i < list.size(); i++) { + Object[] objs = (Object[]) list.get(i); + nameList.add(objs[0] + ""); + } - return nameList; - } - }); + return nameList; + } + }); - for (String name : names) { - List<VideoInfo> list = infoDao.list("from VideoInfo v where v.name=?", new Serializable[] { name }); - if (list.size() > 1) - for (int i = 1; i < list.size(); i++) - vs.deleteVideo(list.get(i).getId()); - } + for (String name : names) { + List<VideoInfo> list = infoDao.list("from VideoInfo v where v.name=?", new Serializable[]{name}); + if (list.size() > 1) + for (int i = 1; i < list.size(); i++) + vs.deleteVideo(list.get(i).getId()); + } - } + } - // @Test - public static void getVideoInfo() { - VideoService vs = (VideoService) BeanUtil.getBean("videoService"); - VideoInfo vi = vs.getVideoInfo("261878"); - VideoPictureUtil.getShowPicture(vi, "android", "35"); + // @Test + public static void getVideoInfo() { + VideoService vs = (VideoService) BeanUtil.getBean("videoService"); + VideoInfo vi = vs.getVideoInfo("261878"); + VideoPictureUtil.getShowPicture(vi, "android", "35"); - } + } - // @Test - public void attention() { - AttentionService attentionService = (AttentionService) BeanUtil.getBean("attentionService"); + // @Test + public void attention() { + AttentionService attentionService = (AttentionService) BeanUtil.getBean("attentionService"); - attentionService.getAttentionVideoListByLoginUid(60192, 1); + attentionService.getAttentionVideoListByLoginUid(60192, 1); - } + } - @org.junit.Test - public void test1() { + @org.junit.Test + public void test1() { - SystemService systemService = BeanUtil.getBean(SystemService.class); + SystemService systemService = BeanUtil.getBean(SystemService.class); - VideoDetailUtil videoDeailUtil = BeanUtil.getBean(VideoDetailUtil.class); + VideoDetailUtil videoDeailUtil = BeanUtil.getBean(VideoDetailUtil.class); - DetailSystem detailSystem = systemService.getDetailSystemByPackage("com.doudou.ysvideo"); + DetailSystem detailSystem = systemService.getDetailSystemByPackage("com.doudou.ysvideo"); - PlayUrl pu = videoDeailUtil.getPlayUrl(detailSystem.getId(), 3357160 + "", "acFunVideo", - Integer.parseInt(21 + ""), 3357160 + ""); - } + PlayUrl pu = videoDeailUtil.getPlayUrl(detailSystem.getId(), 3357160 + "", "acFunVideo", + Integer.parseInt(21 + ""), 3357160 + ""); + } - @org.junit.Test - public void test2() { + @org.junit.Test + public void test2() { - StatisticsService statisticsService = BeanUtil.getBean(StatisticsService.class); + StatisticsService statisticsService = BeanUtil.getBean(StatisticsService.class); - statisticsService.categoryPlayStatistic(); + statisticsService.categoryPlayStatistic(); - } + } - @org.junit.Test - public void test3() { - VideoService videoService = BeanUtil.getBean(VideoService.class); - List<VideoInfo> list = videoService.guessLike(1); - System.out.println(list); - } + @org.junit.Test + public void test3() { + VideoService videoService = BeanUtil.getBean(VideoService.class); + List<VideoInfo> list = videoService.guessLike(1); + System.out.println(list); + } - @org.junit.Test - public void test4() { - IqiyiQueueService iqiyiQueueService = BeanUtil.getBean(IqiyiQueueService.class); - IqiyiUtil iqiyiUtil = BeanUtil.getBean(IqiyiUtil.class); - List<IqiyiUpdateQueue> queueList = iqiyiQueueService.listUpdateQueue(); - for (IqiyiUpdateQueue queue : queueList) { - String aid = null; - int count = 0; - while (StringUtil.isNullOrEmpty(aid) && count < 3) { - if (StringUtil.isNullOrEmpty(queue.getAid())) { - aid = IqiyiUtil.getAlbumIdFromPlayUrl(queue.getUrl()); - count++; - try { - Thread.sleep(1000 * 2); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else - aid = queue.getAid(); - } - if (!StringUtil.isNullOrEmpty(aid)) { - queue.setAid(aid); - iqiyiQueueService.updateUpdateQueue(queue); - iqiyiUtil.updateAlbum(aid); - } - } + @org.junit.Test + public void test4() { + IqiyiQueueService iqiyiQueueService = BeanUtil.getBean(IqiyiQueueService.class); + IqiyiUtil iqiyiUtil = BeanUtil.getBean(IqiyiUtil.class); + List<IqiyiUpdateQueue> queueList = iqiyiQueueService.listUpdateQueue(); + for (IqiyiUpdateQueue queue : queueList) { + String aid = null; + int count = 0; + while (StringUtil.isNullOrEmpty(aid) && count < 3) { + if (StringUtil.isNullOrEmpty(queue.getAid())) { + aid = IqiYiNewAPI.getAidByUrl(queue.getUrl()); + count++; + try { + Thread.sleep(1000 * 2); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else + aid = queue.getAid(); + } + if (!StringUtil.isNullOrEmpty(aid)) { + queue.setAid(aid); + iqiyiQueueService.updateUpdateQueue(queue); + iqiyiUtil.updateAlbum(aid); + } + } - } + } + + @Test + public void test111() { + String regx = "^[(\\u4e00-\\u9fa5)()a-zA-Z0-9]+$"; + boolean isMatch = Pattern.matches(regx, "浠婂ぉ hello"); + System.out.println(isMatch); + } } -- Gitblit v1.8.0