admin
2021-04-28 dff60bc721754a09fc2cd530bb75aa7bf9c01810
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
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;
    }
}