package com.yeshi.buwan.controller.parser;
|
|
import java.io.IOException;
|
import java.io.PrintWriter;
|
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.pptv.PPTVUtil;
|
import com.yeshi.buwan.pptv.entity.PPTVSeries;
|
import com.yeshi.buwan.service.imp.*;
|
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.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.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.util.JuHe.VideoResourceUtil;
|
import com.yeshi.buwan.util.video.VideoDetailUtil;
|
import com.yeshi.buwan.util.zhibo.MeiNvZhiBoUtil;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
@Controller
|
public class HomeParser {
|
@Resource
|
private SystemService systemService;
|
@Resource
|
private HomeAdService homeAdService;
|
@Resource
|
private HomeTypeService homeTypeService;
|
@Resource
|
private DetailSystemConfigService configService;
|
@Resource
|
private AdService adService;
|
@Resource
|
private VideoDetailUtil videoDeailUtil;
|
@Resource
|
private CommentService commentService;
|
@Resource
|
private CollectionService collectionService;
|
@Resource
|
private UserService userService;
|
@Resource
|
private VideoResourceUtil videoResouceUtil;
|
@Resource
|
private MeiNvZhiBoUtil meiNvZhiBoUtil;
|
@Resource
|
private AttentionService attentionService;
|
@Resource
|
private ClassService classService;
|
|
@Resource
|
private ClassParser classParser;
|
|
@Resource
|
private VideoDetailUtil videoDetailUtil;
|
|
@Resource
|
private ResourceVideoService resourceVideoService;
|
|
@Resource
|
private PPTVService pptvService;
|
|
@Resource
|
private VideoWatchHistoryService videoWatchHistoryService;
|
|
@Resource
|
private HomeRecommendSpecialService homeRecommendSpecialService;
|
|
private final Logger userPlayLogger = LoggerFactory.getLogger("videoPlayUser");
|
|
@RequireUid
|
public void getHomeAd(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String vtid = request.getParameter("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, special != null ? special.getDataKey() : null);
|
|
if (acceptData.getPlatform().equalsIgnoreCase("ios"))// IOS测试
|
{
|
|
if (acceptData.getVersion() > 1)// 高版本
|
{
|
for (HomeAd ad : list) {
|
if (!StringUtil.isNullOrEmpty(ad.getParams())) {
|
ad.setParams(ad.getParams().replace("\"", "\\" + "\""));
|
}
|
}
|
} else// 低版本
|
{
|
for (int i = 0; i < list.size() && i > -1; i++)
|
if (list.get(i).getLinkType() != 1) {
|
list.remove(i);
|
i--;
|
}
|
}
|
|
object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
|
JSONArray array = new JSONArray();
|
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) {
|
ad.getVideo().setIntroduction("");
|
ad.getVideo().setMainActor("");
|
}
|
if (!StringUtil.isNullOrEmpty(ad.getParams())) {
|
ad.setParams(ad.getParams().replace("\"", "\\" + "\""));
|
}
|
}
|
object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
|
object.put("data", array);
|
}
|
object.put("bannerSizeRate", special.getBannerSizeRate());
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
} else {
|
classParser.getRecommendCategoryVideoBanner(acceptData, request, out);
|
}
|
}
|
|
// 首页类型获取
|
public void getHomeType(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
System.out.println("getHomeType开始请求");
|
|
String channel = request.getParameter("Channel");
|
|
// 20170914 一级视频分类ID
|
String vtid = request.getParameter("Vtid");
|
|
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.getDetailSystem(), acceptData.getVersion());
|
List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), resourceList,
|
CacheUtil.getMD5Long(resourceList), -1, special != null ? special.getDataKey() : null);
|
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());
|
String mm = confMap.get("meinv_mm_count");
|
int count = Integer.parseInt(mm);
|
if (count > 0) {
|
try {
|
HomeType zhibo = new HomeType();
|
zhibo.setId("1111");
|
zhibo.setName("美女");
|
zhibo.setHasMore(true);
|
zhibo.setColumns(2);
|
zhibo.setHomeVideoList(meiNvZhiBoUtil.getMeiNvZhiBo(MeiNvZhiBoUtil.MEINV_KK, detailSystem, acceptData.getVersion()));
|
List<VideoInfo> zhiboVideo = new ArrayList<VideoInfo>();
|
for (HomeVideo v : zhibo.getHomeVideoList())
|
zhiboVideo.add(v.getVideo());
|
zhibo.setVideoList(zhiboVideo);
|
if (zhibo.getHomeVideoList() != null && zhibo.getHomeVideoList().size() > 0) {
|
int po = Integer.parseInt(confMap.get("zhibo_position"));// 直播数量
|
if (po < 0)
|
po = 0;
|
if (po > list.size())
|
po = list.size();
|
list.add(po, zhibo);
|
}
|
} 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);
|
}
|
}
|
}
|
}
|
|
if (acceptData.getPlatform().equalsIgnoreCase("ios")) {
|
for (HomeType ht : list) {
|
if (ht.getName().contains("福利")) {
|
ht.setActivity("MoreAndMoreViewController");
|
} else {
|
ht.setActivity("ClassDetailsViewController");
|
}
|
}
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
object.put("data", array);
|
object.put("count", list.size() + "");
|
}
|
}
|
|
if ("huawei".equalsIgnoreCase(channel)) {
|
for (int i = 0; i < list.size(); i++) {
|
if (list.get(i).getName().equalsIgnoreCase("美女")) {
|
list.remove(i);
|
break;
|
}
|
}
|
}
|
|
object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
|
|
JSONArray array = new JSONArray();
|
|
for (HomeType ht : list) {
|
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 HomeType convertHomeVideoList(HomeType type) {
|
List<VideoInfo> vlist = new ArrayList<VideoInfo>();
|
List<HomeVideo> list = type.getHomeVideoList();
|
if (list != null)
|
for (HomeVideo hv : list) {
|
vlist.add(hv.getVideo());
|
}
|
type.setVideoList(vlist);
|
return type;
|
}
|
|
@RequireUid
|
public void getMoreVideo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String type = request.getParameter("Type");
|
String page = request.getParameter("Page");
|
|
if (StringUtil.isNullOrEmpty(page)) {
|
out.print(JsonUtil.loadFalseJson("请上传Page"));
|
return;
|
}
|
|
int pageIndex = 0;
|
try {
|
pageIndex = Integer.parseInt(page);
|
} catch (Exception e) {
|
out.print(JsonUtil.loadFalseJson("Page\u683C\u5F0F\u6709\u8BEF"));
|
return;
|
}
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(type, pageIndex, detailSystem);
|
|
List<VideoInfo> list = new ArrayList<VideoInfo>();
|
for (int i = 0; i < homeVideoList.size(); i++) {
|
HomeVideo hv = (HomeVideo) homeVideoList.get(i);
|
if (acceptData.getPackageName().contains("doudou")) {
|
if (!StringUtil.isNullOrEmpty(hv.getPicture()))
|
hv.getVideo().setPicture(hv.getPicture());
|
}
|
list.add(hv.getVideo());
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
|
object.put("data", array);
|
object.put("Column", 2);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
public void getAdList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
|
List<RecommendAd> list = adService.getRecommendAdList(detailSystem.getId());
|
if (list == null)
|
list = new ArrayList<RecommendAd>();
|
JSONObject object = new JSONObject();
|
|
JSONArray array = new JSONArray();
|
|
object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
|
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()));
|
}
|
|
|
@Resource
|
private InternetSearchVideoService internetSearchVideoService;
|
@Resource
|
private YouKuUtil youKuUtil;
|
|
|
public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) {
|
InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId);
|
String resourceId = request.getParameter("ResourceId");
|
if (StringUtil.isNullOrEmpty(resourceId)) {
|
resourceId = internetSearchVideo.getResourceIds().split(",")[0];
|
}
|
|
if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) {
|
VideoInfo info = null;
|
try {
|
info = youKuUtil.getVideoInfo(internetSearchVideo);
|
} catch (Exception e) {
|
out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
|
return;
|
}
|
|
JSONArray array = new JSONArray();
|
JSONObject obj = new JSONObject();
|
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;
|
}
|
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());
|
|
//获取优先展示的渠道
|
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 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);
|
out.print(JsonUtil.loadTrueJson(data.toString()));
|
LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, series.getName(), from));
|
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() + "");
|
}
|
|
JSONArray array = new JSONArray();
|
long count = commentService.getComment2ListCount(videoId, thirdType);
|
if (info != null)
|
info.setCommentCount((int) count);
|
|
JSONObject obj = new JSONObject();
|
if (info.getVideoDetailList() != null)
|
if (info.getVideoDetailList().size() > 1) {// 多集,可关注
|
boolean isAttention = false;
|
if (!StringUtil.isNullOrEmpty(loginUid)) {
|
isAttention = attentionService.isAddAttention(loginUid, info.getId());
|
}
|
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);
|
obj.put("Attention", attentionInfo);
|
}
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
out.print(JsonUtil.loadTrueJson(""));
|
else
|
out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
|
obj.toString()));
|
}
|
|
|
/**
|
* 获取视频的剧集列表
|
*
|
* @param acceptData
|
* @param request
|
* @param out
|
*/
|
@RequireUid
|
public void getVideoEpisodeList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String videoId = request.getParameter("VideoId");
|
String resourceId = request.getParameter("ResourceId");
|
String page = request.getParameter("Page");//页码
|
|
if (StringUtil.isNullOrEmpty(videoId)) {
|
out.print(JsonUtil.loadFalseJson("请上传VideoId"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(resourceId)) {
|
out.print(JsonUtil.loadFalseJson("请上传ResourceId"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(page)) {
|
out.print(JsonUtil.loadFalseJson("请上传Page"));
|
return;
|
}
|
|
|
List<VideoDetailInfo> list = videoDetailUtil.getVideoDetailList(videoId, new VideoResource(resourceId), Integer.parseInt(page), 100);
|
if (list == null)
|
list = new ArrayList<>();
|
JSONObject data = new JSONObject();
|
String listStr = StringUtil.outPutResultJson(list);
|
boolean hasMore = list != null && list.size() > 0;
|
data.put("list", listStr);
|
data.put("hasMore", hasMore);
|
out.print(JsonUtil.loadTrueJson(data.toString()));
|
}
|
|
|
@RequireUid
|
public void getNewVideoDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
getVideoDetail(acceptData, request, out);
|
}
|
|
@RequireUid
|
public void isCollected(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String detailId = request.getParameter("Id");
|
String thirdType = request.getParameter("ThirdType");
|
|
if (StringUtil.isNullOrEmpty(detailId)) {
|
out.print(JsonUtil.loadFalseJson("请上传Id"));
|
return;
|
}
|
|
if (!NumberUtil.isNumeric(detailId)) {
|
out.print(JsonUtil.loadFalseJson(""));
|
return;
|
}
|
|
|
boolean collect = collectionService.isCollect(acceptData.getUid(), detailId, thirdType);
|
if (collect)
|
out.print(JsonUtil.loadTrueJson(""));
|
else
|
out.print(JsonUtil.loadFalseJson(""));
|
}
|
|
public void getPlayUrl(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String resourceId = request.getParameter("ResourceId");
|
String id = request.getParameter("Id");
|
String eid = request.getParameter("EId");
|
String type = request.getParameter("Type");
|
String videoId = request.getParameter("VideoId");
|
|
if (StringUtil.isNullOrEmpty(resourceId)) {
|
out.print(JsonUtil.loadFalseJson("请上传ResourceId"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(id) && StringUtil.isNullOrEmpty(eid)) {
|
out.print(JsonUtil.loadFalseJson("请上传id"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(type)) {
|
out.print(JsonUtil.loadFalseJson("请上传type"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(id))
|
id = eid;
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
|
PlayUrl pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId);
|
|
if (pu != null) {
|
if (!StringUtil.isNullOrEmpty(pu.getUrl()))
|
pu.setUrl(pu.getUrl());
|
JSONObject object = JSONObject.fromObject(StringUtil.outPutResultJson(pu));
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
} else {
|
out.print(JsonUtil.loadFalseJson("找不到该视频"));
|
}
|
|
}
|
|
|
public List<HomeVideo> getZhiBoVideoList() throws Exception {
|
List<HomeVideo> list = new ArrayList<HomeVideo>();
|
String result = get("http://www.kktv1.com/CDN/output/M/3/I/10002002/P/start-0_offset-6_platform-2/json.js");
|
JSONObject object = JSONObject.fromObject(result);
|
JSONArray array = object.optJSONArray("roomList");
|
for (int i = 0; i < array.size(); i++) {
|
VideoInfo info = new VideoInfo();
|
JSONObject obj = array.optJSONObject(i);
|
info.setId(obj.optString("roomId"));
|
info.setName(obj.optString("nickname"));
|
info.setTag("在线:" + obj.optString("onlineCount"));
|
info.setPicture(obj.optString("poster_path_272"));
|
HomeVideo hv = new HomeVideo();
|
hv.setPicture(info.getPicture());
|
hv.setVideo(info);
|
list.add(hv);
|
}
|
return list;
|
}
|
|
public String get(String url) {
|
|
HttpClient client = new HttpClient();
|
GetMethod method = new GetMethod(url);
|
method.getParams().setContentCharset("UTF-8");
|
try {
|
client.executeMethod(method);
|
String responseBodyAsString = method.getResponseBodyAsString();
|
// LogUtil.i(responseBodyAsString);
|
return responseBodyAsString;
|
} catch (HttpException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return "";
|
}
|
|
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())) {
|
out.print(JsonUtil.loadTrueJson("1"));
|
} else {
|
out.print(JsonUtil.loadTrueJson("0"));
|
}
|
}
|
|
}
|