py.sh 2.9 KB

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. #添加PY支持
  3. wget --no-check-certificate -qO- "https://raw.githubusercontent.com/UndCover/PyramidStore/main/aar/pyramid-1011.aar" -O app/libs/pyramid.aar
  4. sed -i "/thunder.jar/a\ implementation files('libs@pyramid.aar')" app/build.gradle
  5. sed -i 's#@#\\#g' app/build.gradle
  6. sed -i 's#pyramid#\\pyramid#g' app/build.gradle
  7. echo "" >>app/proguard-rules.pro
  8. echo "" >>app/proguard-rules.pro
  9. echo "#添加PY支持" >>app/proguard-rules.pro
  10. echo "-keep public class com.undcover.freedom.pyramid.** { *; }" >>app/proguard-rules.pro
  11. echo "-dontwarn com.undcover.freedom.pyramid.**" >>app/proguard-rules.pro
  12. echo "-keep public class com.chaquo.python.** { *; }" >>app/proguard-rules.pro
  13. echo "-dontwarn com.chaquo.python.**" >>app/proguard-rules.pro
  14. sed -i '/import com.orhanobut.hawk.Hawk;/a\import com.undcover.freedom.pyramid.PythonLoader;' app/src/main/java/com/github/tvbox/osc/base/App.java
  15. sed -i '/import com.orhanobut.hawk.Hawk;/a\import com.github.catvod.crawler.SpiderNull;' app/src/main/java/com/github/tvbox/osc/base/App.java
  16. sed -i '/PlayerHelper.init/a\ PythonLoader.getInstance().setApplication(this);' app/src/main/java/com/github/tvbox/osc/base/App.java
  17. sed -i '/import android.util.Base64;/a\import com.github.catvod.crawler.SpiderNull;' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  18. sed -i '/import android.util.Base64;/a\import com.undcover.freedom.pyramid.PythonLoader;' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  19. sed -i '/private void parseJson(String apiUrl, String jsonStr)/a\ PythonLoader.getInstance().setConfig(jsonStr);' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  20. sed -i '/public Spider getCSP(SourceBean sourceBean)/a\ if (sourceBean.getApi().startsWith(\"py_\")) {\n try {\n return PythonLoader.getInstance().getSpider(sourceBean.getKey(), sourceBean.getExt());\n } catch (Exception e) {\n e.printStackTrace();\n return new SpiderNull();\n }\n }' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  21. sed -i '/public Object\[\] proxyLoca/a\ try {\n if(param.containsKey(\"api\")){\n String doStr = param.get(\"do\").toString();\n if(doStr.equals(\"ck\"))\n return PythonLoader.getInstance().proxyLocal(\"\",\"\",param);\n SourceBean sourceBean = ApiConfig.get().getSource(doStr);\n return PythonLoader.getInstance().proxyLocal(sourceBean.getKey(),sourceBean.getExt(),param);\n }else{\n String doStr = param.get(\"do\").toString();\n if(doStr.equals(\"live\")) return PythonLoader.getInstance().proxyLocal(\"\",\"\",param);\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n' app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  22. #FongMi的jar支持
  23. echo "" >>app/proguard-rules.pro
  24. echo "-keep class com.google.gson.**{*;}" >>app/proguard-rules.pro
  25. echo 'DIY end'