From 8fee151ffae0c3818694b7318583814bf92663e2 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 27 八月 2021 18:52:28 +0800
Subject: [PATCH] 聚合视频资源包调整,接入韩迷

---
 src/main/java/com/yeshi/buwan/videos/tencent/TencentVideoApiUtil.java |   48 +++++++++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/tencent/TencentVideoApiUtil.java b/src/main/java/com/yeshi/buwan/videos/tencent/TencentVideoApiUtil.java
similarity index 83%
rename from src/main/java/com/yeshi/buwan/tencent/TencentVideoApiUtil.java
rename to src/main/java/com/yeshi/buwan/videos/tencent/TencentVideoApiUtil.java
index c341426..71b6ddd 100644
--- a/src/main/java/com/yeshi/buwan/tencent/TencentVideoApiUtil.java
+++ b/src/main/java/com/yeshi/buwan/videos/tencent/TencentVideoApiUtil.java
@@ -1,8 +1,9 @@
-package com.yeshi.buwan.tencent;
+package com.yeshi.buwan.videos.tencent;
 
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
-import com.yeshi.buwan.tencent.entity.TencentCoverInfo;
+import com.yeshi.buwan.videos.tencent.entity.TencentCoverInfo;
+import com.yeshi.buwan.util.video.web.TencentWebUtil;
 import net.sf.json.JSONObject;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -12,7 +13,6 @@
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
-import java.io.IOException;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -137,37 +137,39 @@
     }
 
 
-    private static List<TencentCoverInfo> parseList(String url) {
+    public static List<TencentCoverInfo> getVideoList(String url) throws Exception {
         List<TencentCoverInfo> coverInfoList = new ArrayList<>();
-        try {
-            Document document = Jsoup.connect(url).timeout(5000).get();
-            Elements els = document.getElementsByAttributeValue("class", "list_item");
-            for (int i = 0; i < els.size(); i++) {
-                String href = els.get(i).getElementsByTag("a").get(0).attr("href");
-                String img = els.get(i).getElementsByTag("img").get(0).attr("src");
-                img = img.startsWith("http") ? img : "http:" + img;
-                try {
-                    TencentCoverInfo coverInfo = getCoverInfo(href);
-                    coverInfo.setVertical_pic_url(img);
-                    coverInfoList.add(coverInfo);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
+        List<TencentWebUtil.TencentWebVideoInfo> list = TencentWebUtil.getVideoList(url);
+        for (TencentWebUtil.TencentWebVideoInfo info : list) {
+            try {
+                TencentCoverInfo coverInfo = getCoverInfo(info.getPlayUrl());
+                coverInfo.setVertical_pic_url(info.getPicture());
+                coverInfoList.add(coverInfo);
+            } catch (Exception e) {
+                e.printStackTrace();
             }
-        } catch (IOException e) {
-            e.printStackTrace();
         }
         return coverInfoList;
     }
 
     public static List<TencentCoverInfo> getVideoListByCategory(String channel, int page) {
-        return parseList(String.format("https://v.qq.com/x/bu/pagesheet/list?_all=1&append=1&channel=%s&ipay=2&listpage=%s&offset=%s&pagesize=30&sort=18", channel, page, (page - 1) * 30));
-
-
+        String url = String.format("https://v.qq.com/x/bu/pagesheet/list?_all=1&append=1&channel=%s&ipay=2&listpage=%s&offset=%s&pagesize=30&sort=18", channel, page, (page - 1) * 30);
+        try {
+            return getVideoList(url);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
 
     public static void main(String[] args) throws Exception {
+        List<TencentCoverInfo> list1 = getVideoList(TencentWebUtil.getApiUrl("https://v.qq.com/channel/tv?_all=1&channel=tv&iarea=818&listpage=1&sort=18", 1));
+        System.out.println(list1);
+
+        if (1 > 0)
+            return;
+
 //        try {
         TencentCoverInfo info = getCoverInfo("https://v.qq.com/x/cover/7q544xyrava3vxf.html");
         System.out.println(info);

--
Gitblit v1.8.0