Remove juniversalchardet

This commit is contained in:
FongMi 2024-08-28 19:08:00 +08:00
parent 9d006dc413
commit 99ef274b6d
7 changed files with 3 additions and 43 deletions

View File

@ -40,7 +40,6 @@ android {
}
dependencies {
implementation 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
implementation 'com.github.thegrizzlylabs:sardine-android:0.9'
implementation 'wang.harlon.quickjs:wrapper-android:0.21.1'
implementation 'com.squareup.okhttp3:okhttp:3.12.13'

View File

@ -545,11 +545,10 @@ public class AliYun {
String fileId = params.get("fileId");
String shareId = params.get("shareId");
Response res = OkHttp.newCall(getDownloadUrl(shareId, fileId), getHeaderAuth());
byte[] body = Util.toUtf8(res.body().bytes());
Object[] result = new Object[3];
result[0] = 200;
result[1] = "application/octet-stream";
result[2] = new ByteArrayInputStream(body);
result[2] = new ByteArrayInputStream(res.body().bytes());
return result;
}

View File

@ -22,7 +22,6 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -37,8 +36,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import okhttp3.Response;
public class AList extends Spider {
private List<Drive> drives;
@ -254,24 +251,12 @@ public class AList extends Spider {
String[] split = text.split("@@@");
String name = split[0];
String ext = split[1];
String url = Proxy.getUrl() + "?do=alist&type=sub&url=" + getDetail(split[2]).getUrl();
String url = getDetail(split[2]).getUrl();
sub.add(Sub.create().name(name).ext(ext).url(url));
}
return sub;
}
public static Object[] proxy(Map<String, String> params) throws Exception {
if (!"sub".equals(params.get("type"))) return null;
String url = params.get("url");
Response res = OkHttp.newCall(url, getPlayHeader(url));
byte[] body = Util.toUtf8(res.body().bytes());
Object[] result = new Object[3];
result[0] = 200;
result[1] = "application/octet-stream";
result[2] = new ByteArrayInputStream(body);
return result;
}
class Job implements Callable<List<Vod>> {
private final Drive drive;

View File

@ -17,8 +17,6 @@ public class Proxy extends Spider {
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes("UTF-8"))};
case "ali":
return Ali.proxy(params);
case "alist":
return AList.proxy(params);
case "bili":
return Bili.proxy(params);
case "webdav":

View File

@ -13,8 +13,6 @@ import android.webkit.WebViewClient;
import com.github.catvod.spider.Init;
import org.mozilla.universalchardet.UniversalDetector;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.Arrays;
@ -57,25 +55,6 @@ public class Util {
return RULE.matcher(url).find();
}
public static byte[] toUtf8(byte[] bytes) {
try {
UniversalDetector detector = new UniversalDetector(null);
detector.handleData(bytes, 0, bytes.length);
detector.dataEnd();
return removeBOM(new String(bytes, detector.getDetectedCharset()).getBytes("UTF-8"));
} catch (Exception e) {
return bytes;
}
}
public static byte[] removeBOM(byte[] bytes) {
byte[] bom = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
if (bytes.length < 3 || !Arrays.equals(Arrays.copyOf(bytes, 3), bom)) return bytes;
byte[] newBytes = new byte[bytes.length - 3];
System.arraycopy(bytes, 3, newBytes, 0, newBytes.length);
return newBytes;
}
public static boolean isSub(String ext) {
return SUB.contains(ext);
}

Binary file not shown.

View File

@ -1 +1 @@
4c7e0340480fc0778222c0a0bb8bfc0c
67e2e90e2b6f62a730bd3e2b10539203