内容输出接口.md
5.5 KB
/* Title: 1.1 获取点播信息接口 */
接口描述
接口地址
http://api.cnlive.com/open/api/dianbo/getVodInfo
接口协议
HTTP GET
接口请求参数
- vId:节目唯一标识
- sp_id:应用ID
- timestamp:时间戳,精确到秒
返回值
返回JSON格式的节目元数据信息,json示例如下:
{
"message":"请求成功",
"data":{
"MAM_VideoUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/800/419c46d67fb34b46adbd8b7de450a0f2_137519_800.m3u8",
"MAM_VideoEditor":"许真真",
"weight":"80",
"MAM_VideoUHUrl":"",
"pageUrl":"http://www.cnlive.com/fengcaidasai/v_gy2tmmrxgy.html",
"MAM_VideoLUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/400/419c46d67fb34b46adbd8b7de450a0f2_137519_400.m3u8",
"vipFlag":"0",
"CMSChannelName":"华语风采大赛",
"type":"program",
"packagePomID":"3_fengcaidasai/dianfengduijue/",
"MAM_BigPostUrl":"http://y3.cnliveimg.com:8080/image/itv/2016/0725/419c46d67fb34b46adbd8b7de450a0f2_137519_101.jpg",
"cmsChannelID":"fengcaidasai/",
"MAM_ProducerID":"先锋派",
"activityId":"",
"title":"刘子赫孙悟空大闹天宫",
"docSubTitle":"刘子赫孙悟空大闹天宫",
"MAM_NodeID":"016-020-003",
"MAM_TVColumMarkID":"",
"playAuto":"xiangguanshipin",
"docID":"656276",
"onePomID":"3_419c46d67fb34b46adbd8b7de450a0f2",
"MAM_SmallPosterUrl":"http://y3.cnliveimg.com:8080/image/itv/2016/0725/419c46d67fb34b46adbd8b7de450a0f2_137519_100.jpg",
"CMCCNodeID":"",
"MAM_PrgType":"1",
"publishDate":"2016-07-25 16:47:32",
"mediaId":"419c46d67fb34b46adbd8b7de450a0f2",
"MAM_Duration":"293000",
"MAM_CPNAME":"魅力快线3",
"MAM_NodeName":"大型专题/华语风采大赛/巅峰对决",
"vip_product_id":"",
"status":"1",
"WEB_Copyright":1,
"MAM_PosterUrl":"http://y3.cnliveimg.com:8080/image/itv/2016/0725/419c46d67fb34b46adbd8b7de450a0f2_137519_100.jpg",
"cmsColumnID":"fengcaidasai/dianfengduijue/",
"MAM_CreatDate":"2016-07-25 16:22:45",
"APP_Copyright":1,
"docBodyContent":"",
"MAM_VideoFlashUHUrl":"",
"MAM_VideoFlashHUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/1500/419c46d67fb34b46adbd8b7de450a0f2_137519_1500.mp4",
"MAM_VideoHUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/1500/419c46d67fb34b46adbd8b7de450a0f2_137519_1500.m3u8",
"CMSColumnName":"巅峰对决",
"CMCCID":"",
"freePlayLength":"60",
"MAM_VideoFlashUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/800/419c46d67fb34b46adbd8b7de450a0f2_137519_800.mp4",
"docDescription":"刘子赫精彩演绎孙悟空大闹天宫。",
"MAM_TVDate":"",
"modules":[
{
"id":"xiangguanshipin",
"title":"相关推荐"
}
],
"colName":"",
"MAM_VideoFlashLUrl":"http://wideo03.cnlive.com/video/data1/2016/0725/137519/400/419c46d67fb34b46adbd8b7de450a0f2_137519_400.mp4"
},
"errorCode":"0"
}
JSON属性说明: 四路播放地址至少一个有效
| 字段名称 | 描述 | 备注 |
| errorCode | 返回码 | 0:成功 |
| message | 返回信息 | |
| MAM_VideoUrl | 播放地址 | |
| MAM_PosterUrl | 图片地址 | |
| status | 状态 | 1:已发布;2:下线 |
| cmsColumnID | 栏目ID | |
| freePlayLength | 免费播放时长 |
参数需进行加密,示例:
public String getPlayVideo(ModelMap model,HttpServletRequest request) {
String result = "";
Map params = new HashMap<>();
params.put("sp_id", "iqhpk8pl19");
params.put("vId", "419c46d67fb34b46adbd8b7de450a0f2");
params.put("timestamp", System.currentTimeMillis()/1000+"");
String url = OpenUtil.buildURL("http://api.cnlive.com/open/api/dianbo/getVodInfo", params, "672db30805f848f59ec3728f8347a4a0");
HttpURLConnection connection;
try {
URL requestUrl = new URL(url);
connection = (HttpURLConnection)requestUrl.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();//连接
//获得返回值
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStream in = connection.getInputStream();
String currentLine = "";
if(in != null){
BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8"));
while((currentLine = br.readLine()) != null){
result += currentLine;
}
br.close();
}
}
}catch (Exception e) {
e.printStackTrace();
}
if(BaseUtil.notBlank(result)) {
JSONObject resultJson = JSONObject.parseObject(result);
model.put("videoInfo", resultJson);
}
return "play_demo";
}