package com.yeshi.buwan.controller.parser.web;
|
|
import java.io.IOException;
|
import java.io.PrintWriter;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import com.yeshi.buwan.exception.video.VideoPlayException;
|
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.springframework.stereotype.Controller;
|
|
import com.yeshi.buwan.domain.CategoryContry;
|
import com.yeshi.buwan.domain.system.DetailSystem;
|
import com.yeshi.buwan.domain.HomeAd;
|
import com.yeshi.buwan.domain.HomeType;
|
import com.yeshi.buwan.domain.HomeVideo;
|
import com.yeshi.buwan.domain.HotStar;
|
import com.yeshi.buwan.domain.RecommendAd;
|
import com.yeshi.buwan.domain.SuperVideoType;
|
import com.yeshi.buwan.domain.UserInfo;
|
import com.yeshi.buwan.domain.VideoDetailInfo;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.VideoType;
|
import com.yeshi.buwan.domain.entity.PlayUrl;
|
import com.yeshi.buwan.domain.recommend.CategoryRecommendVideo;
|
import com.yeshi.buwan.domain.special.Special;
|
import com.yeshi.buwan.service.imp.AdService;
|
import com.yeshi.buwan.service.imp.AttentionService;
|
import com.yeshi.buwan.service.imp.BanQuanService;
|
import com.yeshi.buwan.service.imp.CategoryAreaService;
|
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.DetailSystemConfigService;
|
import com.yeshi.buwan.service.imp.HomeAdService;
|
import com.yeshi.buwan.service.imp.HomeTypeService;
|
import com.yeshi.buwan.service.imp.RecommendService;
|
import com.yeshi.buwan.service.imp.SearchService;
|
import com.yeshi.buwan.service.imp.SpecialService;
|
import com.yeshi.buwan.service.imp.StarService;
|
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.service.imp.recommend.CategoryRecommendVideoService;
|
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;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
@Controller
|
public class WebHomeParser {
|
@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 StatisticsService statisticsService;
|
@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 VideoManager videoManager;
|
|
@Resource
|
private CategoryRecommendVideoService categoryRecommendVideoService;
|
|
@Resource
|
private RecommendService recommendService;
|
|
@Resource
|
private BanQuanService banQuanService;
|
|
@Resource
|
private SearchService searchService;
|
|
@Resource
|
private CategoryAreaService categoryAreaService;
|
|
@Resource
|
private StarService starService;
|
|
@Resource
|
private SpecialService specialService;
|
|
// 首页
|
public void getHomePage(String uid, HttpServletRequest request, PrintWriter out) {
|
String method = request.getParameter("Method");
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String packageName = request.getParameter("Package");
|
String channel = request.getParameter("Channel");
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
|
JSONObject object = new JSONObject();
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
|
List<HomeAd> list = homeAdService.getHomeAdList(detailSystem, "recommend");
|
|
for (HomeAd ad : list) {
|
if (ad.getVideo() != null) {
|
ad.getVideo().setIntroduction("");
|
ad.getVideo().setMainActor("");
|
}
|
if (!StringUtil.isNullOrEmpty(ad.getParams())) {
|
ad.setParams(ad.getParams().replace("\"", "\\" + "\""));
|
}
|
}
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
|
object.put("homeAdList", array);
|
object.put("homeTypeList", getHomeType(uid, platform, detailSystem.getId(), channel));
|
|
// 排行
|
JSONObject rank = new JSONObject();
|
rank.put("tv", getRank(detailSystem.getId(), platform, "150"));
|
rank.put("movie", getRank(detailSystem.getId(), platform, "151"));
|
rank.put("show", getRank(detailSystem.getId(), platform, "152"));
|
rank.put("cartoon", getRank(detailSystem.getId(), platform, "153"));
|
|
rank.put("entertainment", getRank(detailSystem.getId(), platform, "155"));
|
rank.put("live", getRank(detailSystem.getId(), platform, "157"));
|
rank.put("game", getRank(detailSystem.getId(), platform, "154"));
|
rank.put("science", getRank(detailSystem.getId(), platform, "156"));
|
rank.put("dance", getRank(detailSystem.getId(), platform, "274"));
|
rank.put("sports", getRank(detailSystem.getId(), platform, "158"));
|
|
object.put("rank", rank);
|
|
// 获取homeType
|
|
out.print(JsonUtil.loadTrueJsonNoencript(object.toString()));
|
}
|
|
// 首页类型获取
|
private JSONArray getHomeType(String uid, String platform, String detailsystemid, String channel) {
|
|
List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1, channel);
|
List<HomeType> list1 = homeTypeService.getHomeType(detailsystemid, platform, 1, resourceList,
|
CacheUtil.getMD5Long(resourceList), 10, "recommend");
|
List<HomeType> list = new ArrayList<>();
|
for (HomeType ht : list1)
|
list.add(ht);
|
|
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(), detailsystemid)) {
|
ht.getHomeVideoList().remove(i);
|
i--;
|
}
|
}
|
}
|
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
return array;
|
}
|
|
private JSONArray getRank(String detailsystemid, String platform, String typeid) {
|
int count = categoryRecommendVideoService.getRankVideoNumber(Integer.parseInt(typeid));
|
List<VideoInfo> list = recommendService.getCategoryRecommendVideoList(Integer.parseInt(typeid), count);
|
|
list = banQuanService.getBanQuanVideo(list, detailsystemid, CacheUtil.getMD5VideoInfo(list));
|
for (VideoInfo vi : list) {// 清除无用数据,防止浪费带宽
|
vi.setIntroduction("");
|
vi.setMainActor("");
|
vi.setPicture(VideoPictureUtil.getShowPicture(vi, platform, "0"));
|
}
|
JSONObject object = new JSONObject();
|
object.put("count", list.size());
|
if (list.size() > 10)
|
list = list.subList(0, 10);
|
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
return array;
|
}
|
|
public void getClass(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String version = request.getParameter("Version");
|
String packageName = request.getParameter("Package");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
|
List<SuperVideoType> clist = classService.getSuperVideoTypeList(detailSystem.getId());
|
List<SuperVideoType> list = new ArrayList<>();
|
list.addAll(clist);
|
|
List<VideoType> typelist = new ArrayList<>();
|
for (SuperVideoType sv : list) {
|
if (!StringUtil.isNullOrEmpty(sv.getPicture())) {
|
sv.getType().setIcon(sv.getPicture());
|
}
|
List<VideoType> childList = getFirstType(sv.getType().getId() + "");
|
sv.getType().setChildTypeList(childList);
|
typelist.add(sv.getType());
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int j = 0; j < typelist.size(); j++) {
|
JSONObject obj = JSONObject.fromObject(StringUtil.outPutResultJson(typelist.get(j)));
|
if (typelist.get(j).getChildTypeList() != null) {
|
JSONArray ca = new JSONArray();
|
for (VideoType child : typelist.get(j).getChildTypeList()) {
|
ca.add(StringUtil.outPutResultJson(child));
|
}
|
obj.put("ChildList", ca);
|
}
|
array.add(obj);
|
}
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJsonNoencript(object.toString()));
|
}
|
|
public void getCategoryRecommend(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String version = request.getParameter("Version");
|
String packageName = request.getParameter("Package");
|
String pid = request.getParameter("Pid");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(pid)) {
|
out.print(JsonUtil.loadFalseJson("Pid"));
|
return;
|
}
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
|
JSONObject object = new JSONObject();
|
object.put("banner", getCategoryRecommendBanner(detailSystem.getId(), pid));
|
object.put("videos", getCategoryRecommendVideos(detailSystem.getId(), pid, platform));
|
|
out.print(JsonUtil.loadTrueJsonNoencript(object.toString()));
|
}
|
|
public void getTopHotStars(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
|
List<HotStar> list = starService.getHotStarList(1, 20);
|
JSONArray array = new JSONArray();
|
for (HotStar hs : list)
|
array.add(StringUtil.outPutResultJson(hs));
|
|
out.print(JsonUtil.loadTrueJsonNoencript(array.toString()));
|
}
|
|
public void getTopTypePlayVideos(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String pid = request.getParameter("Pid");
|
String packageName = request.getParameter("Package");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(pid)) {
|
out.print(JsonUtil.loadFalseJson("Pid"));
|
return;
|
}
|
|
List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), 1, null);
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
|
List<VideoType> typeList = getFirstType(pid);
|
JSONArray data = new JSONArray();
|
for (VideoType vt : typeList) {
|
List<VideoInfo> list = new ArrayList<>();
|
if (StringUtil.isNullOrEmpty(vt.getCategoryType()) || "genre".equalsIgnoreCase(vt.getCategoryType())) {// 按分类检索数据
|
Long startTime = System.currentTimeMillis();
|
List<VideoInfo> list1 = classService.getTypeVideoList(vt.getId() + "", detailSystem, 1, 20, 2,
|
resourceList, CacheUtil.getMD5Long(resourceList));
|
list = new ArrayList<>();
|
if (list1 != null)
|
for (VideoInfo info : list1)
|
list.add(info);
|
System.out.println("列表获取时间:" + (System.currentTimeMillis() - startTime));
|
} else {// 按地区检索数据
|
String areaId = vt.getId() + "";// 国籍ID
|
CategoryContry cc = categoryAreaService.getCategoryArea(areaId);
|
String country = cc.getName();
|
long typeid = cc.getParent().getCid();
|
|
list = categoryAreaService.getVideoInfoByArea(typeid + "", detailSystem, 1, 20, 2, resourceList,
|
country, StringUtil.Md5(typeid + "-" + detailSystem + "-" + 1 + "-" + 2 + "-" + country + "-"
|
+ CacheUtil.getMD5Long(resourceList)));
|
}
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++) {
|
list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), platform, 33 + ""));
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
data.add(array);
|
}
|
out.print(JsonUtil.loadTrueJsonNoencript(data.toString()));
|
}
|
|
public void getHotStarList(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String packageName = request.getParameter("Package");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
List<HotStar> list = starService.getHotStarList(1, 100);
|
JSONArray array = new JSONArray();
|
for (HotStar hs : list)
|
array.add(StringUtil.outPutResultJson(hs));
|
|
out.print(JsonUtil.loadTrueJsonNoencript(array.toString()));
|
}
|
|
public void getSpecialList(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String packageName = request.getParameter("Package");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("Platform"));
|
return;
|
}
|
|
DetailSystem ds = systemService.getDetailSystemByPackage(packageName);
|
|
List<Special> list = specialService.getSpecialList(ds.getId());
|
JSONArray array = new JSONArray();
|
for (Special s : list)
|
array.add(StringUtil.outPutResultJson(s));
|
|
out.print(JsonUtil.loadTrueJsonNoencript(array.toString()));
|
}
|
|
private JSONArray getCategoryRecommendBanner(String detailsystemid, String typeid) {
|
List<CategoryRecommendVideo> crvList = categoryRecommendVideoService
|
.getCategoryRecommendVideoBannerList(detailsystemid, Integer.parseInt(typeid));
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < crvList.size(); i++)
|
array.add(StringUtil.outPutResultJson(crvList.get(i)));
|
return array;
|
}
|
|
private JSONArray getCategoryRecommendVideos(String detailsystemid, String typeid, String platform) {
|
List<VideoInfo> list = recommendService.getCategoryRecommendVideoList(Integer.parseInt(typeid), 10);
|
|
list = banQuanService.getBanQuanVideo(list, detailsystemid, CacheUtil.getMD5VideoInfo(list));
|
for (VideoInfo vi : list) {// 清除无用数据,防止浪费带宽
|
vi.setIntroduction("");
|
vi.setMainActor("");
|
vi.setPicture(VideoPictureUtil.getShowPicture(vi, platform, 0 + ""));
|
}
|
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
return array;
|
}
|
|
private List<VideoType> getFirstType(String parentId) {
|
List<VideoType> list = new ArrayList<>();
|
|
if ("150".equalsIgnoreCase(parentId) || "151".equalsIgnoreCase(parentId) || "152".equalsIgnoreCase(parentId)
|
|| "153".equalsIgnoreCase(parentId)) {
|
|
List<CategoryContry> clist = categoryAreaService.getCategoryContryListByCid(parentId);
|
|
List<CategoryContry> areaList = categoryAreaService.categoryContryList(clist.get(0).getId() + "");
|
|
if ("150".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(282);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
} else if ("151".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(281);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
} else if ("153".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(283);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
}
|
|
for (CategoryContry cc : areaList) {
|
VideoType type = new VideoType(cc.getId());
|
type.setName(cc.getName());
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
}
|
|
} else {
|
List<VideoType> clist = classService.getFirstTypeList(parentId);
|
list = new ArrayList<>();
|
if (clist != null)
|
for (VideoType vt : clist) {
|
vt.setCategoryType("genre");
|
list.add(vt);
|
}
|
}
|
return list;
|
}
|
|
public void getHotSearch(String uid, HttpServletRequest request, PrintWriter out) {
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String packageName = request.getParameter("Package");
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
List<String> list = searchService.getHotSearchList(detailSystem.getId());
|
JSONObject object = new JSONObject();
|
object.put("count", list.size() + "");
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++) {
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJsonNoencript(object.toString()));
|
}
|
|
public HomeType convertHomeVideoList(HomeType type) {
|
List<VideoInfo> vlist = new ArrayList<>();
|
List<HomeVideo> list = type.getHomeVideoList();
|
if (list != null)
|
for (HomeVideo hv : list) {
|
vlist.add(hv.getVideo());
|
}
|
type.setVideoList(vlist);
|
return type;
|
}
|
|
public void getMoreVideo(String uid, HttpServletRequest request, PrintWriter out) {
|
String method = request.getParameter("Method");
|
|
String type = request.getParameter("Type");
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String page = request.getParameter("Page");
|
String platform = request.getParameter("Platform");
|
String version = request.getParameter("Version");
|
String packageName = request.getParameter("Package");
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(page)) {
|
out.print(JsonUtil.loadFalseJson("请上传Page"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
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(packageName);
|
UserInfo user = userService.getUserInfo(uid);
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(type, pageIndex, detailSystem);
|
|
List<VideoInfo> list = new ArrayList<>();
|
for (int i = 0; i < homeVideoList.size(); i++) {
|
HomeVideo hv = (HomeVideo) homeVideoList.get(i);
|
if (detailSystem.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(String uid, HttpServletRequest request, PrintWriter out) {
|
String method = request.getParameter("Method");
|
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String packageName = request.getParameter("Package");
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
|
|
List<RecommendAd> list = adService.getRecommendAdList(detailSystem.getId());
|
if (list == null)
|
list = new ArrayList<>();
|
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()));
|
}
|
|
public void getVideoDetail(String uid, HttpServletRequest request, PrintWriter out) {
|
String method = request.getParameter("Method");
|
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String videoId = request.getParameter("VideoId");
|
String resourceId = request.getParameter("ResourceId");
|
String thirdType = request.getParameter("Type");
|
String platform = request.getParameter("Platform");
|
String version = request.getParameter("Version");
|
String packageName = request.getParameter("Package");
|
String loginUid = request.getParameter("LoginUid");
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(videoId)) {
|
out.print(JsonUtil.loadFalseJson("请上传VideoId"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(thirdType)) {
|
out.print(JsonUtil.loadFalseJson("请上传Type"));
|
return;
|
}
|
|
List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(new DetailSystem("44"), Integer.parseInt(version), null);
|
|
VideoInfo info = (videoDeailUtil.getVideoInfo(null, videoId, resourceId, resourceList,
|
CacheUtil.getMD5Long(resourceList)));
|
|
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, platform, version));
|
|
for (VideoDetailInfo vd : info.getVideoDetailList()) {
|
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(packageName);
|
// 统计添加
|
// statisticsService.addStatistics(detailSystem.getId(), videoId);
|
|
JSONArray array = new JSONArray();
|
array.add("http://cloud.letv.com");
|
if ((platform.equalsIgnoreCase("android") && !StringUtil.isNullOrEmpty(version)
|
&& Integer.parseInt(version) > 12) || platform.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();
|
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());
|
attentionInfo.put("UpdateInfo", "更新:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime())));
|
attentionInfo.put("IsAttention", isAttention);
|
obj.put("Attention", attentionInfo);
|
}
|
UserInfo user = userService.getUserInfo(uid);
|
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()));
|
}
|
|
public void getNewVideoDetail(String uid, HttpServletRequest request, PrintWriter out) {
|
getVideoDetail(uid, request, out);
|
}
|
|
public void isCollected(String uid, HttpServletRequest request, PrintWriter out) {
|
String method = request.getParameter("Method");
|
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String detailId = request.getParameter("Id");
|
String platform = request.getParameter("Platform");
|
String thirdType = request.getParameter("ThirdType");
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(detailId)) {
|
out.print(JsonUtil.loadFalseJson("请上传Id"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
|
boolean collect = collectionService.isCollect(uid, detailId, thirdType);
|
if (collect)
|
out.print(JsonUtil.loadTrueJson(""));
|
else
|
out.print(JsonUtil.loadFalseJson(""));
|
|
}
|
|
public void getPlayUrl(String uid, HttpServletRequest request, PrintWriter out) {
|
|
String method = request.getParameter("Method");
|
|
String system = request.getParameter("System");
|
String sign = request.getParameter("Sign");
|
String platform = request.getParameter("Platform");
|
String version = request.getParameter("Version");
|
String resourceId = request.getParameter("ResourceId");
|
String id = request.getParameter("Id");
|
String eid = request.getParameter("EId");
|
String type = request.getParameter("Type");
|
String packageName = request.getParameter("Package");
|
String videoId = request.getParameter("VideoId");
|
|
if (StringUtil.isNullOrEmpty(method)) {
|
out.print(JsonUtil.loadFalseJson("请上传Method"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(uid)) {
|
out.print(JsonUtil.loadFalseJson("请上传Uid"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(system)) {
|
out.print(JsonUtil.loadFalseJson("请上传System"));
|
return;
|
}
|
if (StringUtil.isNullOrEmpty(sign)) {
|
out.print(JsonUtil.loadFalseJson("请上传Sign"));
|
return;
|
}
|
|
if (StringUtil.isNullOrEmpty(platform)) {
|
out.print(JsonUtil.loadFalseJson("请上传Platform"));
|
return;
|
}
|
|
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(packageName);
|
|
PlayUrl pu = null;
|
try {
|
pu = videoDeailUtil.getPlayUrl(null, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId);
|
} catch (VideoPlayException e) {
|
e.printStackTrace();
|
}
|
|
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<>();
|
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 "";
|
}
|
|
}
|