package com.newvideo.util.video;
|
|
import java.util.Iterator;
|
|
import com.newvideo.util.StringUtil;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
public class CZTVParser {
|
public static String getRequestUrl(String baseUrl) {
|
String id = baseUrl.split("id=")[1];
|
return "http://api.cms.cztv.com/mms/out/video/playJson?id=" + id
|
+ "&domain=www.letv.com&splatid=111&platid=1002&pt=2&at=1";
|
}
|
|
public static String parseResponse(String result) {
|
JSONObject object = JSONObject.fromObject(result);
|
JSONArray array = object.optJSONObject("playurl").optJSONArray("dispatch");
|
array = array.optJSONObject(array.size() - 1).optJSONArray("url");
|
for (int i = array.size() - 1; i > -1; i--) {
|
JSONObject obj = array.optJSONObject(i);
|
Iterator<String> its = obj.keys();
|
if (its.hasNext()) {
|
String key = its.next();
|
if ((key.contains("fastweb") || key.contains("chinacache"))// letv
|
&& !StringUtil.isNullOrEmpty(obj.optString(key))) {
|
return obj.optString(key);
|
}
|
}
|
}
|
return "";
|
}
|
|
}
|