From 56481656c7de11cdca69c1a7dd69db176ffd9ecd Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 08 五月 2021 12:49:30 +0800
Subject: [PATCH] 华为屏蔽金币任务中的看海量视频,新增广告平台概率控制

---
 src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java |  194 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 187 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java b/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
index 4b3c645..dc23e1b 100644
--- a/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
+++ b/src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
@@ -4,13 +4,19 @@
 import com.yeshi.buwan.domain.VideoType;
 import com.yeshi.buwan.pptv.entity.PPTVProgram;
 import com.yeshi.buwan.pptv.entity.PPTVSeries;
+import com.yeshi.buwan.util.AESUtil;
 import com.yeshi.buwan.util.StringUtil;
 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;
+    public final static int RESOURCE_ID = 25;
 
     public final static int PLAY_NONE = 0;// 涓嶈兘鎾斁
     public final static int PLAY_HTML = 1;// 璺宠浆绉诲姩绔綉椤垫挱鏀�
@@ -37,7 +43,11 @@
             case "鍔ㄦ极":
                 videoType = VideoConstant.VIDEO_CATEGORY_DONGMAN;
                 break;
+            case "灏戝効":
+                videoType = 312;
+                break;
             default:
+                return null;
         }
 
         return (long) videoType;
@@ -50,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;
@@ -60,14 +89,18 @@
         String score = series.getScore();
 
         String tag = "";
-        VideoType videoType = new VideoType(getVideoType(series));
+        Long videoTypeId = getVideoType(series);
+        if (videoTypeId == null)
+            return null;
+        VideoType videoType = new VideoType(videoTypeId);
+
 
         //鐢靛奖
         if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANYING) {
             tag = "璇勫垎锛�" + score;
         } else if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoType.getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN) {
             //鐢佃鍓э紝鍔ㄦ极
-            if (series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
+            if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
                 tag = series.getSeriesCount() + "闆嗗叏";
             } else {
                 tag = "鏇存柊鑷�" + series.getCurrentNum() + "闆�";
@@ -79,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();
 
@@ -103,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());
@@ -115,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;
     }
 
@@ -128,4 +175,137 @@
         }
     }
 
+    /**
+     * 鑾峰彇pptv鐨勭敤鎴稩D
+     *
+     * @param uid
+     * @return
+     */
+    public static String getPPTVUid(String uid) {
+        return "buwan_" + uid;
+    }
+
+    /**
+     * 鑾峰彇pptvcode
+     *
+     * @param pptvUid
+     * @return
+     */
+    public static String getPPTVCode(String pptvUid) {
+        if (StringUtil.isNullOrEmpty(pptvUid))
+            return null;
+        return AESUtil.encrypt(pptvUid + "#" + System.currentTimeMillis()).replace("/", "_").replace("=", "-");
+    }
+
+    public static String getUidFromPPTVUid(String pptvUid) {
+        return pptvUid.split("_")[1];
+    }
+
+
+    /**
+     * 瑙e瘑PPTVCode
+     *
+     * @param code
+     * @return
+     */
+    public static PPTVCodeInfo decryptPPTVCode(String code) {
+        code = code.replace("_", "/").replace("-", "=");
+        String info = AESUtil.decrypt(code);
+        if (StringUtil.isNullOrEmpty(info)) {
+            return null;
+        } else {
+            String[] sts = info.split("#");
+            if (sts.length != 2)
+                return null;
+            PPTVCodeInfo codeInfo = new PPTVCodeInfo();
+            codeInfo.pptvUid = sts[0];
+            codeInfo.time = Long.parseLong(sts[1]);
+            return codeInfo;
+        }
+    }
+
+
+    /**
+     * 鑾峰彇鎾斁閾炬帴
+     *
+     * @param series
+     * @param program
+     * @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", isMovie ? programCode : series.getSeriesCode(), programCode, isMovie ? 3 : 2);
+    }
+
+
+    public static class PPTVCodeInfo {
+        public String pptvUid;
+        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