From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 20 二月 2025 16:57:55 +0800
Subject: [PATCH] IOS广告增加区域屏蔽

---
 src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java |  299 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 229 insertions(+), 70 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java b/src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java
index 0661593..e04d4f7 100644
--- a/src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java
+++ b/src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java
@@ -1,19 +1,37 @@
 package com.yeshi.buwan.util.video;
 
 import com.yeshi.buwan.dao.VideoInfoDao;
-import com.yeshi.buwan.domain.ResourceVideo;
-import com.yeshi.buwan.domain.VideoDetailInfo;
-import com.yeshi.buwan.domain.VideoInfo;
-import com.yeshi.buwan.domain.VideoResource;
+import com.yeshi.buwan.domain.*;
 import com.yeshi.buwan.domain.entity.PlayUrl;
-import com.yeshi.buwan.iqiyi.util.IqiyiUtil;
-import com.yeshi.buwan.iqiyi.util.IqiyiUtil2;
+import com.yeshi.buwan.domain.system.DetailSystem;
+import com.yeshi.buwan.exception.video.VideoPlayException;
 import com.yeshi.buwan.service.imp.VideoInfoService;
-import com.yeshi.buwan.service.imp.juhe.*;
-import com.yeshi.buwan.sohu.SoHuUtil;
+import com.yeshi.buwan.service.imp.VideoResourceService;
+import com.yeshi.buwan.service.imp.juhe.FunTVService;
+import com.yeshi.buwan.service.imp.juhe.IqiyiService;
+import com.yeshi.buwan.service.imp.juhe.SoHuService;
+import com.yeshi.buwan.service.inter.juhe.*;
+import com.yeshi.buwan.service.manager.APPManager;
+import com.yeshi.buwan.service.manager.search.SolrShortVideoDataManager;
+import com.yeshi.buwan.util.JuHe.VideoResourceUtil;
 import com.yeshi.buwan.util.StringUtil;
+import com.yeshi.buwan.util.log.VideoLogFactory;
+import com.yeshi.buwan.videos.acFun.AcFunUtil;
+import com.yeshi.buwan.videos.bilibili.BilibiliUtil;
+import com.yeshi.buwan.videos.funtv.FunTVUtil;
+import com.yeshi.buwan.videos.funtv.FunTVUtil2;
+import com.yeshi.buwan.videos.hanmi.HanmiUtil;
+import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil;
+import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil2;
+import com.yeshi.buwan.videos.mogotv.MogoTVUtil;
+import com.yeshi.buwan.videos.sohu.SoHuUtil;
+import com.yeshi.buwan.videos.tencent.TencentVideoUtil;
+import com.yeshi.buwan.videos.youku.YouKuUtil;
+import com.yeshi.buwan.vo.AcceptData;
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.orm.hibernate4.HibernateCallback;
 import org.springframework.stereotype.Component;
