From 19533a17aa55fafc70d0a385928e785cb50e1ebc Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期五, 30 七月 2021 02:05:14 +0800
Subject: [PATCH] 爱奇艺视频更新

---
 src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 111 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java b/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
index c017227..dc23e1b 100644
--- a/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
+++ b/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
@@ -9,6 +9,11 @@
 import com.yeshi.buwan.util.video.VideoConstant;
 import com.yeshi.buwan.vo.AcceptData;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 public class PPTVUtil {
 
     public final static int RESOURCE_ID = 25;
@@ -38,6 +43,9 @@
             case "鍔ㄦ极":
                 videoType = VideoConstant.VIDEO_CATEGORY_DONGMAN;
                 break;
+            case "灏戝効":
+                videoType = 312;
+                break;
             default:
                 return null;
         }
@@ -52,7 +60,26 @@
      * @param series
      * @return
      */
-    public static VideoInfo convertToVideoInfo(PPTVSeries series) {
+    public static List<VideoConvertResult> convertToVideoInfo(PPTVSeries series) {
+        Long videoTypeId = getVideoType(series);
+
+        if (videoTypeId == null)
+            return null;
+
+        List<VideoConvertResult> list = new ArrayList<>();
+
+        if (videoTypeId.longValue() == VideoConstant.VIDEO_CATEGORY_DIANYING) {
+            //PPTV鐢靛奖涓�涓櫨绉慖D涓嬮潰鍙兘鏈夊涓棰戯紙鍥借鐗�/绮よ鐗堬級
+            for (PPTVProgram program : series.getSeries()) {
+                list.add(new VideoConvertResult(convertToVideoInfo(series, program), program.getProgramCode()));
+            }
+        } else {
+            list.add(new VideoConvertResult(convertToVideoInfo(series, null), null));
+        }
+        return list;
+    }
+
+    private static VideoInfo convertToVideoInfo(PPTVSeries series, PPTVProgram program) {
         int year = Integer.parseInt(series.getReleaseYear());
         int month = 1;
         int day = 1;
@@ -85,10 +112,24 @@
             } else {
                 tag = series.getPublishTime().split(" ")[0];
             }
+        } else {
+            if ("1".equalsIgnoreCase(series.getSeriesCount())) {
+                tag = "璇勫垎锛�" + score;
+            } else {
+                if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
+                    tag = series.getSeriesCount() + "闆嗗叏";
+                } else {
+                    if (series.getCurrentNum() != null)
+                        tag = "鏇存柊鑷�" + series.getCurrentNum() + "闆�";
+                    else {
+                        tag = "鏇存柊鑷�" + series.getSeriesCount() + "闆�";
+                    }
+                }
+            }
         }
 
 
-        String latestHpicture = series.getSeries().get(series.getSeries().size() - 1).getSubHorCover();
+        String latestHpicture = program != null ? program.getSubHorCover() : series.getSeries().get(series.getSeries().size() - 1).getSubHorCover();
 
         long updateTime = System.currentTimeMillis();
 
@@ -109,7 +150,7 @@
         vi.setLatestVpicture("");
         vi.setMainActor(mainActor);
         vi.setMonth(month + "");
-        vi.setName(series.getName());
+        vi.setName(program != null ? program.getProgramSetTiltle() : series.getName());
         vi.setNowNumber(0 + "");
         vi.setOrderby("0");
         vi.setPicture(series.getCover());
@@ -121,7 +162,7 @@
         vi.setWatchCount(0 + "");
         vi.setYear(year + "");
         vi.setUpdatetime(updateTime + "");
-        vi.setVideocount(series.getSeries().size());
+        vi.setVideocount(program != null ? 1 : series.getSeries().size());
         return vi;
     }
 
@@ -192,9 +233,14 @@
      * @return
      */
     public static String getPlayUrl(PPTVSeries series, PPTVProgram program) {
+        return getPlayUrl(series, program.getProgramCode());
+    }
+
+
+    public static String getPlayUrl(PPTVSeries series, String programCode) {
+        boolean isMovie = (series.getProgramType() != null && series.getProgramType().contains("鐢靛奖")) || (series.getProgramType2() != null && series.getProgramType2().contains("鐢靛奖"));
         //programtype 鐢靛奖-3  鍏朵粬-2
-        return String.format("https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=%s&vid=%s&programtype=%s", series.getSeriesCode(), program.getProgramCode(), series.getProgramType().contains("鐢靛奖") ? 3 : 2);
-//        return String.format(" http://vip.pptv.com/activity/2021/pg_bwysdqmovie?cid=%s&vid=%s&programtype=%s", series.getSeriesCode(), program.getProgramCode(), series.getProgramType().contains("鐢靛奖") ? 3 : 2);
+        return String.format("https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=%s&vid=%s&programtype=%s", isMovie ? programCode : series.getSeriesCode(), programCode, isMovie ? 3 : 2);
     }
 
 
@@ -203,4 +249,63 @@
         public long time;
     }
 
+    public static Set<String> getAvaiableStates() {
+        Set<String> stateSets = new HashSet<>();
+        stateSets.add("add");
+        stateSets.add("update");
+        return stateSets;
+    }
+
+    public static boolean isVIPVideo(String free) {
+        return "1".equalsIgnoreCase((free + "").trim());
+    }
+
+
+    /**
+     * 鑾峰彇鍟嗗搧璐拱鎴愬姛鐨勭紦瀛楰ey
+     *
+     * @param uid
+     * @param goodsNo
+     * @return
+     */
+    public static String getBuyGoodsCacheKey(String uid, String goodsNo) {
+        return String.format("pptvbuygoods-%s-%s", uid, goodsNo);
+    }
+
+
+    /**
+     * 鑾峰彇铏氭嫙鐨勮棰慖D
+     *
+     * @param cid
+     * @return
+     */
+    public static String getVisualVideoId(String cid, String vid) {
+        return "pptv-" + cid + "-" + vid;
+    }
+
+    /**
+     * 瑙f瀽infoId
+     *
+     * @param videoId
+     * @return
+     */
+    public static String[] parseCidAndVidFromVisualVideoId(String videoId) {
+        if (videoId == null)
+            return null;
+        if (!videoId.contains("pptv-"))
+            return null;
+        return videoId.replace("pptv-", "").trim().split("-");
+    }
+
+    public static class VideoConvertResult {
+        public VideoInfo videoInfo;
+        public String programCode;
+
+        public VideoConvertResult(VideoInfo videoInfo, String programCode) {
+            this.videoInfo = videoInfo;
+            this.programCode = programCode;
+        }
+    }
+
+
 }

--
Gitblit v1.8.0