预览成品
准备
在网上找了一个还算比较稳定的资源站接口。(要是小伙伴有好的地址可以评论分享一下 , 奉献的你最迷人)
网站:https://help.feisuzyapi.com/#JSONAPI
接口大概是这样的:
联盟资源分配唯一标识ID,用来区别绑定分类,这个ID一般由苹果CMS官方提供,不可随意修改设置,否则造成入库分类错乱。
1,视频列表地址https://www.feisuzyapi.com/api.php/provide/vod/?ac=list
2,视频详情地址https://www.feisuzyapi.com/api.php/provide/vod/?ac=detail
列表接收参数:
ac=list
t=类别ID
pg=页码
wd=搜索关键字
h=几小时内的数据
例如:https://www.feisuzyapi.com/api.php/provide/vod/?ac=list&t=1&pg=5 分类ID为1的列表数据第5页
内容接收参数:
参数 ids=数据ID,多个ID逗号分割。
t=类型ID
pg=页码
h=几小时内的数据
例如: https://www.feisuzyapi.com/api.php/provide/vod/?ac=detail&ids=123,567 获取ID为123和567的数据信息
https://www.feisuzyapi.com/api.php/provide/vod/?ac=detail&h=24 获取24小时内更新数据信息
编码
1.用java后台写了一个通用的请求转发
@Override
public String httpProxy(ServiceContext serviceContext) throws Exception {
String url = Format.formatStrNullForEmpty(serviceContext.getParameter("url"));
if(StrUtil.isBlank(url)){
throw new Exception("请输入url");
}
HttpServletRequest request = serviceContext.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
Map header = new HashMap();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
header.put(headerName,new ArrayList(){{
add(headerValue);
}});
}
Cookie[] cookies = request.getCookies();
String method = serviceContext.getRequest().getMethod();
Map form = new HashMap();
for (String s : request.getParameterMap().keySet()) {
form.put(s,request.getParameter(s));
}
HttpRequest httpRequest = HttpRequest.of(url);
ArrayList cookies_copy = new ArrayList<>();
if(cookies!=null){
for (Cookie cookie : Arrays.asList(cookies)) {
HttpCookie httpCookie = new HttpCookie(cookie.getName(), cookie.getValue());
httpCookie.setPath(cookie.getPath());
httpCookie.setDomain(cookie.getDomain());
httpCookie.setMaxAge(cookie.getMaxAge());
cookies_copy.add(httpCookie);
}
}
httpRequest.cookie(cookies_copy);
String requestPostData = getRequestPostData(request);
HttpResponse response = httpRequest
.method(Method.valueOf(method))
.header(header)
.body(requestPostData)
.form(form)
.setReadTimeout(1000)
.execute();
if(response.getStatus() == 302){
return response.header("Location");
}
return response.body();
}
2.前端设计
a.先请求列表接口(支持分页)
b.点击列表播放按钮调用详情接口
c.如果是 m3u8 就用h5播放,云地址就直接打开浏览器
代码就不贴了,基本都是常规代码