@@ -23,11 +41,11 @@
 
 @Component
 public class VideoDetailUtil {
-    @Resource
-    private IqiyiUtil iqiyiUtil;
+
+    private final Logger playLogger = LoggerFactory.getLogger("videoPlay");
 
     @Resource
-    private IqiyiUtil2 iqiyiUtil2;
+    private IqiyiUtil iqiyiUtil;
 
     @Resource
     private SoHuUtil soHuUtil;
@@ -48,16 +66,46 @@
     private FunTVService funTVService;
 
     @Resource
-    private PPTVService pptvService;
+    private FunTV2Service funTV2Service;
 
     @Resource
     private VideoInfoService videoInfoService;
 
+    @Resource
+    private YouKuUtil youKuUtil;
+
+    @Resource
+    private YouKuService youKuService;
+
+    @Resource
+    private MogoTVUtil mogoTVUtil;
+
+    @Resource
+    private MogoTVService mogoTVService;
+
+    @Resource
+    private TencentVideoService tencentVideoService;
+
+    @Resource
+    private TencentVideoUtil tencentVideoUtil;
+
+    @Resource
+    private BilibiliVideoService bilibiliVideoService;
+
+    @Resource
+    private HanmiService hanmiService;
+
+    @Resource
+    private BilibiliUtil bilibiliUtil;
+
+    @Resource
+    private APPManager appManager;
+
     @SuppressWarnings("unchecked")
 //	@Cacheable(value = "homeCache", key = "'getVideoInfo'+'-'+#videoid+'-'+#resourceId+'-'+#cacheMD5")
-    public VideoInfo getVideoInfo(final String videoid, final String resourceId, final List<Long> reList,
+    public VideoInfo getVideoInfo(String detailSystemId, final String videoid, final String resourceId, final List<Long> reList,
                                   String cacheMD5) {
-
+        playLogger.info(VideoLogFactory.createVideoDetailLog(detailSystemId, videoid, resourceId));
         return (VideoInfo) videoInfoDao.excute(new HibernateCallback<VideoInfo>() {
             public VideoInfo doInHibernate(Session session) throws HibernateException {
 
@@ -66,7 +114,7 @@
                 try {
                     if (!StringUtil.isNullOrEmpty(resourceId)) {
 
-                        // 来源限制判断
+                        // 鏉ユ簮闄愬埗鍒ゆ柇
                         boolean isCan = false;
                         for (long re : reList)
                             if (resourceId.equalsIgnoreCase(re + "")) {
@@ -84,7 +132,7 @@
                                     .createQuery("select rv.resource from ResourceVideo rv where rv.video.id=?")
                                     .setParameter(0, videoid).list();
 
-                            rv.getVideo().setVideoDetailList(getVideoDetailList(videoid, rv.getResource()));
+                            rv.getVideo().setVideoDetailList(getVideoDetailList(videoid, rv.getResource(), 1, 100));
                             for (VideoResource r : resourceList) {
                                 if (r.getId().equalsIgnoreCase(rv.getResource().getId())) {
                                     r.setChecked(true);
@@ -100,7 +148,7 @@
                                 .createQuery(
                                         "FROM ResourceVideo rv where rv.video.id=? order by rv.resource.orderby desc")
                                 .setParameter(0, videoid).list();
-                        // 来源筛查
+                        // 鏉ユ簮绛涙煡
 
                         if (list != null)
                             for (int i = 0; i < list.size(); i++) {
@@ -124,7 +172,7 @@
                                             "select rv.resource from ResourceVideo rv where rv.video.id=? order by rv.resource.id desc")
                                     .setParameter(0, videoid).list();
 
-                            rv.getVideo().setVideoDetailList(getVideoDetailList(videoid, rv.getResource()));
+                            rv.getVideo().setVideoDetailList(getVideoDetailList(videoid, rv.getResource(), 1, 100));
 
                             for (int i = 0; i < resourceList.size(); i++) {
                                 VideoResource r = resourceList.get(i);
@@ -138,7 +186,7 @@
                                         break;
                                     }
                                 }
-                                // 不在允许的resource里面
+                                // 涓嶅湪鍏佽鐨剅esource閲岄潰
                                 if (!isS) {
                                     resourceList.remove(i);
                                     i--;
@@ -172,66 +220,177 @@
         });
     }
 
-    private List<VideoDetailInfo> getVideoDetailList(String videoid, VideoResource vr) {
-        if (vr.getName().contains("爱奇艺2")) {
-            return iqiyi2Service.getVideoDetailList(videoid);
-        } else if (vr.getName().contains("爱奇艺")) {
-            return iqiyiService.getVideoDetailList(videoid);
-        } else if (vr.getName().contains("搜狐")) {
-            return soHuService.getVideoDetailList(videoid);
-        } else if (vr.getName().contains("PPTV"))
-            return pptvService.getVideoDetailList(videoid);
-        else if (vr.getName().contains("风行"))
-            return funTVService.getVideoDetailList(videoid);
-        else if (vr.getName().contains("AcFun")) {
-            return videoInfoService.getVideoDetailList(videoid, vr);
+    public List<VideoDetailInfo> getVideoDetailList(String videoid, VideoResource vr, int page, int pageSize) {
+        int resourceId = Integer.parseInt(vr.getId());
+        switch (resourceId) {
+            case IqiyiUtil2.RESOURCE_ID:
+                return iqiyi2Service.getVideoDetailList(videoid, page, pageSize);
+            case IqiyiUtil.RESOURCE_ID:
+                return iqiyiService.getVideoDetailList(videoid, page, pageSize);
+            case FunTVUtil2.RESOURCE_ID:
+                return funTV2Service.getVideoDetailList(videoid, page, pageSize);
+            case FunTVUtil.RESOURCE_ID:
+                return funTVService.getVideoDetailList(videoid, page, pageSize);
+            case AcFunUtil.RESOURCE_ID:
+                return videoInfoService.getVideoDetailList(videoid, vr, page, pageSize);
+            case SoHuUtil.RESOURCE_ID:
+                return soHuService.getVideoDetailList(videoid, page, pageSize);
+            case YouKuUtil.RESOURCE_ID:
+                return youKuService.getVideoDetailList(videoid, page, pageSize);
+            case MogoTVUtil.RESOURCE_ID:
+                return mogoTVService.getVideoDetailList(videoid, page, pageSize);
+            case TencentVideoUtil.RESOURCE_ID:
+                return tencentVideoService.getVideoDetailList(videoid, page, pageSize);
+            case BilibiliUtil.RESOURCE_ID:
+                return bilibiliVideoService.getVideoDetailList(videoid, page, pageSize);
+            case HanmiUtil.RESOURCE_ID:
+                return hanmiService.getVideoDetailList(videoid, page, pageSize);
+            default:
+                return null;
         }
-        return null;
     }
 
     public VideoDetailInfo getLatestVideoDetail(String videoid, VideoResource vr) {
-        if (vr.getName().contains("爱奇艺2")) {
-            return iqiyi2Service.getLatestVideoDetail(videoid);
-        } else if (vr.getName().contains("爱奇艺")) {
-            return iqiyiService.getLatestVideoDetail(videoid);
-        } else if (vr.getName().contains("搜狐")) {
-            return soHuService.getLatestVideoDetail(videoid);
-        } else if (vr.getName().contains("PPTV"))
-            return pptvService.getLatestVideoDetail(videoid);
-        else if (vr.getName().contains("风行"))
-            return funTVService.getLatestVideoDetail(videoid);
-        return null;
+
+        int resourceId = Integer.parseInt(vr.getId());
+        switch (resourceId) {
+            case IqiyiUtil2.RESOURCE_ID:
+                return iqiyi2Service.getLatestVideoDetail(videoid);
+            case IqiyiUtil.RESOURCE_ID:
+                return iqiyiService.getLatestVideoDetail(videoid);
+            case FunTVUtil2.RESOURCE_ID:
+                return funTV2Service.getLatestVideoDetail(videoid);
+            case FunTVUtil.RESOURCE_ID:
+                return funTVService.getLatestVideoDetail(videoid);
+            case SoHuUtil.RESOURCE_ID:
+                return soHuService.getLatestVideoDetail(videoid);
+            case YouKuUtil.RESOURCE_ID:
+                return soHuService.getLatestVideoDetail(videoid);
+            case MogoTVUtil.RESOURCE_ID:
+                return soHuService.getLatestVideoDetail(videoid);
+            case HanmiUtil.RESOURCE_ID:
+                return hanmiService.getLatestVideoDetail(videoid);
+            default:
+                return null;
+        }
     }
 
     public int getShowType(String videoid, VideoResource vr) {
-        if (vr.getName().contains("爱奇艺2")) {
-            return iqiyiUtil2.getShowType(videoid);
-        } else if (vr.getName().contains("爱奇艺")) {
-            return iqiyiUtil.getShowType(videoid);
-        } else if (vr.getName().contains("搜狐")) {
-            return soHuUtil.getShowType(videoid);
-        } else if (vr.getName().contains("PPTV")) {
-            return pptvService.getShowType(videoid);
-        } else if (vr.getName().contains("风行")) {
-            return funTVService.getShowType(videoid);
+        int resourceId = Integer.parseInt(vr.getId());
+        switch (resourceId) {
+            case IqiyiUtil2.RESOURCE_ID:
+                return iqiyi2Service.getShowType(videoid);
+            case IqiyiUtil.RESOURCE_ID:
+                return iqiyiUtil.getShowType(videoid);
+            case FunTVUtil2.RESOURCE_ID:
+                return funTV2Service.getShowType(videoid);
+            case FunTVUtil.RESOURCE_ID:
+                return funTVService.getShowType(videoid);
+            case SoHuUtil.RESOURCE_ID:
+                return soHuUtil.getShowType(videoid);
+            case YouKuUtil.RESOURCE_ID:
+                return soHuUtil.getShowType(videoid);
+            case HanmiUtil.RESOURCE_ID:
+                return hanmiService.getShowType(videoid);
+            default:
+                return 1;
         }
-        return 1;
     }
 
-    @Cacheable(value = "homeCache", key = "'getPlayUrl'+'-'+#detailSystemId+'-'+#id+'-'+#type+'-'+#resourceid")
-    public PlayUrl getPlayUrl(String detailSystemId, String id, String type, int resourceid, String videoid) {
-        if (resourceid == 13) {// 爱奇艺
-            return iqiyiUtil.getPlayUrl(detailSystemId, resourceid + "", type, id);
-        } else if (resourceid == 14) {// 搜狐
-            return soHuUtil.getPlayUrl(detailSystemId, resourceid + "", type, id);
-        } else if (resourceid == 16)// PPTV
-            return pptvService.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
-        else if (resourceid == 19)// 风行
-            return funTVService.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
-        else if (resourceid == 21)//acfun
-            return videoInfoService.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
-        else if (resourceid == 22)//爱奇艺2
-            return iqiyiUtil2.getPlayUrl(detailSystemId, resourceid, id, videoid);
-        return null;
+    @Resource
+    private SolrShortVideoDataManager solrShortVideoDataManager;
+
+    @Resource
+    private VideoResourceService videoResourceService;
+
+    @Resource
+    private VideoResourceUtil videoResourceUtil;
+
+
+    @Cacheable(value = "homeCache", key = "'getPlayUrl'+'-'+#acceptData.version+'-'+#detailSystemId+'-'+#id+'-'+#type+'-'+#resourceid")
+    public PlayUrl getPlayUrl(AcceptData acceptData, String detailSystemId, String id, String type, int resourceid, String videoid) throws VideoPlayException {
+        playLogger.info(VideoLogFactory.createPlayUrlLog(detailSystemId, id, type, resourceid, videoid));
+        //鍒ゆ柇resourceId鏄惁鍦ㄥ厑璁告挱鏀剧殑鏉ユ簮鍒楄〃涓�
+
+        List<Long> resourceIds = videoResourceUtil.getAvailablePlayResourceIds(new DetailSystem(detailSystemId), acceptData.getVersion(), acceptData.getChannel());
+
+        if (resourceIds == null || !resourceIds.contains(Long.parseLong(resourceid + ""))) {
+            throw new VideoPlayException(1, "鎸囧畾鎾斁婧愭棤娉曟挱鏀�");
+        }
+
+
+        if (VideoUtil.getVideoFromType(id) == HomeVideo.FROM_TYPE_SHORT) {
+            VideoResource vr = videoResourceService.getResource(resourceid + "");
+            return solrShortVideoDataManager.getPlayUrl(id, vr);
+        }
+
+        String oldId = id;
+        if (id.startsWith("native_")) {
+            id = id.replace("native_", "");
+        }
+
+
+        PlayUrl playUrl = null;
+
+        switch (resourceid) {
+            case IqiyiUtil2.RESOURCE_ID:
+                playUrl = iqiyi2Service.getPlayUrl(detailSystemId, resourceid, id, videoid);
+                break;
+            case IqiyiUtil.RESOURCE_ID:
+                playUrl = iqiyiUtil.getPlayUrl(detailSystemId, resourceid + "", type, id);
+                break;
+            case FunTVUtil2.RESOURCE_ID:
+                playUrl = funTV2Service.getPlayUrl(acceptData, detailSystemId, resourceid, id, videoid);
+                break;
+            case FunTVUtil.RESOURCE_ID:
+                playUrl = funTVService.getPlayUrl(detailSystemId, id, type, resourceid, videoid, acceptData.getChannel(), acceptData.getVersion());
+                break;
+            case SoHuUtil.RESOURCE_ID:
+                playUrl = soHuUtil.getPlayUrl(detailSystemId, resourceid + "", type, id);
+                break;
+            case AcFunUtil.RESOURCE_ID:
+                playUrl = videoInfoService.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
+                break;
+            case YouKuUtil.RESOURCE_ID:
+                playUrl = youKuUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
+                break;
+            case MogoTVUtil.RESOURCE_ID:
+                playUrl = mogoTVUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
+                break;
+            case TencentVideoUtil.RESOURCE_ID:
+                playUrl = tencentVideoUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
+                break;
+            case BilibiliUtil.RESOURCE_ID:
+                playUrl = bilibiliUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid);
+                break;
+            case HanmiUtil.RESOURCE_ID:
+                playUrl = hanmiService.getPlayUrl(detailSystemId, resourceid, id, videoid);
+                break;
+            default:
+                throw new VideoPlayException(2, "鏈煡鎾斁婧�");
+        }
+
+        if (playUrl != null) {
+            //闊╁墽
+            if ("48".equalsIgnoreCase(acceptData.getDetailSystem().getId())) {
+                //姝e湪涓婄嚎
+                //TODO 涓婄嚎鐨勬椂鍊欏紑鍚紝闃叉璇搷浣�
+//                if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) {
+//                    //闇�瑕佸師鐢熸挱鏀惧櫒
+//                    if (oldId != null && oldId.startsWith("native_")) {
+//                        if (playUrl.getPlayType() == 1) {
+//                            //鍘熺敓鎾斁鍣ㄦ挱鏀�
+//                            playUrl.setPlayType(2);
+//                            playUrl.setUrl("https://jx.parwix.com:4433/player/?url=" + playUrl.getUrl());
+//                        }
+//                    }
+//                }
+            }
+        }
+
+        return playUrl;
+
+
     }
+
 }

--
Gitblit v1.8.0