http://v.youku.com/v_show/id_XNjExMTQ5OTIw.html 简单粗暴,贴出解析代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| String path = "http://v.youku.com/v_show/id_XNjExMTQ5OTIw.html"; Pattern p = Pattern.compile(".*id_(\\w+)\\.html"); Matcher m = p.matcher(path); String id = ""; if (m.find()) { id = m.group(1); }
String s = "https://openapi.youku.com/v2/videos/files.json?client_id=513edb6cf9833ca7&client_secret=eaf151ffdbf1383d934ab4cb91250fa6&type=play&video_id=";
String json = HttpUtil.changeInputStream(HttpUtil.getInputStream(s + id));
JSONObject object = new JSONObject(json); object = object.getJSONObject("files"); object = object.getJSONObject("3gphd"); object = object.getJSONArray("segs").getJSONObject(0); String url = object.getString("url"); System.out.println(url);
|
最后输出:
http://180.96.38.43/youku/65738D58CD431813202EE93924/0300200100523B433B57D707A71947923FEF7E-8BE5-FC18-E182-7B619D650F21.mp4
注意这个链接是有时效性的!获取出来就尽快使用。