|
|
|
|
@ -11,8 +11,8 @@ import com.fongmi.android.tv.utils.UrlUtil; |
|
|
|
|
import com.github.catvod.net.OkHttp; |
|
|
|
|
import com.github.catvod.utils.Json; |
|
|
|
|
import com.google.common.net.HttpHeaders; |
|
|
|
|
import com.google.gson.JsonElement; |
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
|
import com.google.gson.JsonParser; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
@ -107,7 +107,7 @@ public class ParseJob implements ParseCallback { |
|
|
|
|
|
|
|
|
|
private void jsonParse(Parse item, String webUrl, boolean error) throws Exception { |
|
|
|
|
String body = OkHttp.newCall(item.getUrl() + webUrl, Headers.of(item.getHeaders())).execute().body().string(); |
|
|
|
|
JsonObject object = JsonParser.parseString(body).getAsJsonObject(); |
|
|
|
|
JsonObject object = Json.parse(body).getAsJsonObject(); |
|
|
|
|
object = object.has("data") ? object.getAsJsonObject("data") : object; |
|
|
|
|
boolean illegal = body.contains("不存在") || body.contains("已过期"); |
|
|
|
|
String url = illegal ? "" : Json.safeString(object, "url"); |
|
|
|
|
@ -188,7 +188,7 @@ public class ParseJob implements ParseCallback { |
|
|
|
|
|
|
|
|
|
private Map<String, String> getHeader(JsonObject object) { |
|
|
|
|
Map<String, String> headers = new HashMap<>(); |
|
|
|
|
for (String key : object.keySet()) if (key.equalsIgnoreCase(HttpHeaders.USER_AGENT) || key.equalsIgnoreCase(HttpHeaders.REFERER)) headers.put(UrlUtil.fixHeader(key), object.get(key).getAsString()); |
|
|
|
|
for (Map.Entry<String, JsonElement> entry : object.entrySet()) if (entry.getKey().equalsIgnoreCase(HttpHeaders.USER_AGENT) || entry.getKey().equalsIgnoreCase(HttpHeaders.REFERER)) headers.put(UrlUtil.fixHeader(entry.getKey()), object.get(entry.getKey()).getAsString()); |
|
|
|
|
if (headers.isEmpty()) return parse.getHeaders(); |
|
|
|
|
return headers; |
|
|
|
|
} |
|
|
|
|
|