Skip to content

Commit

Permalink
增加支持py源代码
Browse files Browse the repository at this point in the history
增加支持py源代码
  • Loading branch information
hlh2518 committed Sep 17, 2023
1 parent 85ac638 commit 54db958
Show file tree
Hide file tree
Showing 23 changed files with 1,997 additions and 11 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
putDefault(HawkConfig.SEARCH_VIEW, 2); // Text or Picture

}




github命令行上传本地代码
使用Personal access token
Expand Down
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ dependencies {
implementation 'com.orhanobut:hawk:2.0.1'

implementation 'androidx.annotation:annotation:1.6.0'
implementation "com.google.android.exoplayer:exoplayer-core:2.19.0"
implementation "com.google.android.exoplayer:exoplayer-dash:2.19.0"
implementation "com.google.android.exoplayer:exoplayer-hls:2.19.0"
implementation "com.google.android.exoplayer:exoplayer-rtsp:2.19.0"
implementation "com.google.android.exoplayer:extension-rtmp:2.19.0"
implementation "com.google.android.exoplayer:exoplayer-core:exoVersion"
implementation "com.google.android.exoplayer:exoplayer-dash:$exoVersion"
implementation "com.google.android.exoplayer:exoplayer-hls:$exoVersion"
implementation "com.google.android.exoplayer:exoplayer-rtsp:$exoVersion"
implementation "com.google.android.exoplayer:extension-rtmp:$exoVersion"
//implementation 'com.google.android.exoplayer:extension-okhttp:' + rootProject.ext.exoVersion

implementation "com.aliyun.sdk.android:AliyunPlayer:5.5.1.0-full"
Expand All @@ -133,6 +133,7 @@ dependencies {
implementation 'xyz.doikki.android.dkplayer:videocache:3.3.7'

implementation project(":quickjs")
implementation project(":pyramid")

implementation('org.xwalk:xwalk_shared_library:23.53.589.4') {
exclude group: 'com.android.support'
Expand Down
7 changes: 6 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,9 @@
-keep class com.cicada.**{*;}
-dontwarn com.alivc.**
-dontwarn com.aliyun.**
-dontwarn com.cicada.**
-dontwarn com.cicada.**
#add py支持
-keep public class com.undcover.freedom.pyramid.** { *; }
-dontwarn com.undcover.freedom.pyramid.**
-keep public class com.chaquo.python.** { *; }
-dontwarn com.chaquo.python.**
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.github.tvbox.osc.tk",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0.20230917_1210",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
172 changes: 172 additions & 0 deletions app/schemas/com.github.tvbox.osc.data.AppDataBase/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "d2470d2304493a5cf8987b181ba1e601",
"entities": [
{
"tableName": "cache",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `data` BLOB, PRIMARY KEY(`key`))",
"fields": [
{
"fieldPath": "key",
"columnName": "key",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "data",
"columnName": "data",
"affinity": "BLOB",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"key"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "vodRecord",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `vodId` TEXT, `updateTime` INTEGER NOT NULL, `sourceKey` TEXT, `dataJson` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "vodId",
"columnName": "vodId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "updateTime",
"columnName": "updateTime",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "sourceKey",
"columnName": "sourceKey",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "dataJson",
"columnName": "dataJson",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "vodCollect",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `vodId` TEXT, `updateTime` INTEGER NOT NULL, `sourceKey` TEXT, `name` TEXT, `pic` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "vodId",
"columnName": "vodId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "updateTime",
"columnName": "updateTime",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "sourceKey",
"columnName": "sourceKey",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "pic",
"columnName": "pic",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "storageDrive",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `type` INTEGER NOT NULL, `configJson` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "configJson",
"columnName": "configJson",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd2470d2304493a5cf8987b181ba1e601')"
]
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.github.catvod.crawler.JarLoader;
import com.github.catvod.crawler.JsLoader;
import com.github.catvod.crawler.Spider;
import com.github.catvod.crawler.SpiderNull;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.IJKCode;
Expand All @@ -31,6 +32,7 @@
import com.lzy.okgo.callback.AbsCallback;
import com.lzy.okgo.model.Response;
import com.orhanobut.hawk.Hawk;
import com.undcover.freedom.pyramid.PythonLoader;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
Expand Down Expand Up @@ -303,6 +305,9 @@ private void parseJson(String apiUrl, File f) throws Throwable {
}

private void parseJson(String apiUrl, String jsonStr) {
//pyramid-add-start
PythonLoader.getInstance().setConfig(jsonStr);
//pyramid-add-end

JsonObject infoJson = new Gson().fromJson(jsonStr, JsonObject.class);
// spider
Expand Down Expand Up @@ -661,6 +666,16 @@ public String getSpider() {
}

public Spider getCSP(SourceBean sourceBean) {
//pyramid-add-start
if (sourceBean.getApi().startsWith("py_")) {
try {
return PythonLoader.getInstance().getSpider(sourceBean.getKey(), sourceBean.getExt());
} catch (Exception e) {
e.printStackTrace();
return new SpiderNull();
}
}
//pyramid-add-end

// Getting js api
if (sourceBean.getApi().endsWith(".js") || sourceBean.getApi().contains(".js?")) {
Expand All @@ -671,6 +686,22 @@ public Spider getCSP(SourceBean sourceBean) {
}

public Object[] proxyLocal(Map param) {
//pyramid-add-start
try {
if(param.containsKey("api")){
String doStr = param.get("do").toString();
if(doStr.equals("ck"))
return PythonLoader.getInstance().proxyLocal("","",param);
SourceBean sourceBean = ApiConfig.get().getSource(doStr);
return PythonLoader.getInstance().proxyLocal(sourceBean.getKey(),sourceBean.getExt(),param);
}else{
String doStr = param.get("do").toString();
if(doStr.equals("live")) return PythonLoader.getInstance().proxyLocal("","",param);
}
} catch (Exception e) {
e.printStackTrace();
}
//pyramid-add-end

return jarLoader.proxyInvoke(param);
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/github/tvbox/osc/base/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import android.net.Uri;
import android.os.Build;

import androidx.multidex.BuildConfig;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.github.tvbox.osc.BuildConfig;

import com.github.tvbox.osc.callback.EmptyCallback;
import com.github.tvbox.osc.callback.LoadingCallback;
import com.github.tvbox.osc.data.AppDataManager;
Expand All @@ -22,6 +23,7 @@
import com.github.tvbox.osc.util.js.JSEngine;
import com.kingja.loadsir.core.LoadSir;
import com.orhanobut.hawk.Hawk;
import com.undcover.freedom.pyramid.PythonLoader;

import org.conscrypt.Conscrypt;

Expand Down Expand Up @@ -65,6 +67,9 @@ public void onCreate() {
.setSupportSP(false)
.setSupportSubunits(Subunits.MM);
PlayerHelper.init();
//pyramid-add-start
PythonLoader.getInstance().setApplication(this);
//pyramid-add-end

// Delete Cache
/*File dir = getCacheDir();
Expand Down
Loading

0 comments on commit 54db958

Please sign in to comment.