| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.dao.juhe.pptv.PPTVSeriesDao; |
| | | import com.yeshi.buwan.job.video.PPTVVideoUpdate; |
| | | import com.yeshi.buwan.pptv.PPTVApiUtil; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | import org.yeshi.utils.HtmlToolUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | |
| | | //@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | //@ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | //@WebAppConfiguration |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | public class PPTVTest { |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | |
| | | @Resource |
| | | private PPTVSeriesDao pptvSeriesDao; |
| | | |
| | | @Resource |
| | | private PPTVVideoUpdate pptvVideoUpdate; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | @Test |
| | | public void save() { |
| | | List<PPTVSeries> list = PPTVApiUtil.getUpdateList(); |
| | | public void saveAll() { |
| | | List<PPTVSeries> list = PPTVApiUtil.getTotalList(); |
| | | pptvService.save(list); |
| | | } |
| | | |
| | | @Test |
| | | public void addToVideoInfo() { |
| | | List<PPTVSeries> list = pptvSeriesDao.list(2000, 1000); |
| | | for (PPTVSeries s : list) { |
| | | if (s.getProgramType().contains("少儿") || s.getProgramType2().contains("少儿")) { |
| | | continue; |
| | | } |
| | | System.out.println(s.getName() + ":" + s.getInfoID()); |
| | | PPTVSeries series = pptvService.getSeriesDetail(s.getInfoID()); |
| | | pptvService.addToVideoInfo(series); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void getAll() { |
| | | PPTVApiUtil.getUpdateList(); |
| | | public void update() { |
| | | try { |
| | | pptvVideoUpdate.updateLatestVideo(""); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void login() { |
| | | PPTVApiUtil.login("zcoAY6ev7RpYSLzXKtWybniCK+sgBiCARUii_uyNdFw-"); |
| | | } |
| | | |
| | | |
| | |
| | | public void getOpenId() { |
| | | //CODE:XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg= |
| | | // PPTVApiUtil.login("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg="); |
| | | String pptvUid = PPTVUtil.decryptPPTVCode("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg=").pptvUid; |
| | | String pptvUid = "buwan_844600";//PPTVUtil.decryptPPTVCode("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg=").pptvUid; |
| | | String openId = PPTVApiUtil.getOpenId(pptvUid); |
| | | System.out.println(openId); |
| | | |
| | |
| | | |
| | | @Test |
| | | public void addVideoInfo() { |
| | | PPTVSeries series = pptvService.getSeriesDetail("9847"); |
| | | System.out.println(series); |
| | | PPTVSeries series = pptvService.getSeriesDetail("26796"); |
| | | pptvService.addToVideoInfo(series); |
| | | } |
| | | |
| | | @Test |
| | | public void offline() { |
| | | List<String[]> list = HtmlToolUtil.parseSQLYogExportHtmData("C:\\Users\\Administrator\\Desktop\\草稿\\PPTV重复的电视剧.htm", 1); |
| | | for (int i = 1000; i < list.size(); i++) { |
| | | String[] sts = list.get(i); |
| | | String name = sts[0]; |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("name").is(name)); |
| | | PPTVSeries series = pptvSeriesDao.findOne(query); |
| | | if (series != null) { |
| | | pptvService.offLineSeries(series.getInfoID()); |
| | | //添加到详情 |
| | | try { |
| | | Thread.sleep(1000 * 3L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | series = pptvService.getSeriesDetail(series.getInfoID()); |
| | | pptvService.addToVideoInfo(series); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void reAddVideo(){ |
| | | reAdd("武林外传"); |
| | | } |
| | | |
| | | private void reAdd(String name) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("name").is(name)); |
| | | PPTVSeries series = pptvSeriesDao.findOne(query); |
| | | if (series != null) { |
| | | pptvService.offLineSeries(series.getInfoID()); |
| | | //添加到详情 |
| | | try { |
| | | Thread.sleep(1000 * 3L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | series = pptvService.getSeriesDetail(series.getInfoID()); |
| | | pptvService.addToVideoInfo(series); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void logs() { |
| | | LoggerUtil.getVIPLogger().info("123123"); |
| | | } |
| | | |
| | | |