admin
2021-03-26 998b6bd2a1dc25ec8350f5a691c3cd44a23d6d14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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";
    }
}