package com.yeshi.buwan.util.video;
|
|
import java.net.MalformedURLException;
|
import java.net.URL;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.yeshi.buwan.util.LogUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
public class HuaShuVideoParser {
|
public static String getRequestUrl(String id) {
|
return "http://clientapi.wasu.cn/Phone/vodinfo/id/" + id;
|
}
|
|
// 解析链接
|
public static List<String> parseRespnse(String result) {
|
List<String> list = new ArrayList<String>();
|
try {
|
JSONObject obj = JSONObject.fromObject(result);
|
JSONArray array = obj.optJSONArray("vods");
|
for (int i = 0; i < array.size(); i++) {
|
JSONObject item = array.optJSONObject(i);
|
list.add(item.optString("url"));
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return list;
|
}
|
|
public static String getIdByUrl(String url) {
|
String ru = "";
|
if (url.contains("?"))
|
ru = url.split("?")[0];
|
else
|
ru = url;
|
String id = ru.split("/id/")[1];
|
return id;
|
}
|
|
public static String getVideoUrl(String playurl, String videoid) {
|
playurl = playurl.replace("http://apkvod-cnc.wasu.cn", "http://wapvod-al.wasu.cn");
|
URL localURL = null;
|
try {
|
localURL = new URL(playurl);
|
} catch (MalformedURLException e) {
|
e.printStackTrace();
|
}
|
String time = "201509101623";// TimeUtil.getAllNoTime(System.currentTimeMillis());
|
String str3 = playurl.substring(playurl.indexOf(localURL.getHost()) + localURL.getHost().length());
|
//
|
String paramString2 = "wasu!@#48217#$@#1" + time + str3;// liveWASU12#$56&*
|
// liveWASU1234@#&*
|
// wasu!@#48217#$@#1
|
LogUtil.i(StringUtil.Md5(paramString2));
|
playurl = playurl.replace(localURL.getHost(),
|
localURL.getHost() + "/" + time + "/" + StringUtil.Md5(paramString2));
|
return playurl + "?vid=" + videoid + "&version=MIPlayer_V1.4.0";
|
}
|
}
|