package com.yeshi.buwan.util.video;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
public class MangGuoVideoParser {
|
public static String getRequestUrl(String id) {
|
return "http://mobile.api.hunantv.com/v3/juhe/getSource?userId=&osVersion=4.4.2&device=&appVersion=4.5.1&videoId="
|
+ id + "&ticket=&channel=qq&mac=&osType=android";
|
}
|
|
// 解析链接
|
public static List<String> parseRespnse(String result) {
|
List<String> list = new ArrayList<String>();
|
try {
|
JSONObject obj = JSONObject.fromObject(result);
|
JSONObject dataObj = obj.optJSONObject("data");
|
JSONArray array = dataObj.optJSONArray("videoSources");
|
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 parseSecondRespnse(String result) {
|
try {
|
JSONObject obj =JSONObject.fromObject(result);
|
return obj.optString("info");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return "";
|
}
|
|
public static String getIdByUrl(String url) {
|
String ru = "";
|
if (url.contains("?"))
|
ru = url.split("?")[0];
|
else
|
ru = url;
|
String[] sts = ru.split("/");
|
|
String id = sts[sts.length - 1];
|
if (id.contains("."))
|
id = id.split("\\.")[0];
|
return id;
|
}
|
}
|