| | |
| | | import com.yeshi.buwan.domain.video.VideoWatchHistory; |
| | | import com.yeshi.buwan.dto.log.BaseLog; |
| | | import com.yeshi.buwan.dto.statistic.video.VideoDetailStatisticData; |
| | | 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.mogotv.MogoTVUtil; |
| | | import com.yeshi.buwan.videos.pptv.PPTVApiUtil; |
| | | import com.yeshi.buwan.videos.pptv.PPTVUtil; |
| | |
| | | @Resource |
| | | private DeviceAdStrategyService deviceAdStrategyService; |
| | | |
| | | @Resource |
| | | private APPManager appManager; |
| | | |
| | | @Resource |
| | | private VideoResourceInfoMapService videoResourceInfoMapService; |
| | | |
| | | private final Logger userPlayLogger = LoggerFactory.getLogger("videoPlayUser"); |
| | | |
| | | @RequireUid |
| | |
| | | List<HomeType> list = new ArrayList<>(); |
| | | for (HomeType ht : list1) |
| | | list.add(ht); |
| | | if ("309" .equals(vtid)) { |
| | | if (!"ios" .equalsIgnoreCase(acceptData.getPlatform())) { |
| | | Map<String, String> confMap = configService.getConfigAsMap(detailSystem, acceptData.getVersion()); |
| | | if ("309".equals(vtid)) { |
| | | if (!"ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | Map<String, String> confMap = configService.getConfigAsMap(acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | String mm = confMap.get("meinv_mm_count"); |
| | | int count = Integer.parseInt(mm); |
| | | if (count > 0) { |
| | |
| | | } |
| | | |
| | | if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | if (adContent != null && adPosition != null) { |
| | | HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class); |
| | | int adP = Integer.parseInt(adPosition.getValue()); |
| | |
| | | } |
| | | } |
| | | |
| | | if ("huawei" .equalsIgnoreCase(channel)) { |
| | | if ("huawei".equalsIgnoreCase(channel)) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getName().equalsIgnoreCase("美女")) { |
| | | list.remove(i); |
| | |
| | | |
| | | try { |
| | | if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion()) && dataKey.equalsIgnoreCase("recommend")) { |
| | | DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | if (adContent != null && adPosition != null) { |
| | | HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class); |
| | | int adP = Integer.parseInt(adPosition.getValue()); |
| | | if (adP < homeTypeList.size() && adP > -1) { |
| | | HomeType homeType = new HomeType(); |
| | | homeType.setAd(ad); |
| | | if ("1" .equalsIgnoreCase(page)) { |
| | | if ("1".equalsIgnoreCase(page)) { |
| | | homeTypeList.add(adP, homeType); |
| | | } |
| | | count++; |
| | |
| | | |
| | | info.setWatchCount("" + (int) (Math.random() * 1000)); |
| | | |
| | | //视频过滤 |
| | | filterVideo(acceptData, info); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | JSONObject obj = new JSONObject(); |
| | | |
| | |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | | obj.toString())); |
| | | } |
| | | } |
| | | |
| | | //视频过滤 |
| | | private void filterVideo(AcceptData acceptData, VideoInfo video) { |
| | | //过滤视频资源 |
| | | List<VideoResource> resourceList = videoResourceInfoMapService.filter(acceptData.getDetailSystem().getId(), video.getResourceList()); |
| | | video.setResourceList(resourceList); |
| | | //控制前端列表中的来源显示问题 |
| | | if ("48".equalsIgnoreCase(acceptData.getDetailSystem().getId())) { |
| | | if (video.getArea() != null && video.getArea().contains("韩国")) { |
| | | //判断当前版本是否正在上线 |
| | | if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) { |
| | | //如果在上线就删除未选中的资源,并且将当前资源变为韩迷TV |
| | | for (int i = 0; i < video.getResourceList().size(); i++) { |
| | | if (!video.getResourceList().get(i).isChecked()) { |
| | | video.getResourceList().remove(i--); |
| | | } |
| | | } |
| | | if (video.getResourceList().size() > 0) { |
| | | video.getResourceList().get(0).setName("PP视频"); |
| | | //在ID前面添加native标识 |
| | | for (VideoDetailInfo videoDetailInfo : video.getVideoDetailList()) { |
| | | videoDetailInfo.setExtraId("native_" + videoDetailInfo.getExtraId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequireUid |
| | |
| | | return; |
| | | } else if (fromType == HomeVideo.FROM_TYPE_INTERNET) { |
| | | getVideoDetailForInternetSearch(acceptData, videoId, request, out); |
| | | |
| | | //VIVO 渠道每日广告最多展示一次 |
| | | if ("vivo".equalsIgnoreCase(acceptData.getChannel())) { |
| | | deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); |
| | | } |
| | | return; |
| | | } |
| | | } |
| | |
| | | data.put("playUrl", playUrl); |
| | | data.put("name", videoName); |
| | | data.put("pptv", true); |
| | | data.put("vip", "1" .equalsIgnoreCase(series.getFree())); |
| | | data.put("vip", "1".equalsIgnoreCase(series.getFree())); |
| | | data.put("sessionId", sessionId); |
| | | out.print(JsonUtil.loadTrueJson(data.toString())); |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, series.getName(), from)); |
| | |
| | | attentionInfo.put("IsAttention", attention.isAttention()); |
| | | obj.put("Attention", attentionInfo); |
| | | } |
| | | UserInfo user = userService.getUserInfo(acceptData.getUid()); |
| | | |
| | | //视频过滤 |
| | | filterVideo(acceptData, info); |
| | | |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String sessionId = createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId); |
| | | |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid, videoId, from), attention, sessionId)), array.toString(), |
| | | obj.toString())); |
| | | //VIVO 渠道每日广告最多展示一次 |
| | | if ("vivo".equalsIgnoreCase(acceptData.getChannel())) { |
| | | deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); |
| | | } |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | | obj.toString())); |
| | | } |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | long showTime = TimeUtil.convertGernalTime(TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"); |
| | | deviceAdStrategyService.setShortVideoAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), videoId, from, showTime, null); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @RequireUid |
| | | public void getVideoDetailNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | String videoId = request.getParameter("VideoId"); |
| | | if (!NumberUtil.isNumeric(videoId)) { |
| | | String[] cidVid = PPTVUtil.parseCidAndVidFromVisualVideoId(videoId); |
| | | if (cidVid == null) { |
| | | int fromType = VideoUtil.getVideoFromType(videoId); |
| | | //短视频 |
| | | if (fromType == HomeVideo.FROM_TYPE_SHORT) { |
| | | getVideoDetailForShortVideo(acceptData, videoId, request, out); |
| | | return; |
| | | } else if (fromType == HomeVideo.FROM_TYPE_INTERNET) { |
| | | getVideoDetailForInternetSearch(acceptData, videoId, request, out); |
| | | return; |
| | | } |
| | | } |
| | | String cid = cidVid[0]; |
| | | String vid = cidVid[1]; |
| | | |
| | | PPTVSeries series = pptvService.getSeriesDetail(cid); |
| | | if (series == null) { |
| | | series = PPTVApiUtil.getDetail(cid); |
| | | } |
| | | |
| | | if (series != null) { |
| | | JSONObject data = new JSONObject(); |
| | | String playUrl = PPTVUtil.getPlayUrl(series, pptvService.selectProgramById(vid)); |
| | | data.put("videoId", videoId); |
| | | data.put("playUrl", playUrl); |
| | | data.put("name", series.getName()); |
| | | data.put("vip", PPTVUtil.isVIPVideo(series.getFree())); |
| | | JSONObject pptv = new JSONObject(); |
| | | pptv.put("pptv", data); |
| | | out.print(JsonUtil.loadTrueJson(pptv.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadFalseJson("已下线")); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | | String resourceId = request.getParameter("ResourceId"); |
| | | String thirdType = request.getParameter("Type"); |
| | | String loginUid = request.getParameter("LoginUid"); |
| | | String position = request.getParameter("Position"); |
| | | String from = request.getParameter("From"); |
| | | |
| | | if (StringUtil.isNullOrEmpty(videoId)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传VideoId")); |
| | | return; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(thirdType)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传Type")); |
| | | return; |
| | | } |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); |
| | | |
| | | //获取优先展示的渠道 |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | | Set<Long> rids = new HashSet<>(); |
| | | rids.addAll(resourceList); |
| | | VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids); |
| | | if (defaultVideoResource != null) { |
| | | resourceId = defaultVideoResource.getId(); |
| | | } |
| | | //视频没有来源 |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | | CMQManager.getInstance().addVideoResourceDeleteMsg(videoId); |
| | | out.print(JsonUtil.loadFalseJson("视频已下线")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | int p = 0; |
| | | if (!StringUtil.isNullOrEmpty(position)) { |
| | | p = Integer.parseInt(position); |
| | | } |
| | | |
| | | VideoWatchHistory history = new VideoWatchHistory(); |
| | | history.setDevice(acceptData.getDevice()); |
| | | history.setVideoId(videoId); |
| | | history.setUid(loginUid); |
| | | history.setPosition(p); |
| | | videoWatchHistoryService.add(history); |
| | | } |
| | | }); |
| | | |
| | | userPlayLogger.info(VideoLogFactory.createUserVideoDetailLog(acceptData.getDevice(), acceptData.getUtdId(), loginUid, acceptData.getDetailSystem().getId(), videoId, resourceId, from)); |
| | | |
| | | |
| | | //PPTV网页播放 |
| | | if (!StringUtil.isNullOrEmpty(resourceId) && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) { |
| | | JSONObject data = new JSONObject(); |
| | | VideoPPTVMap map = pptvService.getVideoPPTVMapByVideoId(videoId); |
| | | int p = 0; |
| | | if (!StringUtil.isNullOrEmpty(position)) { |
| | | p = Integer.parseInt(position); |
| | | } else { |
| | | //取播放记录 |
| | | VideoWatchHistory history = videoWatchHistoryService.getWatchHistory(acceptData.getDevice(), videoId); |
| | | if (history != null && history.getPosition() != null) { |
| | | p = history.getPosition(); |
| | | } |
| | | } |
| | | |
| | | String videoName = ""; |
| | | String playUrl = null; |
| | | |
| | | PPTVSeries series = pptvService.getSeriesDetail(map.getInfoId()); |
| | | |
| | | if (map.getProgramCode() != null) { |
| | | PPTVProgram program = pptvService.selectProgramById(map.getProgramCode()); |
| | | videoName = program.getProgramSetTiltle(); |
| | | playUrl = PPTVUtil.getPlayUrl(series, program); |
| | | } else { |
| | | videoName = series.getName(); |
| | | p = p >= series.getSeries().size() ? 0 : p; |
| | | playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(p)); |
| | | } |
| | | |
| | | String sessionId = createVideoDetailSessionId(acceptData, loginUid, videoName, videoId, resourceId); |
| | | data.put("videoId", videoId); |
| | | data.put("playUrl", playUrl); |
| | | data.put("name", videoName); |
| | | data.put("pptv", true); |
| | | data.put("vip", "1".equalsIgnoreCase(series.getFree())); |
| | | data.put("sessionId", sessionId); |
| | | out.print(JsonUtil.loadTrueJson(data.toString())); |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, series.getName(), from)); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //看PP视频 |
| | | deviceAdStrategyService.watchPPTVVideo(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | |
| | | VideoInfo info = videoDeailUtil.getVideoInfo(detailSystem.getId(), videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList)); |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info != null ? info.getName() : "", from)); |
| | | |
| | | List<VideoType> typeList = classService.getVideoTypeList(info.getId()); |
| | | if (typeList != null && typeList.size() > 0) { |
| | | VideoType type = typeList.get(0); |
| | | while (type.getParent() != null) |
| | | type = type.getParent(); |
| | | info.setVideoType(type); |
| | | } |
| | | |
| | | info.setPlayPicture(VideoPictureUtil.getShowPicture(info, acceptData.getPlatform(), acceptData.getVersion() + "")); |
| | | |
| | | if (info.getVideoDetailList() != null) |
| | | for (VideoDetailInfo vd : info.getVideoDetailList()) { |
| | | if (StringUtil.isNullOrEmpty(vd.getExtraId())) |
| | | vd.setExtraId(vd.getId() + ""); |
| | | } |
| | | info.setCommentCount(0); |
| | | |
| | | |
| | | VideoDetailVO.AttentionInfo attention = null; |
| | | if (info.getVideoDetailList() != null) |
| | | if (info.getVideoDetailList().size() > 1) {// 多集,可关注 |
| | | boolean isAttention = false; |
| | | if (!StringUtil.isNullOrEmpty(loginUid)) { |
| | | isAttention = attentionService.isAddAttention(loginUid, info.getId()); |
| | | } |
| | | attention = new VideoDetailVO.AttentionInfo(); |
| | | attention.setName(info.getName()); |
| | | attention.setPicture(info.getPicture()); |
| | | if (StringUtil.isNullOrEmpty(info.getUpdatetime())) { |
| | | attention.setUpdateInfo("更新:" + TimeUtil.getCommentTime(info.getCreatetime())); |
| | | } else { |
| | | attention.setUpdateInfo("更新:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime()))); |
| | | } |
| | | attention.setAttention(isAttention); |
| | | } |
| | | |
| | | //视频过滤 |
| | | filterVideo(acceptData, info); |
| | | String sessionId = createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId); |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid, videoId, from), attention, sessionId)))); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | PlayUrl pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); |
| | | 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())) |
| | |
| | | |
| | | public void isPraise(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | DetailSystemConfig config = configService.getConfigByKey("banner_praise", detailSystem, acceptData.getVersion()); |
| | | if ("是" .equals(config.getValue())) { |
| | | DetailSystemConfig config = configService.getConfigByKey("banner_praise", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | if ("是".equals(config.getValue())) { |
| | | out.print(JsonUtil.loadTrueJson("1")); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson("0")); |
| | |
| | | public void getRecommendSearchSpecial(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | //推荐搜索专题 |
| | | DetailSystemConfig config = configService.getConfigByKey("recommend_search_special_position", detailSystem, acceptData.getVersion()); |
| | | DetailSystemConfig config = configService.getConfigByKey("recommend_search_special_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | if (config == null) { |
| | | out.print(JsonUtil.loadFalseAdmin("位置为空")); |
| | | return; |