Remove nanohttpd
This commit is contained in:
parent
04ed4a777a
commit
f599cf0a27
|
|
@ -46,7 +46,6 @@ dependencies {
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
||||||
implementation 'com.google.code.gson:gson:2.11.0'
|
implementation 'com.google.code.gson:gson:2.11.0'
|
||||||
implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'
|
implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'
|
||||||
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
|
||||||
implementation 'com.google.zxing:core:3.3.0'
|
implementation 'com.google.zxing:core:3.3.0'
|
||||||
implementation 'com.orhanobut:logger:2.2.0'
|
implementation 'com.orhanobut:logger:2.2.0'
|
||||||
implementation 'org.jsoup:jsoup:1.15.3'
|
implementation 'org.jsoup:jsoup:1.15.3'
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@
|
||||||
# Gson
|
# Gson
|
||||||
-keep class com.google.gson.** { *; }
|
-keep class com.google.gson.** { *; }
|
||||||
|
|
||||||
# Nano
|
|
||||||
-keep class fi.iki.elonen.** { *; }
|
|
||||||
|
|
||||||
# OkHttp
|
# OkHttp
|
||||||
-dontwarn okhttp3.**
|
-dontwarn okhttp3.**
|
||||||
-keep class okio.** { *; }
|
-keep class okio.** { *; }
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ public class AliYun {
|
||||||
Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
List<String> keys = Arrays.asList("referer", "icy-metadata", "range", "connection", "accept-encoding", "user-agent");
|
List<String> keys = Arrays.asList("referer", "icy-metadata", "range", "connection", "accept-encoding", "user-agent");
|
||||||
for (String key : params.keySet()) if (keys.contains(key)) headers.put(key, params.get(key));
|
for (String key : params.keySet()) if (keys.contains(key)) headers.put(key, params.get(key));
|
||||||
return new Object[]{ProxyVideo.proxy(downloadUrl, headers)};
|
return ProxyVideo.proxy(downloadUrl, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getM3u8Url(String shareId, String fileId, String templateId) {
|
private String getM3u8Url(String shareId, String fileId, String templateId) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
package com.github.catvod.utils;
|
package com.github.catvod.utils;
|
||||||
|
|
||||||
import static fi.iki.elonen.NanoHTTPD.Response.Status;
|
|
||||||
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse;
|
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
|
@ -12,10 +9,10 @@ import com.github.catvod.spider.Proxy;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import fi.iki.elonen.NanoHTTPD;
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class ProxyVideo {
|
public class ProxyVideo {
|
||||||
|
|
@ -43,16 +40,14 @@ public class ProxyVideo {
|
||||||
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
|
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NanoHTTPD.Response proxy(String url, Map<String, String> headers) throws Exception {
|
public static Object[] proxy(String url, Map<String, String> headers) throws Exception {
|
||||||
Response response = OkHttp.newCall(url, headers);
|
Response response = OkHttp.newCall(url, headers);
|
||||||
String contentType = response.headers().get("Content-Type");
|
String contentType = response.headers().get("Content-Type");
|
||||||
String hContentLength = response.headers().get("Content-Length");
|
|
||||||
String contentDisposition = response.headers().get("Content-Disposition");
|
String contentDisposition = response.headers().get("Content-Disposition");
|
||||||
long contentLength = hContentLength != null ? Long.parseLong(hContentLength) : 0;
|
|
||||||
if (contentDisposition != null) contentType = getMimeType(contentDisposition);
|
if (contentDisposition != null) contentType = getMimeType(contentDisposition);
|
||||||
NanoHTTPD.Response resp = newFixedLengthResponse(Status.PARTIAL_CONTENT, contentType, response.body().byteStream(), contentLength);
|
Map<String, String> respHeaders = new HashMap<>();
|
||||||
for (String key : response.headers().names()) resp.addHeader(key, response.headers().get(key));
|
for (String key : response.headers().names()) respHeaders.put(key, response.headers().get(key));
|
||||||
return resp;
|
return new Object[]{206, contentType, response.body().byteStream(), respHeaders};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMimeType(String contentDisposition) {
|
private static String getMimeType(String contentDisposition) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
3eb80d3f9fc40b9470b262c4c66b39f6
|
748fbc51b767528466bdbbaee22c8803
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue