|
|
|
|
@ -4,6 +4,8 @@ import android.content.Context; |
|
|
|
|
|
|
|
|
|
import com.chaquo.python.PyObject; |
|
|
|
|
import com.github.catvod.Proxy; |
|
|
|
|
import com.github.catvod.utils.Path; |
|
|
|
|
import com.github.catvod.utils.UriUtil; |
|
|
|
|
import com.github.catvod.utils.Util; |
|
|
|
|
import com.google.gson.Gson; |
|
|
|
|
|
|
|
|
|
@ -17,11 +19,13 @@ public class Spider extends com.github.catvod.crawler.Spider { |
|
|
|
|
private final PyObject app; |
|
|
|
|
private final PyObject obj; |
|
|
|
|
private final Gson gson; |
|
|
|
|
private final String api; |
|
|
|
|
|
|
|
|
|
public Spider(PyObject app, PyObject obj) { |
|
|
|
|
public Spider(PyObject app, PyObject obj, String api) { |
|
|
|
|
this.gson = new Gson(); |
|
|
|
|
this.app = app; |
|
|
|
|
this.obj = obj; |
|
|
|
|
this.api = api; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -31,6 +35,8 @@ public class Spider extends com.github.catvod.crawler.Spider { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void init(Context context, String extend) { |
|
|
|
|
List<PyObject> items = app.callAttr("getDependence", obj).asList(); |
|
|
|
|
for (PyObject item : items) download(item + ".py"); |
|
|
|
|
app.callAttr("init", obj, extend); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -108,6 +114,12 @@ public class Spider extends com.github.catvod.crawler.Spider { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void download(String name) { |
|
|
|
|
String path = Path.py(name).getAbsolutePath(); |
|
|
|
|
String url = UriUtil.resolve(api, name); |
|
|
|
|
app.callAttr("download", path, url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String replaceProxy(String content) { |
|
|
|
|
return content.replace("http://127.0.0.1:UndCover/proxy", Proxy.getUrl(true)); |
|
|
|
|
} |
|
|
|
|
|