From ab35ac8b769b2d9816dffb33a64f2c6f7bd5dd6e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 05 九月 2024 17:05:55 +0800
Subject: [PATCH] 风行网页版爬虫

---
 src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java |   64 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
index 846e715..adb2601 100644
--- a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
+++ b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -15,6 +15,7 @@
 import com.yeshi.buwan.exception.video.VideoPlayException;
 import com.yeshi.buwan.service.inter.video.VideoResourceInfoMapService;
 import com.yeshi.buwan.service.manager.APPManager;
+import com.yeshi.buwan.videos.hanmi.HanmiUtil;
 import com.yeshi.buwan.videos.mogotv.MogoTVUtil;
 import com.yeshi.buwan.videos.pptv.PPTVApiUtil;
 import com.yeshi.buwan.videos.pptv.PPTVUtil;
@@ -124,6 +125,9 @@
 
     @Resource
     private VideoResourceInfoMapService videoResourceInfoMapService;
+
+    @Resource
+    private HanmiUtil hanmiUtil;
 
     private final Logger userPlayLogger = LoggerFactory.getLogger("videoPlayUser");
 
@@ -375,7 +379,7 @@
 
 
     public HomeType convertHomeVideoList(HomeType type) {
-        List<VideoInfo> vlist = new ArrayList<VideoInfo>();
+        List<VideoInfo> vlist = new ArrayList<>();
         List<HomeVideo> list = type.getHomeVideoList();
         if (list != null)
             for (HomeVideo hv : list) {
@@ -634,6 +638,7 @@
             try {
                 info = tencentVideoUtil.getVideoInfo(internetSearchVideo, pageSize);
             } catch (Exception e) {
+                e.printStackTrace();
                 logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId);
                 out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                 return;
@@ -641,6 +646,14 @@
         } else if (Integer.parseInt(resourceId) == BilibiliUtil.RESOURCE_ID) {
             try {
                 info = bilibiliUtil.getVideoInfo(internetSearchVideo, pageSize);
+            } catch (Exception e) {
+                logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId);
+                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
+                return;
+            }
+        }else if (Integer.parseInt(resourceId) == HanmiUtil.RESOURCE_ID) {
+            try {
+                info = hanmiUtil.getVideoInfo(internetSearchVideo, pageSize);
             } catch (Exception e) {
                 logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId);
                 out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
@@ -1251,6 +1264,55 @@
     }
 
 
+    // 鑾峰彇闊╁墽鐨勬挱鏀鹃摼鎺�
+    public void getHjPlayUrl(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
+        String resourceId = request.getParameter("ResourceId");
+        String id = request.getParameter("Id");
+        String eid = request.getParameter("EId");
+        String type = request.getParameter("Type");
+        String videoId = request.getParameter("VideoId");
+
+        if (StringUtil.isNullOrEmpty(resourceId)) {
+            out.print(JsonUtil.loadFalseJson("璇蜂笂浼燫esourceId"));
+            return;
+        }
+
+        if (StringUtil.isNullOrEmpty(id) && StringUtil.isNullOrEmpty(eid)) {
+            out.print(JsonUtil.loadFalseJson("璇蜂笂浼爄d"));
+            return;
+        }
+
+//        if (StringUtil.isNullOrEmpty(type)) {
+//            out.print(JsonUtil.loadFalseJson("璇蜂笂浼爐ype"));
+//            return;
+//        }
+
+        if (StringUtil.isNullOrEmpty(id))
+            id = eid;
+
+        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
+
+        PlayUrl pu = null;
+        try {
+            pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId);
+        } catch (VideoPlayException e) {
+            e.printStackTrace();
+        }
+
+        if (pu != null) {
+            if (!StringUtil.isNullOrEmpty(pu.getUrl()))
+                pu.setUrl(pu.getUrl());
+            JSONObject object = JSONObject.fromObject(StringUtil.outPutResultJson(pu));
+            out.print(JsonUtil.loadTrueJson(object.toString()));
+        } else {
+            out.print(JsonUtil.loadFalseJson("鎵句笉鍒拌瑙嗛"));
+        }
+
+    }
+
+
+
+
     public List<HomeVideo> getZhiBoVideoList() throws Exception {
         List<HomeVideo> list = new ArrayList<HomeVideo>();
         String result = get("http://www.kktv1.com/CDN/output/M/3/I/10002002/P/start-0_offset-6_platform-2/json.js");

--
Gitblit v1.8.0