| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiAlbum2Dao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyi2Dao; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.funtv.FunTVUtil2; |
| | | import com.yeshi.buwan.funtv.entity.VideoFunTV2; |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; |
| | | import com.yeshi.buwan.iqiyi.vo.IqiyiAlbumListResult; |
| | | import com.yeshi.buwan.job.SMSJob; |
| | | import com.yeshi.buwan.job.video.Iqiyi2VideoUpdate; |
| | | import com.yeshi.buwan.query.Iqiyi2AlbumQuery; |
| | | import com.yeshi.buwan.service.imp.CategoryVideoService; |
| | | import com.yeshi.buwan.service.imp.ResourceVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import net.sf.json.JSONArray; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Scanner; |
| | | |
| | | // |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | |
| | | @Resource |
| | | private Iqiyi2Service iqiyi2Service; |
| | | |
| | | @Resource |
| | | private Iqiyi2VideoUpdate iqiyi2VideoUpdate; |
| | | |
| | | @Resource |
| | | private CategoryVideoService categoryVideoService; |
| | | |
| | | @Resource |
| | | private VideoIqiyi2Dao videoIqiyi2Dao; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | |
| | | @Test |
| | | public void syncAll() { |
| | | iqiyiUtil2.syncAllZongYi(); |
| | | iqiyiUtil2.updateTodayAlbumAndVideo(IqiYiNewAPI.TYPE_DIANYING); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | @Test |
| | | public void addToVideoInfo() { |
| | | List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByChannelId(1, null, 1,11000, 3000); |
| | | List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByChannelId(1, null, 1, 11000, 3000); |
| | | for (IqiyiAlbum2 album : list) |
| | | try { |
| | | iqiyi2Service.addToVideoInfo(album); |
| | |
| | | |
| | | @Test |
| | | public void syncOne() { |
| | | iqiyiUtil2.syncByAid(247738801L); |
| | | iqiyiUtil2.syncByAid(253393601L); |
| | | iqiyiUtil2.syncByAid(253305701L); |
| | | iqiyiUtil2.syncByAid(247742201L); |
| | | iqiyiUtil2.syncByAid(111367401L); |
| | | // iqiyiUtil2.syncByAid(253393601L); |
| | | // iqiyiUtil2.syncByAid(253305701L); |
| | | // iqiyiUtil2.syncByAid(247742201L); |
| | | } |
| | | |
| | | |
| | |
| | | @Test |
| | | public void syncByAid() { |
| | | |
| | | Long[] ids = new Long[]{ |
| | | 246508201L, 248886801L, 230798901L, 1569537751867101L, |
| | | // Long[] ids = new Long[]{ |
| | | // 246508201L, 248886801L, 230798901L, 1569537751867101L, |
| | | // }; |
| | | |
| | | |
| | | }; |
| | | |
| | | iqiyiUtil2.syncByAid(240793601L); |
| | | iqiyiUtil2.syncByAid(7643537550826500L); |
| | | |
| | | // IqiyiAlbum2 album2 = iqiyi2Service.selectAlbumById(240793601L); |
| | | // if (album2 != null) { |
| | |
| | | |
| | | @Test |
| | | public void test6() { |
| | | List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByChannelId(1, null, 1, 0, 1000); |
| | | for (IqiyiAlbum2 album : list) |
| | | System.out.println(album.getName()); |
| | | for (int i = 0; i < 10; i++) { |
| | | List<Long> ids = iqiyiAlbum2Dao.listInvalid(0, 1000); |
| | | for (long id : ids) |
| | | iqiyiAlbum2Dao.delete(id); |
| | | //saveToFile(ids); |
| | | } |
| | | } |
| | | |
| | | private void saveToFile(List<Long> list) { |
| | | FileWriter fw = null; |
| | | try { |
| | | //如果文件存在,则追加内容;如果文件不存在,则创建文件 |
| | | File f = new File("E:\\iqiyialbum_invalid.txt"); |
| | | fw = new FileWriter(f, true); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | PrintWriter pw = new PrintWriter(fw); |
| | | pw.println(new Gson().toJson(list)); |
| | | pw.flush(); |
| | | try { |
| | | fw.flush(); |
| | | pw.close(); |
| | | fw.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void count() { |
| | | // long count = iqiyiAlbum2Dao.countVideoByAid(253120001L); |
| | | // System.out.println(count); |
| | | IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(730266600L); |
| | | iqiyi2Service.addToVideoInfo(album2); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void sync() { |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | Date startTime = new Date(TimeUtil.convertGernalTime("2020-10-23", "yyyy-MM-dd")); |
| | | Date endTime = new Date(TimeUtil.convertGernalTime("2020-10-23 03", "yyyy-MM-dd HH")); |
| | | IqiyiAlbumListResult result = IqiYiNewAPI.getUpdateAlbumList(IqiYiNewAPI.TYPE_DIANYING + "", startTime, endTime, null, false, 20); |
| | | System.out.println(result); |
| | | } |
| | | |
| | | @Test |
| | | public void deleteAlbum() { |
| | | try { |
| | | Scanner scanner = new Scanner(new FileInputStream(new File("E:\\iqiyialbum_invalid.txt"))); |
| | | while (scanner.hasNextLine()) { |
| | | String text = scanner.nextLine(); |
| | | if (!StringUtil.isNullOrEmpty(text)) { |
| | | JSONArray array = JSONArray.fromObject(text); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | iqiyi2Service.deleteByAid(array.optLong(i)); |
| | | } |
| | | } |
| | | } |
| | | scanner.close(); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void addToMQ() { |
| | | Iqiyi2AlbumQuery query = new Iqiyi2AlbumQuery(); |
| | | query.setContentType(1); |
| | | query.setFeatureAlbumId(0L); |
| | | query.setChannelId(2); |
| | | |
| | | long count = iqiyiAlbum2Dao.countByAid(query); |
| | | int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1); |
| | | |
| | | for (int i = 0; i < page; i++) { |
| | | List<IqiyiAlbum2> album2List = iqiyiAlbum2Dao.listByAid(query, IqiyiAlbum2.SORT_ID, i * 100, 100); |
| | | for (IqiyiAlbum2 album2 : album2List) { |
| | | System.out.println(album2.getName()); |
| | | if (IqiyiUtil2.albumIsValid(album2)) { |
| | | CMQManager.getInstance().addIqiyiAlbumUpdateMsg(album2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void addCategory() { |
| | | List<String[]> list = HtmlToolUtil.parseSQLYogExportHtmData("C:\\Users\\Administrator\\Desktop\\爱奇艺分类缺失.htm", 2); |
| | | for (String[] sts : list) { |
| | | String videoId = sts[0]; |
| | | String videoType = sts[1]; |
| | | categoryVideoService.addCategoryVideo(videoId, Long.parseLong(videoType)); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void addResources() { |
| | | List<String> videoIds = new ArrayList<>(); |
| | | List<VideoIqiyi2> list = videoIqiyi2Dao.listAll(0, 5000); |
| | | for (VideoIqiyi2 video : list) { |
| | | long count = resourceVideoService.countByVideoIdAndResourceId(video.getVideoId() + "", IqiyiUtil2.RESOURCE_ID); |
| | | if (count == 0L) { |
| | | videoIds.add(video.getVideoId() + ""); |
| | | } |
| | | } |
| | | //["588808","466573","475946","328312","475934","359261","276279","322163","276768"] |
| | | System.out.println(new Gson().toJson(videoIds)); |
| | | } |
| | | |
| | | |