Update quickjs and remove bb

pull/585/head
FongMi 1 year ago
parent cc5beb85e5
commit 8e2ad4036e
  1. 2
      app/build.gradle
  2. 6
      app/src/main/java/com/fongmi/android/tv/App.java
  3. 8
      app/src/main/java/com/fongmi/android/tv/bean/Device.java
  4. 4
      quickjs/build.gradle
  5. BIN
      quickjs/libs/wrapper-android-release.aar
  6. BIN
      quickjs/libs/wrapper-java.jar
  7. 15
      quickjs/src/main/java/com/fongmi/quickjs/crawler/Spider.java
  8. 2
      quickjs/src/main/java/com/fongmi/quickjs/utils/Connect.java
  9. 7
      quickjs/src/main/java/com/fongmi/quickjs/utils/JSUtil.java
  10. 9
      quickjs/src/main/java/com/fongmi/quickjs/utils/Module.java

@ -81,6 +81,7 @@ android {
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
@ -126,4 +127,5 @@ dependencies {
annotationProcessor 'androidx.room:room-compiler:2.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.3.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.1.4'
}

@ -39,12 +39,14 @@ public class App extends Application {
private static App instance;
private Activity activity;
private final Gson gson;
private final long time;
private Hook hook;
public App() {
instance = this;
executor = Executors.newFixedThreadPool(Constant.THREAD_POOL);
handler = HandlerCompat.createAsync(Looper.getMainLooper());
time = System.currentTimeMillis();
gson = new Gson();
}
@ -56,6 +58,10 @@ public class App extends Application {
return get().gson;
}
public static long time() {
return get().time;
}
public static Activity activity() {
return get().activity;
}

@ -44,9 +44,13 @@ public class Device {
@Ignore
@SerializedName("wlan")
private String wlan;
@Ignore
@SerializedName("time")
private long time;
public static Device get() {
Device device = new Device();
device.setTime(App.time());
device.setSerial(Util.getSerial());
device.setEth(Util.getMac("eth0"));
device.setWlan(Util.getMac("wlan0"));
@ -121,6 +125,10 @@ public class Device {
this.wlan = wlan;
}
public void setTime(long time) {
this.time = time;
}
public boolean isLeanback() {
return getType() == 0;
}

@ -25,7 +25,7 @@ android {
dependencies {
implementation project(':catvod')
implementation 'org.jsoup:jsoup:1.15.3'
implementation 'wang.harlon.quickjs:wrapper-java:2.4.3'
implementation 'wang.harlon.quickjs:wrapper-android:2.4.3'
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.4'
implementation(ext: 'jar', name: 'wrapper-java', group: 'fongmi', version: 'release')
implementation(ext: 'aar', name: 'wrapper-android-release', group: 'fongmi', version: 'release')
}

Binary file not shown.

@ -165,8 +165,7 @@ public class Spider extends com.github.catvod.crawler.Spider {
@Override
public byte[] getModuleBytecode(String moduleName) {
String content = Module.get().fetch(moduleName);
return content.startsWith("//bb") ? Module.get().bb(content) : ctx.compileModule(content, moduleName);
return ctx.compileModule(Module.get().fetch(moduleName), moduleName);
}
});
}
@ -175,9 +174,8 @@ public class Spider extends com.github.catvod.crawler.Spider {
String spider = "__JS_SPIDER__";
String global = "globalThis." + spider;
String content = Module.get().fetch(api);
boolean bb = content.startsWith("//bb");
cat = bb || content.contains("__jsEvalReturn");
if (!bb) ctx.evaluateModule(content.replace(spider, global), api);
cat = content.contains("__jsEvalReturn");
ctx.evaluateModule(content.replace(spider, global), api);
ctx.evaluateModule(String.format(Asset.read("js/lib/spider.js"), api));
jsObject = (JSObject) ctx.getProperty(ctx.getGlobalObject(), spider);
}
@ -219,11 +217,8 @@ public class Spider extends com.github.catvod.crawler.Spider {
}
private ByteArrayInputStream getStream(Object o, boolean base64) {
if (o instanceof JSONArray) {
JSONArray a = (JSONArray) o;
byte[] bytes = new byte[a.length()];
for (int i = 0; i < a.length(); i++) bytes[i] = (byte) a.optInt(i);
return new ByteArrayInputStream(bytes);
if (o instanceof byte[]) {
return new ByteArrayInputStream((byte[]) o);
} else {
String content = o.toString();
if (base64 && content.contains("base64,")) content = content.split("base64,")[1];

@ -37,8 +37,8 @@ public class Connect {
jsObject.setProperty("code", res.code());
jsObject.setProperty("headers", jsHeader);
if (req.getBuffer() == 0) jsObject.setProperty("content", new String(res.body().bytes(), req.getCharset()));
if (req.getBuffer() == 1) jsObject.setProperty("content", JSUtil.toArray(ctx, res.body().bytes()));
if (req.getBuffer() == 2) jsObject.setProperty("content", Util.base64(res.body().bytes()));
if (req.getBuffer() == 1) jsObject.setProperty("content", res.body().bytes());
return jsObject;
} catch (Exception e) {
return error(ctx);

@ -19,13 +19,6 @@ public class JSUtil {
return array;
}
public static JSArray toArray(QuickJSContext ctx, byte[] bytes) {
JSArray array = ctx.createNewJSArray();
if (bytes == null || bytes.length == 0) return array;
for (int i = 0; i < bytes.length; i++) array.set((int) bytes[i], i);
return array;
}
public static JSObject toObj(QuickJSContext ctx, Map<String, String> map) {
JSObject obj = ctx.createNewJSObject();
if (map == null || map.isEmpty()) return obj;

@ -1,7 +1,6 @@
package com.fongmi.quickjs.utils;
import android.net.Uri;
import android.util.Base64;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Asset;
@ -60,12 +59,4 @@ public class Module {
return "";
}
}
public byte[] bb(String content) {
byte[] bytes = Base64.decode(content.substring(4), Base64.DEFAULT);
byte[] newBytes = new byte[bytes.length - 4];
newBytes[0] = 1;
System.arraycopy(bytes, 5, newBytes, 1, bytes.length - 5);
return newBytes;
}
}

Loading…
Cancel
Save