| 20 | import dalvik.system.DexClassLoader; |
| 21 | |
| 22 | public class BaseLoader { |
| 23 | |
| 24 | private final JarLoader jarLoader; |
| 25 | private final PyLoader pyLoader; |
| 26 | private final JsLoader jsLoader; |
| 27 | |
| 28 | private BaseLoader() { |
| 29 | jarLoader = new JarLoader(); |
| 30 | pyLoader = new PyLoader(); |
| 31 | jsLoader = new JsLoader(); |
| 32 | } |
| 33 | |
| 34 | public static BaseLoader get() { |
| 35 | return Loader.INSTANCE; |
| 36 | } |
| 37 | |
| 38 | private static boolean isJs(String api) { |
| 39 | return api.contains(".js"); |
| 40 | } |
| 41 | |
| 42 | private static boolean isPy(String api) { |
| 43 | return api.contains(".py"); |
| 44 | } |
| 45 | |
| 46 | private static boolean isCsp(String api) { |
| 47 | return api.startsWith("csp_"); |
| 48 | } |
| 49 | |
| 50 | public void clear() { |
| 51 | Task.execute(() -> { |
| 52 | jarLoader.clear(); |
| 53 | pyLoader.clear(); |
| 54 | jsLoader.clear(); |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | public Spider getSpider(String key, String api, String ext, String jar) { |
| 59 | if (isPy(api)) return pyLoader.getSpider(key, api, ext); |
| 60 | else if (isJs(api)) return jsLoader.getSpider(key, api, ext, jar); |
| 61 | else if (isCsp(api)) return jarLoader.getSpider(key, api, ext, jar); |
| 62 | else return new SpiderNull(); |
| 63 | } |
| 64 | |
| 65 | public Spider getSpider(String key) { |
| 66 | Site site = VodConfig.get().getSite(key); |
| 67 | Live live = LiveConfig.get().getLive(key); |
| 68 | if (!site.isEmpty()) return site.spider(); |
| 69 | if (!live.isEmpty()) return live.spider(); |
| 70 | return new SpiderNull(); |
| 71 | } |
| 72 | |
| 73 | public void setRecent(String key, String api, String jar) { |
| 74 | if (isJs(api)) jsLoader.setRecent(key); |
| 75 | else if (isPy(api)) pyLoader.setRecent(key); |
| 76 | else if (isCsp(api)) jarLoader.setRecent(Util.md5(jar)); |
| 77 | } |
| 78 | |
| 79 | public Object[] proxy(Map<String, String> params) throws Exception { |
nothing calls this directly
no outgoing calls
no test coverage detected