From f13ed98e1de0ec7b85ed179212cc095f63480eed Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 25 三月 2021 18:18:20 +0800
Subject: [PATCH] 全网搜优酷兼容

---
 src/test/java/com/hxh/spring/test/PPTVTest.java |  136 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 122 insertions(+), 14 deletions(-)

diff --git a/src/test/java/com/hxh/spring/test/PPTVTest.java b/src/test/java/com/hxh/spring/test/PPTVTest.java
index 3bdc1b5..d6d1344 100644
--- a/src/test/java/com/hxh/spring/test/PPTVTest.java
+++ b/src/test/java/com/hxh/spring/test/PPTVTest.java
@@ -7,7 +7,14 @@
 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.StringUtil;
 import com.yeshi.buwan.util.log.LoggerUtil;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.write.Label;
+import jxl.write.WritableCell;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.data.mongodb.core.query.Criteria;
@@ -18,12 +25,14 @@
 import org.yeshi.utils.HtmlToolUtil;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.*;
 
 
-@RunWith(SpringJUnit4ClassRunner.class) //浣跨敤junit4杩涜娴嬭瘯
-@ContextConfiguration(locations = {"classpath:spring.xml"})
-@WebAppConfiguration
+//@RunWith(SpringJUnit4ClassRunner.class) //浣跨敤junit4杩涜娴嬭瘯
+//@ContextConfiguration(locations = {"classpath:spring.xml"})
+//@WebAppConfiguration
 public class PPTVTest {
 
     @Resource
@@ -42,7 +51,7 @@
     @Test
     public void saveAll() {
         List<PPTVSeries> list = PPTVApiUtil.getTotalList();
-        pptvService.save(list);
+//        pptvService.save(list);
     }
 
     @Test
@@ -58,11 +67,6 @@
         }
     }
 
-    @Test
-    public void getDetail() {
-        PPTVSeries pptvSeries = pptvService.getSeriesDetail("201161");
-        System.out.println(pptvSeries);
-    }
 
     @Test
     public void test() {
@@ -76,6 +80,18 @@
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+//        List<PPTVSeries> list = PPTVApiUtil.getUpdateList();
+//        System.out.println(list);
+    }
+
+    @Test
+    public void syncVideo() {
+        try {
+            pptvVideoUpdate.syncVideo("");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     @Test
@@ -86,7 +102,7 @@
 
     @Test
     public void getApiDetail() {
-        PPTVApiUtil.getDetail("32159127,10215224,15326213");
+        PPTVApiUtil.getDetail("9040633");
     }
 
 
@@ -115,8 +131,11 @@
 
     @Test
     public void addVideoInfo() {
-        PPTVSeries series = pptvService.getSeriesDetail("26796");
+//        List<PPTVSeries> seriesList = pptvSeriesDao.list("灏戝効", 0, 100);
+//        for (PPTVSeries series : seriesList) {
+        PPTVSeries series = pptvService.getSeriesDetail("381472");
         pptvService.addToVideoInfo(series);
+//        }
     }
 
     @Test
@@ -143,7 +162,7 @@
     }
 
     @Test
-    public void reAddVideo(){
+    public void reAddVideo() {
         reAdd("姝︽灄澶栦紶");
     }
 
@@ -164,10 +183,99 @@
         }
     }
 
+    private List<String[]> getPPTVVideos(File f, int sheetNum) {
+        List<String[]> videoList = new ArrayList<>();
+        try {
+            jxl.Workbook rwb = Workbook.getWorkbook(new FileInputStream(f));
+            Sheet sheet = rwb.getSheet(sheetNum);
+            for (int c = 1; c < sheet.getRows(); c++) {
+                String infoId = sheet.getCell(0, c).getContents().trim();
+                String name = sheet.getCell(1, c).getContents().trim();
+                String del = sheet.getCell(21, c).getContents().trim();
+                if (!StringUtil.isNullOrEmpty(infoId) && StringUtil.isNullOrEmpty(del)) {
+                    videoList.add(new String[]{infoId, name, del});
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return videoList;
+    }
+
+
+    @Test
+    public void checkPPTVVideos() {
+        List<String[]> list1 = getPPTVVideos(new File("C:\\Users\\Administrator\\Desktop\\鍏ㄩ噺.xls"), 0);
+        List<String[]> list2 = getPPTVVideos(new File("C:\\Users\\Administrator\\Desktop\\鍏ㄩ噺.xls"), 1);
+        Map<String, String[]> map = new TreeMap<>();
+        Set<String> sets = new HashSet<>();
+        for (String[] sts : list1) {
+            map.put(sts[0], sts);
+            sets.add(sts[1]);
+        }
+
+        for (String[] sts : list2) {
+            map.put(sts[0], sts);
+            sets.add(sts[1]);
+        }
+
+//        List<PPTVSeries> list = pptvSeriesDao.list(0, 10000);
+//        Set<String> infoIds = new HashSet<>();
+//        for (PPTVSeries s : list) {
+//            infoIds.add(s.getInfoID());
+//        }
+//
+//        for (String infoId : infoIds) {
+//            map.remove(infoId);
+//        }
+
+        for (String code : sets)
+            getDetail(code);
+
+//        try {
+//            save(map);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+
+//        System.out.println(map);
+    }
+
+    private void save(Map<String, String[]> data) throws Exception {
+        WritableWorkbook wwb = Workbook.createWorkbook(new File("C:\\Users\\Administrator\\Desktop\\甯冧父杈撳嚭鐗囧崟_缂哄け.xls"));
+        WritableSheet sheet = wwb.createSheet("缂哄け", 0);
+        sheet.addCell((WritableCell) new Label(0, 0, "鐧剧ID"));
+        sheet.addCell((WritableCell) new Label(1, 0, "鍚嶇О"));
+        int row = 1;
+        for (Iterator<String> its = data.keySet().iterator(); its.hasNext(); ) {
+            String key = its.next();
+            sheet.addCell((WritableCell) new Label(0, row, key));
+            sheet.addCell((WritableCell) new Label(1, row, data.get(key)[1]));
+            row++;
+        }
+        wwb.write();
+        wwb.close();
+    }
+
 
     @Test
     public void logs() {
-        LoggerUtil.getVIPLogger().info("123123");
+//        LoggerUtil.getVIPLogger().info("123123");
+
+        Map<String, String[]> data = new TreeMap<>();
+        data.put("4234234", new String[]{"4234234", "娴嬭瘯"});
+        try {
+            save(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //    @Test
+    public void getDetail(String sCode) {
+        PPTVSeries series = PPTVApiUtil.getDetail(sCode);
+        pptvService.save(series);
     }
 
 

--
Gitblit v1.8.0