| | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.jump.JumpDetail; |
| | | import com.yeshi.buwan.domain.jump.JumpTypeEnum; |
| | | import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial; |
| | | import com.yeshi.buwan.domain.system.DetailSystemConfig; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | 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.mogotv.MogoTVUtil; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.imp.*; |
| | | import com.yeshi.buwan.service.inter.ad.DeviceAdStrategyService; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.service.inter.juhe.YouKuService; |
| | | import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService; |
| | | import com.yeshi.buwan.service.inter.video.VideoWatchHistoryService; |
| | | import com.yeshi.buwan.service.manager.VideoPlayStatisticManager; |
| | | import com.yeshi.buwan.tencent.TencentVideoUtil; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.annotation.RequireUid; |
| | | import com.yeshi.buwan.util.factory.VideoInfoFactory; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.log.UserActiveLogFactory; |
| | | import com.yeshi.buwan.util.log.VideoLogFactory; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.video.VideoDetailVO; |
| | | import com.yeshi.buwan.youku.YouKuUtil; |
| | | import com.yeshi.buwan.youku.entity.YouKuSearchVideoMap; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowDetail; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.service.imp.AdService; |
| | | import com.yeshi.buwan.service.imp.AttentionService; |
| | | import com.yeshi.buwan.service.imp.ClassService; |
| | | import com.yeshi.buwan.service.imp.CollectionService; |
| | | import com.yeshi.buwan.service.imp.CommentService; |
| | | import com.yeshi.buwan.service.imp.ConfigService; |
| | | import com.yeshi.buwan.service.imp.HomeAdService; |
| | | import com.yeshi.buwan.service.imp.HomeTypeService; |
| | | import com.yeshi.buwan.service.imp.StatisticsService; |
| | | import com.yeshi.buwan.service.imp.SystemService; |
| | | import com.yeshi.buwan.service.imp.UserService; |
| | | import com.yeshi.buwan.service.imp.VideoManager; |
| | | import com.yeshi.buwan.util.CacheUtil; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.JuheVideoUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.Utils; |
| | | import com.yeshi.buwan.util.VideoPictureUtil; |
| | | import com.yeshi.buwan.util.JuHe.VideoResourceUtil; |
| | | import com.yeshi.buwan.util.video.VideoDetailUtil; |
| | | import com.yeshi.buwan.util.zhibo.MeiNvZhiBoUtil; |
| | |
| | | |
| | | @Controller |
| | | public class HomeParser { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(HomeParser.class); |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | |
| | | @Resource |
| | | private HomeTypeService homeTypeService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | private DetailSystemConfigService configService; |
| | | @Resource |
| | | private AdService adService; |
| | | @Resource |
| | |
| | | @Resource |
| | | private VideoDetailUtil videoDetailUtil; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | @Resource |
| | | private VideoWatchHistoryService videoWatchHistoryService; |
| | | |
| | | @Resource |
| | | private HomeRecommendSpecialService homeRecommendSpecialService; |
| | | |
| | | @Resource |
| | | private DeviceAdStrategyService deviceAdStrategyService; |
| | | |
| | | private final Logger userPlayLogger = LoggerFactory.getLogger("videoPlayUser"); |
| | | |
| | | @RequireUid |
| | | public void getHomeAd(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | String vtid = request.getParameter("Vtid"); |
| | | if (!"310".equals(vtid)) { |
| | | HomeRecommendSpecial special = homeRecommendSpecialService.getSpecial(vtid); |
| | | //兼容新版本 |
| | | if (special != null) { |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<HomeAd> list = homeAdService.getHomeAdList(detailSystem); |
| | | |
| | | // 测试跳转小程序 |
| | | // JSONObject xcx = new JSONObject(); |
| | | // xcx.put("thumb", |
| | | // "http://img.zcool.cn/community/0169235af03daea801206aba8664d7.jpeg@260w_195h_1c_1e_1o_100sh.jpg"); |
| | | // xcx.put("title", "测试标题"); |
| | | // xcx.put("desc", "简介"); |
| | | // xcx.put("path", "pages/index/index"); |
| | | // xcx.put("username", "gh_33b9bea57aff"); |
| | | // xcx.put("url", "http://video.yeshitv.com"); |
| | | |
| | | // 测试标题 |
| | | // HomeAd homeAd = new HomeAd(); |
| | | // homeAd.setClazz("com"); |
| | | // homeAd.setLinkType(5); |
| | | // homeAd.setOrderby(0); |
| | | // homeAd.setPicture( |
| | | // "http://img.zcool.cn/community/0169235af03daea801206aba8664d7.jpeg@260w_195h_1c_1e_1o_100sh.jpg"); |
| | | // homeAd.setVideo(new VideoInfo(1 + "")); |
| | | // homeAd.setParams(xcx.toString()); |
| | | // homeAd.setTitle("标题"); |
| | | // list.add(homeAd); |
| | | List<HomeAd> list = homeAdService.getHomeAdList(detailSystem, special != null ? special.getDataKey() : null); |
| | | |
| | | if (acceptData.getPlatform().equalsIgnoreCase("ios"))// IOS测试 |
| | | { |
| | |
| | | for (int i = 0; i < list.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | object.put("data", array); |
| | | |
| | | } else { |
| | | for (HomeAd ad : list) { |
| | | if (ad.getVideo() != null) { |
| | |
| | | if (!StringUtil.isNullOrEmpty(ad.getParams())) { |
| | | ad.setParams(ad.getParams().replace("\"", "\\" + "\"")); |
| | | } |
| | | |
| | | // 3.4.7以上的版本才可以用 |
| | | // com.weikou.beibeivideo.ui.mine.FXBrowserActivity |
| | | if ("com.weikou.beibeivideo.ui.mine.FXBrowserActivity".equalsIgnoreCase(ad.getClazz()) |
| | | && acceptData.getVersion() < 71) |
| | | ad.setClazz("com.weikou.beibeivideo.ui.mine.BrowserActivity"); |
| | | else |
| | | ad.setClazz("com.weikou.beibeivideo.ui.mine.FXBrowserActivity"); |
| | | } |
| | | object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString()); |
| | | JSONArray array = new JSONArray(); |
| | |
| | | |
| | | object.put("data", array); |
| | | } |
| | | object.put("bannerSizeRate", special.getBannerSizeRate()); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | classParser.getRecommendCategoryVideoBanner(acceptData, request, out); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 首页类型获取 |
| | |
| | | if (StringUtil.isNullOrEmpty(vtid)) { |
| | | vtid = "309"; // 为了兼容以前的推荐 |
| | | } |
| | | |
| | | HomeRecommendSpecial special = homeRecommendSpecialService.getSpecial(vtid); |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | JSONObject object = new JSONObject(); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), resourceList, |
| | | CacheUtil.getMD5Long(resourceList), -1, Long.parseLong(vtid)); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), acceptData.getPlatform(), acceptData.getVersion(), resourceList, |
| | | CacheUtil.getMD5Long(resourceList), -1, special != null ? special.getDataKey() : null); |
| | | List<HomeType> list = new ArrayList<>(); |
| | | for (HomeType ht : list1) |
| | | list.add(ht); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | 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()); |
| | | if (adContent != null && adPosition != null) { |
| | | HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class); |
| | | int adP = Integer.parseInt(adPosition.getValue()); |
| | | if (adP < list.size() && adP > -1) { |
| | | HomeType homeType = new HomeType(); |
| | | homeType.setAd(ad); |
| | | list.add(adP, homeType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | for (HomeType ht : list) { |
| | | for (int i = 0; i < ht.getHomeVideoList().size(); i++) { |
| | | //改变图片 |
| | | if (JuheVideoUtil.isNeedDelete(ht.getHomeVideoList().get(i).getVideo(), detailSystem.getId())) { |
| | | ht.getHomeVideoList().remove(i); |
| | | i--; |
| | | if (ht.getHomeVideoList() != null) |
| | | for (int i = 0; i < ht.getHomeVideoList().size(); i++) { |
| | | //改变图片 |
| | | if (JuheVideoUtil.isNeedDelete(ht.getHomeVideoList().get(i).getVideo(), detailSystem.getId())) { |
| | | ht.getHomeVideoList().remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < list.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | |
| | | // 首页类型获取 |
| | | public void getHomeTypeNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | // 20170914 一级视频分类ID |
| | | String page = request.getParameter("Page"); |
| | | String pageSize = request.getParameter("PageSize"); |
| | | String dataKey = request.getParameter("DataKey"); |
| | | |
| | | long count = homeTypeService.countHomeType(acceptData.getDetailSystem().getId(), acceptData.getVersion(), dataKey); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | List<HomeType> homeTypeList = homeTypeService.getHomeTypeList(acceptData.getDetailSystem().getId(), acceptData.getVersion(), dataKey, Integer.parseInt(page), Integer.parseInt(pageSize)); |
| | | |
| | | if (homeTypeList != null) |
| | | for (HomeType homeType : homeTypeList) { |
| | | String resourceKey = StringUtil.Md5(org.yeshi.utils.StringUtil.concat(resourceList, ",")); |
| | | List<HomeVideo> homeVideoList = homeTypeService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber()); |
| | | long videoCount = homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null); |
| | | homeType.setCount((int) videoCount); |
| | | homeType.setHomeVideoList(homeVideoList); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < homeTypeList.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(homeTypeList.get(i))); |
| | | object.put("data", array); |
| | | object.put("count", count + ""); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | |
| | | type.setVideoList(vlist); |
| | | return type; |
| | | } |
| | | |
| | | |
| | | // 首页类型获取 |
| | | public void getHomeVideoList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | // 20170914 一级视频分类ID |
| | | String homeTypeId = request.getParameter("Id"); |
| | | int page = Integer.parseInt(request.getParameter("Page")); |
| | | |
| | | if (StringUtil.isNullOrEmpty(homeTypeId)) { |
| | | out.print(JsonUtil.loadFalseJson("")); |
| | | return; |
| | | } |
| | | |
| | | HomeType homeType = homeTypeService.getHomeTypeById(homeTypeId); |
| | | if (homeType == null) { |
| | | out.print(JsonUtil.loadFalseJson("")); |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | //查询大图 |
| | | List<HomeVideo> bigPictureVideos = homeTypeService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, true, 1, homeType.getNumber()); |
| | | |
| | | |
| | | //大图需要每次都返回 |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | String resourceKey = StringUtil.Md5(org.yeshi.utils.StringUtil.concat(resourceList, ",")); |
| | | |
| | | Long count = homeTypeService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null); |
| | | List<HomeVideo> list1 = homeTypeService.getHomeVideoList(homeTypeId, resourceKey, resourceList, false, page, homeType.getNumber()); |
| | | List<HomeVideo> list = new ArrayList<>(); |
| | | list.addAll(bigPictureVideos); |
| | | list.addAll(list1); |
| | | JSONObject data = new JSONObject(); |
| | | object.put("count", count); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < list.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | object.put("list", array); |
| | | |
| | | //判断是否还有下一页 |
| | | int totalPage = (int) ((count - bigPictureVideos.size()) % homeType.getNumber() == 0 ? (count - bigPictureVideos.size()) / homeType.getNumber() : (count - bigPictureVideos.size()) / homeType.getNumber() + 1); |
| | | |
| | | if (page >= totalPage) { |
| | | page = 0; |
| | | } |
| | | object.put("page", page); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | |
| | | @RequireUid |
| | | public void getMoreVideo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | @Resource |
| | | private YouKuUtil youKuUtil; |
| | | |
| | | @Resource |
| | | private MogoTVUtil mogoTVUtil; |
| | | |
| | | @Resource |
| | | private TencentVideoUtil tencentVideoUtil; |
| | | |
| | | @Resource |
| | | private VideoPlayStatisticManager videoPlayStatisticManager; |
| | | |
| | | |
| | | private String createVideoDetailSessionId(AcceptData acceptData, String uid, String videoName, String videoId, String resourceId) { |
| | | |
| | | try { |
| | | VideoDetailStatisticData data = new VideoDetailStatisticData(); |
| | | data.setDetailSystemId(acceptData.getDetailSystem().getId()); |
| | | data.setLoginUid(uid); |
| | | data.setResourceId(Integer.parseInt(resourceId)); |
| | | data.setUtdId(acceptData.getUtdId()); |
| | | data.setVersion(acceptData.getVersion()); |
| | | data.setVideoId(videoId); |
| | | data.setVideoName(videoName); |
| | | |
| | | return videoPlayStatisticManager.createVideoDetailSessionId(data); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) { |
| | | String loginUid = request.getParameter("LoginUid"); |
| | | String from = request.getParameter("From"); |
| | | InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId); |
| | | String resourceId = request.getParameter("ResourceId"); |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | | resourceId = internetSearchVideo.getResourceIds().split(",")[0]; |
| | | } |
| | | VideoInfo info = null; |
| | | if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) { |
| | | try { |
| | | info = youKuUtil.getVideoInfo(internetSearchVideo); |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:" + videoId); |
| | | e.printStackTrace(); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | |
| | | } else if (Integer.parseInt(resourceId) == MogoTVUtil.RESOURCE_ID) { |
| | | try { |
| | | info = mogoTVUtil.getVideoInfo(internetSearchVideo); |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:" + videoId); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | } else if (Integer.parseInt(resourceId) == TencentVideoUtil.RESOURCE_ID) { |
| | | try { |
| | | info = tencentVideoUtil.getVideoInfo(internetSearchVideo); |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:" + videoId); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info.getName(), from)); |
| | | |
| | | info.setWatchCount("" + (int) (Math.random() * 1000)); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | JSONObject obj = new JSONObject(); |
| | | |
| | | if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), loginUid), null, createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId))), array.toString(), |
| | | obj.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | | obj.toString())); |
| | | } |
| | | } |
| | | |
| | | @RequireUid |
| | | public void getVideoDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | String videoId = request.getParameter("VideoId"); |
| | | if (!NumberUtil.isNumeric(videoId)) { |
| | | getVideoDetailForInternetSearch(acceptData, videoId, request, out); |
| | | 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; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | //获取优先展示的渠道 |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | | Set<Long> rids = new HashSet<>(); |
| | | rids.addAll(resourceList); |
| | | VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids); |
| | | if (defaultVideoResource != null) { |
| | | resourceId = defaultVideoResource.getId(); |
| | | } |
| | | } |
| | | |
| | | 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 (resourceId != null && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) { |
| | | JSONObject data = new JSONObject(); |
| | | PPTVSeries series = pptvService.getSeriesDetailByVideoId(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(); |
| | | } |
| | | } |
| | | |
| | | p = p >= series.getSeries().size() ? 0 : p; |
| | | |
| | | String sessionId = createVideoDetailSessionId(acceptData, loginUid, series.getName(), videoId, resourceId); |
| | | String playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(p)); |
| | | data.put("videoId", videoId); |
| | | data.put("playUrl", playUrl); |
| | | data.put("name", series.getName()); |
| | | data.put("pptv", true); |
| | | 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() { |
| | | //每天展示一次广告 |
| | | long showTime = TimeUtil.convertGernalTime(TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"); |
| | | |
| | | deviceAdStrategyService.setVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), showTime, null); |
| | | } |
| | | }); |
| | | 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) { |
| | |
| | | if (StringUtil.isNullOrEmpty(vd.getExtraId())) |
| | | vd.setExtraId(vd.getId() + ""); |
| | | } |
| | | System.out.println(info.getPlayPicture()); |
| | | // info.setPicture(VideoPictureUtil.getShowPicture(info, platform, |
| | | // version)); |
| | | |
| | | // 过滤版权视频关键字 |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | // 统计添加 |
| | | // statisticsService.addStatistics(detailSystem.getId(), videoId); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | array.add("http://cloud.letv.com"); |
| | | if ((acceptData.getPlatform().equalsIgnoreCase("android") |
| | | && acceptData.getVersion() > 12) || acceptData.getPlatform().equalsIgnoreCase("ios")) { |
| | | for (String st : Constant.POJIE_LIST) |
| | | array.add(st); |
| | | } |
| | | |
| | | long count = commentService.getComment2ListCount(videoId, thirdType); |
| | | if (info != null) |
| | | info.setCommentCount((int) count); |
| | | |
| | | JSONObject obj = new JSONObject(); |
| | | 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); |
| | | |
| | | //兼容老版本 |
| | | JSONObject attentionInfo = new JSONObject(); |
| | | attentionInfo.put("Name", info.getName()); |
| | | attentionInfo.put("Picture", info.getPicture()); |
| | | if (StringUtil.isNullOrEmpty(info.getUpdatetime())) |
| | | attentionInfo.put("UpdateInfo", "更新:" + TimeUtil.getCommentTime(info.getCreatetime())); |
| | | else |
| | | attentionInfo.put("UpdateInfo", "更新:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime()))); |
| | | attentionInfo.put("IsAttention", isAttention); |
| | | attentionInfo.put("Picture", attention.getPicture()); |
| | | attentionInfo.put("Name", attention.getName()); |
| | | attentionInfo.put("UpdateInfo", attention.getUpdateInfo()); |
| | | attentionInfo.put("IsAttention", attention.isAttention()); |
| | | obj.put("Attention", attentionInfo); |
| | | } |
| | | UserInfo user = userService.getUserInfo(acceptData.getUid()); |
| | | if (Utils.isTest(request, user, detailSystem.getId())) |
| | | out.print(JsonUtil.loadTrueJson("")); |
| | | else |
| | | 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(), loginUid), attention, sessionId)), array.toString(), |
| | | obj.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), |
| | | obj.toString())); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取视频的剧集列表 |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!NumberUtil.isNumeric(detailId)) { |
| | | out.print(JsonUtil.loadFalseJson("")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | boolean collect = collectionService.isCollect(acceptData.getUid(), detailId, thirdType); |
| | | if (collect) |
| | | out.print(JsonUtil.loadTrueJson("")); |
| | |
| | | |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | PlayUrl pu = videoDeailUtil.getPlayUrl(acceptData,detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); |
| | | PlayUrl pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); |
| | | |
| | | if (pu != null) { |
| | | if (!StringUtil.isNullOrEmpty(pu.getUrl())) |
| | |
| | | |
| | | public void isPraise(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | Config config = configService.getConfigByKey("banner_praise", detailSystem, acceptData.getVersion()); |
| | | DetailSystemConfig config = configService.getConfigByKey("banner_praise", detailSystem, acceptData.getVersion()); |
| | | if ("是".equals(config.getValue())) { |
| | | out.print(JsonUtil.loadTrueJson("1")); |
| | | } else { |